Browse Source

Merge remote-tracking branch 'origin/prod-5.1.3' into prod-5.1.3

# Conflicts:
#	hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java
#	hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java
#	hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java
#	hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java
#	hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClient.java
#	hzims-service/hzims-big-model/pom.xml
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IJumpPageService.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpPageServiceImpl.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java
#	hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationVideoTypeClient.java
zhongwei
yang_shj 4 months ago
parent
commit
68ed88192d
  1. 7
      hzims-biz-common/src/main/java/com/hnac/hzims/common/support/utils/Condition.java
  2. 20
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/CanvasSyncDTO.java
  3. 20
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/ControlSyncDTO.java
  4. 50
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java
  5. 20
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java
  6. 12
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ICanvasSyncClient.java
  7. 11
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IControlSyncClient.java
  8. 40
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java
  9. 33
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java
  10. 23
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/ControlDeviceAuthDTO.java
  11. 45
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/feign/IAuthClient.java
  12. 36
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDTO.java
  13. 38
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDeviceDTO.java
  14. 15
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/req/ModelFunctionReq.java
  15. 2
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java
  16. 8
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java
  17. 7
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java
  18. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java
  19. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClient.java
  20. 44
      hzims-service/hzims-big-model/pom.xml
  21. 35
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java
  22. 16
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java
  23. 33
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/DataSourceExecuteController.java
  24. 36
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/RemoteController.java
  25. 87
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/feign/AuthClient.java
  26. 119
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/AuthenticationService.java
  27. 121
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java
  28. 97
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/HistoryDataService.java
  29. 31
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/RemoteService.java
  30. 32
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/SqlVO.java
  31. 28
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/TableAuthVO.java
  32. 27
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/RedisKeyDeleter.java
  33. 73
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java
  34. 74
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionParamController.java
  35. 11
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/mapper/FuncParamMapper.java
  36. 12
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/mapper/FunctionMapper.java
  37. 22
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/IFuncParamService.java
  38. 15
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/IFunctionService.java
  39. 28
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/impl/FuncParamServiceImpl.java
  40. 27
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/impl/FunctionServiceImpl.java
  41. 5
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java
  42. 11
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java
  43. 20
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java
  44. 116
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java
  45. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java
  46. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java
  47. 9
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java
  48. 6
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java
  49. 16
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java
  50. 58
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java
  51. 17
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IJumpPageService.java
  52. 15
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java
  53. 31
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java
  54. 6
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java
  55. 37
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java
  56. 74
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java
  57. 430
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java
  58. 46
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpPageServiceImpl.java
  59. 145
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java
  60. 16
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java
  61. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java
  62. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java
  63. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java
  64. 76
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java
  65. 56
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableColumnController.java
  66. 61
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableInfoController.java
  67. 66
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java
  68. 17
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DataRecordEntity.java
  69. 37
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DatasourceEntity.java
  70. 56
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TableInfoEntity.java
  71. 49
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TablePropertyEntity.java
  72. 12
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/DatasourceMapper.java
  73. 12
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TableInfoMapper.java
  74. 11
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TablePropertyMapper.java
  75. 19
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/DataSourceService.java
  76. 37
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java
  77. 21
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableInfoService.java
  78. 20
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TablePropertyService.java
  79. 101
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java
  80. 76
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java
  81. 122
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java
  82. 8
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java
  83. 201
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java
  84. 21
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java
  85. 81
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java
  86. 65
      hzims-service/hzims-big-model/src/main/resources/db/2.0.0.sql
  87. 4
      hzims-service/hzims-big-model/src/main/resources/template/template.yml
  88. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationVideoTypeClient.java

7
hzims-biz-common/src/main/java/com/hnac/hzims/common/support/utils/Condition.java

@ -7,6 +7,7 @@ import com.hnac.hzims.common.support.constants.Order;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.QueryField;
import org.springblade.core.mp.support.SqlCondition;
import org.springblade.core.tool.api.ResultCode;
import org.springblade.core.tool.utils.Func;
import org.springframework.util.Assert;
@ -68,7 +69,7 @@ public class Condition extends org.springblade.core.mp.support.Condition {
try {
value = field.get(query);
} catch (Exception e) {
throw new ServiceException("获取属性性出错");
throw new ServiceException(ResultCode.FAILURE,"获取属性性出错");
}
if(value == null) {
continue;
@ -96,13 +97,13 @@ public class Condition extends org.springblade.core.mp.support.Condition {
}else if(SqlCondition.NOT_IN.equals(condition)){
String columnName = queryField.columnName();
Assert.isTrue(Func.isBlank(columnName),() -> {
throw new ServiceException("查询不包含条件时需要指定列名");
throw new ServiceException(ResultCode.FAILURE,"查询不包含条件时需要指定列名");
});
qw.notIn(camel2under(columnName),list);
}else if(SqlCondition.IN.equals(condition)){
String columnName = queryField.columnName();
Assert.isTrue(Func.isBlank(columnName), () -> {
throw new ServiceException("查询包含条件时需要指定列名");
throw new ServiceException(ResultCode.FAILURE,"查询包含条件时需要指定列名");
});
qw.in(camel2under(columnName),list);
}

20
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/CanvasSyncDTO.java

@ -0,0 +1,20 @@
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 {
}

20
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/ControlSyncDTO.java

@ -0,0 +1,20 @@
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 {
}

50
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java

@ -0,0 +1,50 @@
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;
}

20
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java

@ -0,0 +1,20 @@
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:42
*/
@ApiModel(value = "视频同步DTO对象",description = "视频同步DTO对象")
@Data
@EqualsAndHashCode
public class VideoSyncDTO extends SyncDTO implements Serializable {
}

12
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ICanvasSyncClient.java

@ -0,0 +1,12 @@
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<CanvasSyncDTO> {
}

11
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IControlSyncClient.java

@ -0,0 +1,11 @@
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<ControlSyncDTO> {
}

40
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java

@ -0,0 +1,40 @@
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<T extends SyncDTO> {
String SAVE_BATCH = "/saveBatch";
String UPDATE_BY_ID = "/updateById";
String DELETE_BY_IDS = "/deleteByIds";
/**
* 同步 - 新增对象
* @param syncDTO 同步对象列表
* @return 同步结果
*/
R saveBatch(List<T> syncDTO);
/**
* 同步 - 更新对象
* @param syncDTO 同步对象
* @return 同步结果
*/
R updateById(T syncDTO);
/**
* 同步 - 删除对象
* @param ids 主键id按逗号分隔
* @return 删除结果
*/
R deleteByIds(String ids);
}

33
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java

@ -0,0 +1,33 @@
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<VideoSyncDTO> {
String PREFIX_API = "/feign/sync/video";
@Override
@PostMapping(PREFIX_API + SAVE_BATCH)
R saveBatch(@RequestBody List<VideoSyncDTO> syncDTO);
@Override
@PutMapping(PREFIX_API + UPDATE_BY_ID)
R updateById(@RequestBody VideoSyncDTO syncDTO);
@Override
@DeleteMapping(PREFIX_API + DELETE_BY_IDS)
R deleteByIds(@RequestParam(value = "ids") String ids);
}

23
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/ControlDeviceAuthDTO.java

@ -0,0 +1,23 @@
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;
}

45
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/feign/IAuthClient.java

@ -0,0 +1,45 @@
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<Map<String, String[]>> getAuthData(String userId);
}

36
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDTO.java

@ -0,0 +1,36 @@
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<ControlDeviceDTO> yks;
}

38
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDeviceDTO.java

@ -0,0 +1,38 @@
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;
}

15
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/req/ModelFunctionReq.java

@ -16,15 +16,16 @@ import java.util.Map;
@ApiModel("大模型响应内容")
public class ModelFunctionReq implements Serializable {
@ApiModelProperty("类型")
private String type;
@JSONField(name = "function_name")
@ApiModelProperty("函数标识")
private String functionName;
private String func;
@ApiModelProperty("会话ID")
private String chatId;
@ApiModelProperty("用户ID")
private String userId;
@JSONField(name = "function_args")
@ApiModelProperty("函数参数")
private Map<String,String> functionArgs;
private Map<String,String> item;
}

2
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java

@ -14,7 +14,7 @@ public class DataItemVO implements Serializable {
private String name;
@JSONField(name = "id")
@JSONField(name = "itemId")
private String attrId;
@JSONField(name = "record_name")

8
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java

@ -1,6 +1,8 @@
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;
@ -21,9 +23,11 @@ public class ExtraVO implements Serializable {
private String type;
@ApiModelProperty("若为弹窗,则返回路由")
@JsonInclude(JsonInclude.Include.NON_NULL)
private String route;
@ApiModelProperty("链接显示文字")
@JsonInclude(JsonInclude.Include.NON_NULL)
private String label;
@ApiModelProperty("函数编号")
@ -33,13 +37,15 @@ public class ExtraVO implements Serializable {
private boolean isImmediatelyJump = false;
@ApiModelProperty("附带参数")
@JsonInclude(JsonInclude.Include.NON_NULL)
private Map<String,Object> params;
@ApiModelProperty("是否为特殊函数")
private boolean isSpecial;
@ApiModelProperty("选项")
private List selection;
@JsonInclude(JsonInclude.Include.NON_NULL)
private List data;
@JSONField(name = "agent_name")
private String agentName;

7
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java

@ -1,5 +1,6 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.io.Serializable;
@ -12,9 +13,11 @@ import java.io.Serializable;
public class SelectionVO implements Serializable {
/**选项ID**/
private String id;
@JSONField(name = "item_id")
private String itemId;
/**选项名称**/
private String name;
@JSONField(name = "item_name")
private String itemName;
}

4
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java

@ -83,5 +83,7 @@ public interface IStationClient {
R<List<StationEntity>> querySatationByCodes(@RequestParam("codes") List<String> codes);
@GetMapping(GET_STATIONS_BY_TYPE_AND_DURATION)
R<List<StationEntity>> getStationByTypeAndDuration(@RequestParam(required = false) String startTime,@RequestParam(required = false) String endTime,@RequestParam(required = false) String type);
R<List<StationEntity>> getStationByTypeAndDuration(@RequestParam(value = "startTime",required = false) String startTime,
@RequestParam(value = "endTime",required = false) String endTime,
@RequestParam(value = "type",required = false) String type);
}

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClient.java

@ -28,5 +28,5 @@ public interface IStationVideoTypeClient {
R<List<StationVideoTypeEntity>> list(StationVideoTypeEntity req);
@GetMapping(GET_BY_ID)
R<StationVideoTypeEntity> getById(@RequestParam Long id);
R<StationVideoTypeEntity> getById(@RequestParam(value = "id",required = false) Long id);
}

44
hzims-service/hzims-big-model/pom.xml

@ -20,7 +20,10 @@
<groupId>org.springblade</groupId>
<artifactId>blade-system-api</artifactId>
</dependency>
<dependency>
<groupId>com.hnac.hzinfo.data</groupId>
<artifactId>hzinfo-data-sdk</artifactId>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>big-model-api</artifactId>
@ -47,44 +50,27 @@
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>hzims-operational-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.hnac.hzinfo.data</groupId>
<artifactId>hzinfo-data-sdk</artifactId>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>equipment-api</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>2.5.6</version>
<artifactId>hzims-operational-api</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.name}-${project.version}</finalName>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<configuration>
<username>${docker.username}</username>
<password>${docker.password}</password>
<repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<useMavenSettingsForAuth>true</useMavenSettingsForAuth>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
<skip>false</skip>
</configuration>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
</plugins>
</build>

35
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java

@ -0,0 +1,35 @@
package com.hnac.hzims.bigmodel.api.feign;
import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
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{
@Override
@PostMapping(PREFIX_API + SAVE_BATCH)
public R saveBatch(@RequestBody List<VideoSyncDTO> syncDTO) {
return null;
}
@Override
@PutMapping(PREFIX_API + UPDATE_BY_ID)
public R updateById(@RequestBody VideoSyncDTO syncDTO) {
return null;
}
@Override
@DeleteMapping(PREFIX_API + DELETE_BY_IDS)
public R deleteByIds(@RequestParam String ids) {
return null;
}
}

16
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java

@ -0,0 +1,16 @@
package com.hnac.hzims.bigmodel.api.service;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* @Author: huangxing
* @Date: 2024/07/10 09:03
*/
@Service
@Slf4j
@AllArgsConstructor
public class SyncService {
}

33
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/DataSourceExecuteController.java

@ -0,0 +1,33 @@
package com.hnac.hzims.bigmodel.business.control;
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<List<Map<String, Object>>> executeQuery(@RequestBody @Valid SqlVO sqlVO) {
return R.data(dataSourceService.queryListOnSpecificDataSource(sqlVO));
}
}

36
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/RemoteController.java

@ -0,0 +1,36 @@
package com.hnac.hzims.bigmodel.business.control;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.bigmodel.BigModelConstants;
import com.hnac.hzims.bigmodel.business.service.RemoteService;
import com.hnac.hzinfo.log.annotation.Business;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author: huangxing
* @Date: 2024/06/24 14:42
*/
@AllArgsConstructor
@RequestMapping("/remote")
@RestController
@Api(value = "数据平台遥控指令管理",tags = "数据平台遥控指令管理")
@Business(module = BigModelConstants.APP_NAME,value = "数据平台遥控指令管理")
public class RemoteController {
private final RemoteService remoteService;
@ApiOperation("下发遥控指令")
@ApiOperationSupport(order = 1)
@PostMapping("/sendRemoteControl")
public R<Object> sendRemoteControl(ControlDTO controlDTO) {
return remoteService.sendRemoteControl(controlDTO);
}
}

87
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/feign/AuthClient.java

@ -0,0 +1,87 @@
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<DeptStationDTO> 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<Map<String,String[]>> getAuthData(String userId) {
Map<String,String[]> result = new HashMap<>(2);
List<DeptStationDTO> 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);
}
}

119
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/AuthenticationService.java

@ -0,0 +1,119 @@
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<DeptStationDTO> 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<Boolean> 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<List<ProjectVO>> 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<List<CtrlAuth>> ctrlAuthR = remoteClient.getCtrlAuth(Optional.ofNullable(userId).filter(StringUtil::isNotBlank).map(Long::parseLong).orElse(null));
Assert.isTrue(ctrlAuthR.isSuccess(),() -> {
throw new ServiceException("该站点未设置鉴权用户,校验失败!");
});
List<CtrlAuth> ctrlAuthList = ctrlAuthR.getData();
Optional<CtrlAuth> 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<DeptStationDTO> getStationPermissionsById(String userId) {
R<List<DeptStationDTO>> deptSattionR = deptClient.getStationPermissionsById(Long.valueOf(userId));
Assert.isTrue(deptSattionR.isSuccess() && CollectionUtil.isNotEmpty(deptSattionR.getData()),() -> {
throw new ServiceException("获取人员站点权限失败!");
});
return deptSattionR.getData();
}
}

121
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java

@ -0,0 +1,121 @@
package com.hnac.hzims.bigmodel.business.service;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.hnac.hzims.bigmodel.business.vo.SqlVO;
import com.hnac.hzims.bigmodel.business.vo.TableAuthVO;
import com.hnac.hzims.common.service.UserAuthDataService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
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 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<Map<String, Object>> 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()));
for (TableAuthVO tableAuthVO : sqlVO.getTableAuthVOList()) {
String tableSubStr = "(SELECT * FROM " + tableAuthVO.getTableName() + " where" + userAuthDataSQL +") temp";
sql = sql.replace(tableAuthVO.getTableName(),tableSubStr);
}
log.info("执行sql:{}",sql);
return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName());
// 过滤更新、删除语句
// Assert.isTrue(!DataSourceService.isUpdateOrDelete(sqlVO.getSql()),() -> {
// throw new ServiceException("执行sql语句包含更新/删除操作,执行失败!");
// });
// String sql = sqlVO.getSql();
// String userAuthDataSQL = userAuthDataService.getUserAuthDataSQL(Long.parseLong(sqlVO.getUserId()));
// List<Map<String,String>> tempViewList = Lists.newArrayList();
// try {
// for (TableAuthVO tableAuthVO : sqlVO.getTableAuthVOList()) {
// // 创建视图语句
// String viewName = "V_TEMP_" + UUID.randomUUID().toString().replace("-", "");
// String createView = "CREATE VIEW " + viewName + " AS SELECT * FROM " + tableAuthVO.getTableName() + " where " + userAuthDataSQL;
// this.updateOnSpecificDataSource(createView,tableAuthVO.getDatasourceName());
// Map<String,String> viewMap = new HashMap(2);
// viewMap.put("datasource",tableAuthVO.getDatasourceName());
// viewMap.put("viewName",viewName);
// tempViewList.add(viewMap);
// sql = sql.replace(tableAuthVO.getTableName(),viewName);
// }
// log.info("执行sql:{}",sql);
// return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName());
// }
// catch(Exception e) {
// log.error("An Error occurred!",e);
// throw new ServiceException("sql执行失败!");
// }
// finally {
// if(CollectionUtil.isNotEmpty(tempViewList)) {
// tempViewList.forEach(viewMap -> {
// this.updateOnSpecificDataSource("DROP VIEW IF EXISTS `" + viewMap.get("viewName")+"`;",viewMap.get("datasource"));
// });
// }
// }
}
/**
* sql
* @param sql
* @param dataSourceName
* @return
*/
public List<Map<String, Object>> 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();
}
}

97
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/HistoryDataService.java

@ -0,0 +1,97 @@
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.log.logger.BladeLogger;
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;
//private final BladeLogger logger;
public static final int DATA_COUNT_MAX = 1000;
public Result<ReductionDataVO> 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));
//logger.info("interactive:getPolymerizationData","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));
}
}
}

31
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/RemoteService.java

@ -0,0 +1,31 @@
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<Object> sendRemoteControl(ControlDTO controlDTO) {
return remoteClient.sendCtrl(controlDTO);
}
}

32
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/SqlVO.java

@ -0,0 +1,32 @@
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<TableAuthVO> tableAuthVOList;
}

28
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/TableAuthVO.java

@ -0,0 +1,28 @@
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;
}

27
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/RedisKeyDeleter.java

@ -0,0 +1,27 @@
package com.hnac.hzims.bigmodel.configuration;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMODEL_ASK_KEY;
/**
* @Author: huangxing
* @Date: 2024/07/12 09:23
*/
@Component
@Slf4j
public class RedisKeyDeleter implements CommandLineRunner {
@Autowired
private RedisTemplate<String, Object> redisTemplate;
@Override
public void run(String... args) throws Exception {
// 删除指定的Redis key
redisTemplate.delete(HZIMS_BIGMODEL_ASK_KEY);
log.info("服务重启删除问题reids缓存:{}",HZIMS_BIGMODEL_ASK_KEY);
}
}

73
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java

@ -1,73 +0,0 @@
package com.hnac.hzims.bigmodel.function.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.entity.FunctionEntity;
import com.hnac.hzims.bigmodel.function.service.IFunctionService;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzinfo.log.annotation.Business;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Author: huangxing
* @Date: 2024/04/29 14:39
*/
@RestController
@RequestMapping("/function")
@Api(value = "大模型函数管理",tags = "大模型函数管理")
@Business(module = BigModelConstants.MODULE_NAME,value = "大模型函数管理")
@AllArgsConstructor
public class FunctionController {
private final IFunctionService functionService;
@PostMapping("/save")
@ApiOperation("保存函数")
@ApiOperationSupport(order = 1)
public R save(@RequestBody @Validated FunctionEntity req) {
return R.status(functionService.save(req));
}
@PutMapping("/updateById")
@ApiOperation("编辑函数")
@ApiOperationSupport(order = 2)
public R updateById(@RequestBody FunctionEntity req) {
return R.status(functionService.save(req));
}
@GetMapping("/list")
@ApiOperation("列表查询")
@ApiOperationSupport(order = 3)
public R<List<FunctionEntity>> list(FunctionEntity req) {
return R.data(functionService.list(Condition.getQueryWrapper(BeanUtil.toMap(req),FunctionEntity.class)));
}
@GetMapping("/page")
@ApiOperation("分页查询")
@ApiOperationSupport(order = 4)
public R<IPage<FunctionEntity>> page(FunctionEntity req, Query query) {
QueryWrapper<FunctionEntity> queryWrapper = Condition.getQueryWrapper(BeanUtil.toMap(req), FunctionEntity.class);
return R.data(functionService.page(Condition.getPage(query),queryWrapper));
}
@DeleteMapping("/remove")
@ApiOperation("删除函数")
@ApiOperationSupport(order = 4)
public R remove(String ids) {
return R.data(functionService.removeByIds(Func.toLongList(",",ids)));
}
}

74
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionParamController.java

@ -1,74 +0,0 @@
package com.hnac.hzims.bigmodel.function.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.entity.FuncParamEntity;
import com.hnac.hzims.bigmodel.entity.FunctionEntity;
import com.hnac.hzims.bigmodel.function.service.IFuncParamService;
import com.hnac.hzims.bigmodel.function.service.IFunctionService;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzinfo.log.annotation.Business;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Author: huangxing
* @Date: 2024/04/29 15:46
*/
@RestController
@RequestMapping("/function/param")
@Api(value = "大模型函数参数管理",tags = "大模型函数参数管理")
@Business(module = BigModelConstants.MODULE_NAME,value = "大模型函数参数管理")
@AllArgsConstructor
public class FunctionParamController {
private final IFuncParamService funcParamService;
@PostMapping("/save")
@ApiOperation("保存函数参数")
@ApiOperationSupport(order = 1)
public R save(@RequestBody @Validated FuncParamEntity req) {
return R.status(funcParamService.save(req));
}
@PutMapping("/save")
@ApiOperation("编辑函数参数")
@ApiOperationSupport(order = 2)
public R updateById(@RequestBody FuncParamEntity req) {
return R.status(funcParamService.save(req));
}
@GetMapping("/list")
@ApiOperation("列表查询")
@ApiOperationSupport(order = 3)
public R<List<FuncParamEntity>> list(FuncParamEntity req) {
return R.data(funcParamService.list(Condition.getQueryWrapper(BeanUtil.toMap(req),FuncParamEntity.class)));
}
@GetMapping("/page")
@ApiOperation("分页查询")
@ApiOperationSupport(order = 4)
public R<IPage<FuncParamEntity>> page(FuncParamEntity req, Query query) {
QueryWrapper<FuncParamEntity> queryWrapper = Condition.getQueryWrapper(BeanUtil.toMap(req), FuncParamEntity.class);
return R.data(funcParamService.page(Condition.getPage(query),queryWrapper));
}
@DeleteMapping("/remove")
@ApiOperation("删除函数参数")
@ApiOperationSupport(order = 4)
public R remove(String ids) {
return R.data(funcParamService.removeByIds(Func.toLongList(",",ids)));
}
}

11
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/mapper/FuncParamMapper.java

@ -1,11 +0,0 @@
package com.hnac.hzims.bigmodel.function.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.bigmodel.entity.FuncParamEntity;
/**
* @Author: huangxing
* @Date: 2024/04/26 11:11
*/
public interface FuncParamMapper extends BaseMapper<FuncParamEntity> {
}

12
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/mapper/FunctionMapper.java

@ -1,12 +0,0 @@
package com.hnac.hzims.bigmodel.function.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.bigmodel.entity.FunctionEntity;
/**
* @Author: huangxing
* @Date: 2024/04/26 11:10
*/
public interface FunctionMapper extends BaseMapper<FunctionEntity> {
}

22
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/IFuncParamService.java

@ -1,22 +0,0 @@
package com.hnac.hzims.bigmodel.function.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.bigmodel.entity.FuncParamEntity;
import java.util.List;
/**
* @Author: huangxing
* @Date: 2024/04/26 11:12
*/
public interface IFuncParamService extends IService<FuncParamEntity> {
/**
* 根据函数ID获取参数列表
* @param funcId 函数ID
* @return 参数列表
*/
List<FuncParamEntity> getParamsByFuncId(Long funcId);
}

15
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/IFunctionService.java

@ -1,15 +0,0 @@
package com.hnac.hzims.bigmodel.function.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.bigmodel.entity.FunctionEntity;
/**
* @Author: huangxing
* @Date: 2024/04/26 11:08
*/
public interface IFunctionService extends IService<FunctionEntity> {
FunctionEntity getFunctionByCode(String code);
}

28
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/impl/FuncParamServiceImpl.java

@ -1,28 +0,0 @@
package com.hnac.hzims.bigmodel.function.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.bigmodel.entity.FuncParamEntity;
import com.hnac.hzims.bigmodel.function.mapper.FuncParamMapper;
import com.hnac.hzims.bigmodel.function.service.IFuncParamService;
import lombok.extern.slf4j.Slf4j;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author: huangxing
* @Date: 2024/04/26 11:13
*/
@Service
@Slf4j
public class FuncParamServiceImpl extends ServiceImpl<FuncParamMapper, FuncParamEntity> implements IFuncParamService {
@Override
public List<FuncParamEntity> getParamsByFuncId(Long funcId) {
LambdaQueryWrapper<FuncParamEntity> queryWrapper = Wrappers.<FuncParamEntity>lambdaQuery().eq(FuncParamEntity::getFuncId, funcId);
return this.list(queryWrapper);
}
}

27
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/impl/FunctionServiceImpl.java

@ -1,27 +0,0 @@
package com.hnac.hzims.bigmodel.function.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.bigmodel.entity.FunctionEntity;
import com.hnac.hzims.bigmodel.function.mapper.FunctionMapper;
import com.hnac.hzims.bigmodel.function.service.IFunctionService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* @Author: huangxing
* @Date: 2024/04/26 11:09
*/
@Service
@Slf4j
@AllArgsConstructor
public class FunctionServiceImpl extends ServiceImpl<FunctionMapper, FunctionEntity> implements IFunctionService {
@Override
public FunctionEntity getFunctionByCode(String code) {
LambdaQueryWrapper<FunctionEntity> queryWrapper = Wrappers.<FunctionEntity>lambdaQuery().eq(FunctionEntity::getCode, code);
return this.getOne(queryWrapper);
}
}

5
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java

@ -24,16 +24,17 @@ public enum FuncRouteEnum {
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)
;
@Getter
private String funcCode;
private String func;
@Getter
private String funcName;
@Getter
private FunctionConstants.TypeEnum type;
public static FuncRouteEnum getEnumByFuncCode(String funcCode) {
Optional<FuncRouteEnum> FuncRoute = Arrays.stream(FuncRouteEnum.class.getEnumConstants()).filter(e -> funcCode.equals(e.getFuncCode())).findFirst();
Optional<FuncRouteEnum> FuncRoute = Arrays.stream(FuncRouteEnum.class.getEnumConstants()).filter(e -> funcCode.equals(e.getFunc())).findFirst();
return FuncRoute.orElse(null);
}

11
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java

@ -10,6 +10,7 @@ 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;
@ -50,7 +51,7 @@ public class FontEndInteractiveController {
@ApiOperation("获取热点问题")
@ApiOperationSupport(order = 3)
@GetMapping("/hotQuestions")
public R<List<String>> hotQuestions() {
public R<List> hotQuestions() {
return R.data(hznlmInvokeService.hotQuestions());
}
@ -60,4 +61,12 @@ public class FontEndInteractiveController {
public R<String> getSessionId() {
return R.data(IdWorker.get32UUID());
}
@ApiOperation("中断当前的问答")
@ApiOperationSupport(order = 5)
@GetMapping("/interruptSession")
public R interruptSession(@RequestParam(value = "id") String sessionId) {
hznlmInvokeService.askAbort(sessionId);
return R.success("操作成功!");
}
}

20
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java

@ -2,12 +2,14 @@ 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 com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO;
import com.hnac.hzinfo.log.annotation.Business;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
/**
* @Author: huangxing
@ -30,6 +33,7 @@ import java.util.List;
public class HznlmInteractiveController {
private final IHznlmInteractiveService interactiveService;
private final DataSourceService dataSourceService;
@PostMapping(value = "/get_auth_data")
@ApiOperation("获取鉴权数据")
@ -44,4 +48,18 @@ public class HznlmInteractiveController {
public R<ExtraVO> resolve(@RequestBody ModelFunctionReq req) {
return R.data(interactiveService.resolve(req));
}
@PostMapping("/execute_query")
@ApiOperation("执行大模型sql")
@ApiOperationSupport(order = 3)
public R<List<Map<String, Object>>> executeQuery(@RequestBody @Valid SqlVO sqlVO) {
return R.data(dataSourceService.queryListOnSpecificDataSource(sqlVO));
}
@PostMapping("/control_device")
@ApiOperation("控制设备")
@ApiOperationSupport(order = 4)
public R<ExtraVO> controlDevice(@RequestBody @Valid ControlDTO req) {
return R.data(interactiveService.controlDevice(req));
}
}

116
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java

@ -1,116 +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.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService;
import com.hnac.hzims.bigmodel.interactive.vo.StationSearchVO;
import com.hnac.hzinfo.log.annotation.Business;
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.springblade.system.dto.ControlDTO;
import org.springframework.web.bind.annotation.*;
import java.text.DecimalFormat;
import java.util.List;
/**
* @Author: huangxing
* @Date: 2024/04/26 14:51
*/
@RestController
@AllArgsConstructor
@Api(value = "FDP大模型交互层",tags = "FDP大模型交互层")
@RequestMapping("/interactive")
@Business(module = BigModelConstants.MODULE_NAME,value = "FDP大模型交互层")
@Deprecated
public class InteractiveController {
private final IInteractiveService interactiveService;
@ApiOperation("解析大模型函数")
@ApiOperationSupport(order = 1)
@PostMapping("/resolve")
public R resolve(@RequestBody ModelFunctionReq req) {
return interactiveService.resolve(req);
}
@ApiOperation("提问")
@ApiOperationSupport(order = 2)
@GetMapping("/ask")
@Deprecated
public R ask(@RequestParam @ApiParam("用户提出问题") String question,@RequestParam @ApiParam("问答sessionId") String sessionId,@RequestParam @ApiParam("用户Id") String userId) {
return interactiveService.ask(question, sessionId, userId);
}
@ApiOperation("站点、菜单鉴权")
@ApiOperationSupport(order = 3)
@Deprecated
@RequestMapping(value = "/authentication",method = {RequestMethod.GET,RequestMethod.POST})
public R authentication(@RequestParam(required = false) @ApiParam("站点编号") String stationId,
@RequestParam @ApiParam("用户ID") String userId,
@RequestParam(required = false) @ApiParam("菜单ID") String func,
@RequestParam(required = false) @ApiParam("会话ID")String askId) {
return R.status(interactiveService.authentication(stationId,userId,func,askId));
}
@ApiOperation("获取问答sessionId")
@ApiOperationSupport(order = 4)
@GetMapping("/getSessionId")
public R<String> getSessionId() {
return R.data(IdWorker.get32UUID());
}
@ApiOperation("删除对话sessionId")
@ApiOperationSupport(order = 5)
@GetMapping("/removeSessionId")
@Deprecated
public R<Boolean> removeSessionId(@RequestParam(value = "id") String sessionId) {
return R.data(interactiveService.removeSessionId(sessionId));
}
@ApiOperation("下发遥控指令")
@ApiOperationSupport(order = 6)
@PostMapping("/sendRemoteControl")
public R sendRemoteControl(@RequestBody ControlDTO operate) {
return interactiveService.sendRemoteControl(operate);
}
@ApiOperation("解析接入站点数量")
@ApiOperationSupport(order = 7)
@PostMapping("/resolveStations")
public R resolveStations(@RequestBody StationSearchVO req) {
return R.data(interactiveService.resolveStations(req.getStartTime(),req.getEndTime(),req.getType(),req.getEnumType()));
}
@ApiOperation("站点发电量")
@ApiOperationSupport(order = 7)
@RequestMapping(value = "/generation",method = {RequestMethod.GET,RequestMethod.POST})
public R generation(@RequestParam @ApiParam("站点编号") String stationId,
@RequestParam @ApiParam("开始时间") String startTime,
@RequestParam @ApiParam("结束时间")String endTime) {
double generate = interactiveService.generation(stationId,startTime,endTime);
DecimalFormat format = new DecimalFormat("0.00");
return R.data(format.format(generate) + "kWh");
}
@ApiOperation("获取热点问题")
@ApiOperationSupport(order = 8)
@GetMapping("/hotQuestions")
@Deprecated
public R hotQuestions() {
try{
List questions = interactiveService.hotQuestions();
return R.data(questions);
}
catch (Exception e) {
e.printStackTrace();
return R.data(Lists.newArrayList());
}
}
}

3
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java

@ -19,12 +19,11 @@ import java.io.Serializable;
@EqualsAndHashCode
public class AuthDataDTO implements Serializable {
@JsonProperty("chat_id")
@JsonProperty("chatId")
@ApiModelProperty("问答ID,用于获取前端发起问答传入缓存中数据")
@NotBlank
private String sessionId;
@JsonProperty("user_id")
@ApiModelProperty("提问用户ID")
@NotBlank
private String userId;

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java

@ -7,7 +7,7 @@ import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService;
import com.hnac.hzims.bigmodel.interactive.service.IResolveService;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
//import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;

9
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java

@ -1,12 +1,9 @@
package com.hnac.hzims.bigmodel.interactive.factory;
import com.hnac.hzims.bigmodel.entity.FunctionEntity;
import com.hnac.hzims.bigmodel.function.service.IFunctionService;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants;
import com.hnac.hzims.bigmodel.interactive.service.IResolveService;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
//import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;
@ -25,7 +22,7 @@ public class ResolveFactory {
* @return 解析函数所需service
*/
public static IResolveService getResolveService(String funcCode) {
BladeLogger logger = SpringUtil.getBean(BladeLogger.class);
// BladeLogger logger = SpringUtil.getBean(BladeLogger.class);
FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(funcCode);
if(Func.isNotEmpty(funcRouteEnum)) {
switch(funcRouteEnum) {
@ -34,7 +31,7 @@ public class ResolveFactory {
case OPEN_VIDEO:
return SpringUtil.getBean("videoResolveService");
default:
logger.error("hzims:bigModel:getResolveService","函数解析失败,函数编号为:" + funcCode);
// logger.error("hzims:bigModel:getResolveService","函数解析失败,函数编号为:" + funcCode);
throw new ServiceException("service解析失败");
}
}

6
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java

@ -1,6 +1,7 @@
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;
@ -16,7 +17,10 @@ import java.util.List;
*/
public interface IHznlmInteractiveService {
List<AuthDataVO> getAuthData(@RequestBody @Valid AuthDataDTO req);
List<AuthDataVO> getAuthData(AuthDataDTO req);
ExtraVO resolve(ModelFunctionReq req);
ExtraVO controlDevice(ControlDTO req);
}

16
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java

@ -1,6 +1,7 @@
package com.hnac.hzims.bigmodel.interactive.service;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.question.dto.QuestionDTO;
import org.springblade.core.tool.api.R;
import java.util.List;
@ -19,8 +20,11 @@ public interface IHznlmInvokeService {
* @param userId 提问人ID
* @return 提问结果
*/
@Deprecated
void ask(String question, String sessionId, String userId);
void ask(QuestionDTO question);
/**
* 特殊问题
* @param sessionId 会话ID
@ -28,8 +32,11 @@ public interface IHznlmInvokeService {
* @param extra 特殊问题内容
* @return 提问结果
*/
@Deprecated
void specialAsk(String sessionId, String userId, Map<String,Object> extra);
void specialAsk(QuestionDTO questionDTO);
/**
* 知识库问题
* @param question 问题名称
@ -37,8 +44,11 @@ public interface IHznlmInvokeService {
* @param userId 提问人ID
* @param knowledge 知识库名称
*/
@Deprecated
void knowledgeAsk(String question, String sessionId, String userId, String knowledge);
void knowledgeAsk(QuestionDTO questionDTO);
/**
* 删除对话记录
* @param sessionId 会话ID
@ -58,6 +68,10 @@ public interface IHznlmInvokeService {
*/
List<AnswerVO> getAnswerBySessionIds(String sessionIds);
/**
* 中断当前的问答
* @param sessionId 会话ID
*/
void askAbort(String sessionId);
}

58
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java

@ -1,58 +0,0 @@
package com.hnac.hzims.bigmodel.interactive.service;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import org.springblade.core.tool.api.R;
import org.springblade.system.dto.ControlDTO;
import java.util.List;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/04/26 14:51
*/
@Deprecated
public interface IInteractiveService {
ExtraVO resolveStations(String startTime, String endTime, String type, String enumType);
R resolve(ModelFunctionReq req);
R ask(String question,String sessionId,String userId);
R specialAsk(String sessionId,String userId,Map<String,Object> extra);
void updateVideo(Map<String,Object> request);
Boolean updateCanvas(Map<String,Object> request);
void updateFault(Map<String,Object> request);
List<AnswerVO> getAnswerBySessionIds(String sessionIds);
Boolean authentication(String stationId, String userId, String func,String sessionId);
Boolean removeSessionId(String sessionId);
/**
* 发起知识库问答
* @param question 问题
* @param sessionId 会话id
* @param userId 用户id
* @param knowledge 知识库名称
* @return 发起结果
*/
R knowledgeAsk(String question, String sessionId, String userId, String knowledge);
R<Object> sendRemoteControl(ControlDTO operate);
Double generation(String stationId, String startTime, String endTime);
/**
* 获取热点问题
* @return 热点问题
*/
List hotQuestions();
}

17
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IJumpPageService.java

@ -1,17 +0,0 @@
package com.hnac.hzims.bigmodel.interactive.service;
import com.hnac.hzims.bigmodel.entity.FunctionEntity;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/04/26 11:46
*/
@Deprecated
public interface IJumpPageService {
String dealJumpTypeFunction(FunctionEntity function, Map<String,String> args);
}

15
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java

@ -1,8 +1,7 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.hnac.hzims.bigmodel.data.service.HistoryDataService;
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;
@ -10,23 +9,13 @@ 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.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 org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.utils.CollectionUtil;
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.time.Duration;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -57,7 +46,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
searchVO.setDataType(adapterDate.getDateType());
ExtraVO extraVO = new ExtraVO();
extraVO.setType(FuncRouteEnum.HISTORY_DATA.getType().getType());
extraVO.setFunc(FuncRouteEnum.HISTORY_DATA.getFuncCode());
extraVO.setFunc(FuncRouteEnum.HISTORY_DATA.getFunc());
Map<String,Object> params = new HashMap<>(1);
Result<ReductionDataVO> reductionDataVOR = historyDataService.getPolymerizationData(searchVO);
String label;

31
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java

@ -7,16 +7,14 @@ 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.bigmodel.interactive.vo.ResolveResultVO;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzinfo.sdk.v5.scada.ScadaClient;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
// import org.springblade.core.log.logger.BladeLogger;
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;
@ -36,35 +34,32 @@ import java.util.stream.IntStream;
public class CanvasResolveServiceImpl implements IResolveService {
private final IStationClient stationClient;
private final BladeLogger logger;
// private final BladeLogger logger;
@Override
public ExtraVO resolve(ModelFunctionReq req) {
Map<String, String> args = req.getFunctionArgs();
String id = args.get("id");
String name = args.get("name");
Map<String, String> args = req.getItem();
String id = args.get("itemId");
String name = args.get("itemName");
Assert.isTrue(StringUtil.isNotBlank(id) && StringUtil.isNotBlank(name),() -> {
logger.error("hzims:video:resolve","解析传参错误,缺少必要参数video_id,传参内容为:" + JSON.toJSONString(req));
throw new ServiceException("解析传参错误,缺少必要参数video_id");
// logger.error("hzims:video:resolve","解析传参错误,缺少必要参数video_id,传参内容为:" + JSON.toJSONString(req));
throw new ServiceException(ResultCode.FAILURE,"解析传参错误,缺少必要参数video_id");
});
return this.resolve(id);
// ExtraVO extra = this.resolve(id);
// String message = "已成功打开" + name + ";";
// return new ResolveResultVO(message,extra);
}
@Override
public ExtraVO resolve(String id) {
ExtraVO extraVO = new ExtraVO();
extraVO.setImmediatelyJump(true);
extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFuncCode());
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<String, String> resolveMap = this.resolve(id, SCADA_PARAMS_SOLVE);
R<StationEntity> 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"));
Integer picResource = Integer.valueOf(resolveMap.get("picResource"));
int picResource = Integer.parseInt(resolveMap.get("picResource"));
Map<String,Object> extraParams = new HashMap<>(1);
extraParams.put("picResource",picResource);
extraVO.setParams(extraParams);
@ -85,10 +80,10 @@ public class CanvasResolveServiceImpl implements IResolveService {
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}&name={name}", resolveMap));
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 ServiceException("解析出来的画面类型在云组态、v3、v4类型之外,无法解析路由");
throw new ServiceException(ResultCode.FAILURE,"解析出来的画面类型在云组态、v3、v4类型之外,无法解析路由");
}
return extraVO;
}
@ -97,7 +92,7 @@ public class CanvasResolveServiceImpl implements IResolveService {
Map<String,String> result = new HashMap<>();
List<String> params = Func.toStrList("\\^", paramsStr);
Assert.isTrue(params.size() == keys.length, () -> {
throw new ServiceException("大模型传参params长度错误,传参为:" + paramsStr);
throw new ServiceException(ResultCode.FAILURE,"大模型传参params长度错误,传参为:" + paramsStr);
});
IntStream.iterate(0, index -> index + 1).limit(params.size()).forEach(index -> result.put(keys[index],params.get(index)));
return result;

6
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java

@ -37,11 +37,7 @@ public class ChoiceAnswerResolveServiceImpl implements IAnswerResolveService {
public ExtraVO getExtra(JSONObject originExtra) {
ExtraVO result = JSONObject.parseObject(JSON.toJSONString(originExtra),ExtraVO.class);
result.setSpecial(true);
String funcCode = originExtra.getString("func");
result.setFunc(funcCode);
result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType());
JSONArray selections = JSONArray.parseArray(JSON.toJSONString(originExtra.get("data")));
result.setSelection(selections);
result.setType(FuncRouteEnum.getEnumByFuncCode(result.getFunc()).getType().getType());
return result;
}
}

37
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java

@ -1,22 +1,32 @@
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 com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO;
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;
/**
@ -29,6 +39,7 @@ import java.util.stream.Collectors;
public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService {
private final AuthenticationService authenticationService;
private final IAuthClient authClient;
@Override
public List<AuthDataVO> getAuthData(AuthDataDTO req) {
@ -45,10 +56,30 @@ public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService {
@Override
public ExtraVO resolve(ModelFunctionReq req) {
IResolveService resolveService = ResolveFactory.getResolveService(req.getFunctionName());
IResolveService resolveService = ResolveFactory.getResolveService(req.getFunc());
return resolveService.resolve(req);
}
@Override
public ExtraVO controlDevice(ControlDTO req) {
ExtraVO result = new ExtraVO();
Optional<ControlDeviceAuthDTO> 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<String,Object> params = BeanUtil.toMap(optional.get());
params.put("value", req.getValue());
result.setParams(params);
return result;
}
public List<AuthDataVO> getDeptAuthData(String userId) {
List<DeptStationDTO> deptStationDTOs = authenticationService.getStationPermissionsById(userId);
return deptStationDTOs.stream().map(this::convertDeptAuthData).collect(Collectors.toList());
@ -56,7 +87,7 @@ public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService {
public List<AuthDataVO> getStationAuthData(String userId) {
List<DeptStationDTO> deptStationDTOs = authenticationService.getStationPermissionsById(userId);
return deptStationDTOs.stream().map(this::convertStationAuthData).filter(d -> Func.isNotBlank(d.getId())).collect(Collectors.toList());
return deptStationDTOs.stream().map(this::convertStationAuthData).filter(d -> Func.isNotBlank(d.getItemId())).collect(Collectors.toList());
}
private AuthDataVO convertStationAuthData(DeptStationDTO req) {

74
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java

@ -1,33 +1,28 @@
package com.hnac.hzims.bigmodel.interactive.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.TypeReference;
import com.google.common.collect.Lists;
import com.hnac.hzims.bigmodel.business.feign.IAuthClient;
import com.hnac.hzims.bigmodel.business.service.AuthenticationService;
import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl;
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.sessionManager.InteractiveSessionManager;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
//import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.dto.DeptStationDTO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -42,10 +37,10 @@ import java.util.Map;
@Slf4j
public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
private final AuthenticationService authenticationService;
private final BigModelInvokeUrl bigModelInvokeUrl;
private final BladeLogger logger;
// private final BladeLogger logger;
private final SessionRedisManager sessionRedisManager;
private final IAuthClient authClient;
@Value("${fdp.host}")
private String fdpHost;
@ -53,8 +48,8 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
@Override
public void ask(String question, String sessionId, String userId) {
Map<String,Object> params = new HashMap<>();
params.put("id",sessionId);
params.put("userid", userId);
params.put("chat_id",sessionId);
params.put("user_id", userId);
params.put("query",question);
Map<String, String[]> authDataIds = this.getAuthDataIds(userId);
params.putAll(authDataIds);
@ -63,10 +58,16 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
}
@Override
public void ask(QuestionDTO question) {
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantAsk(), JSON.toJSONString(question));
sessionRedisManager.addSessionId(question.getChatId());
}
@Override
public void specialAsk(String sessionId, String userId, Map<String, Object> extra) {
Map<String,Object> params = new HashMap<>();
params.put("id",sessionId);
params.put("userid", userId);
params.put("chat_id",sessionId);
params.put("user_id", userId);
params.put("extra",extra);
Map<String, String[]> authDataIds = this.getAuthDataIds(userId);
params.putAll(authDataIds);
@ -76,10 +77,16 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
}
@Override
public void specialAsk(QuestionDTO question) {
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk(), JSON.toJSONString(question));
sessionRedisManager.addSessionId(question.getChatId());
}
@Override
public void knowledgeAsk(String question, String sessionId, String userId, String knowledge) {
Map<String,Object> params = new HashMap<>();
params.put("id", sessionId);
params.put("userid", userId);
params.put("chat_id", sessionId);
params.put("user_id", userId);
params.put("query", question);
params.put("knowledge", knowledge);
Map<String, String[]> authDataIds = this.getAuthDataIds(userId);
@ -89,16 +96,27 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
}
@Override
public void knowledgeAsk(QuestionDTO question) {
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantKnowledgeAsk(), JSON.toJSONString(question));
sessionRedisManager.addSessionId(question.getChatId());
}
@Override
public void removeSessionId(String sessionId) {
Map<String,Object> params = new HashMap<>();
params.put("id",sessionId);
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAskAbort(), params);
this.askAbort(sessionId);
// 移除内存sessionId
InteractiveSessionManager.SESSION_POOL.remove(sessionId);
sessionRedisManager.removeSessionId(sessionId);
}
@Override
public void askAbort(String sessionId) {
Map<String,Object> params = new HashMap<>();
params.put("id",sessionId);
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAskAbort(), params);
}
@Override
public List hotQuestions() {
try {
return RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getHotQuestion(), null, new TypeReference<List<String>>(){});
@ -112,20 +130,14 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
@Override
public List<AnswerVO> getAnswerBySessionIds(String sessionIds) {
Map<String,Object> params = new HashMap<>();
params.put("ids",Func.toStrList(",",sessionIds).toArray());
List<AnswerVO> answerVOList = RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantStatus(), params, new TypeReference<List<AnswerVO>>(){});
return answerVOList;
params.put("chat_ids",Func.toStrList(",",sessionIds).toArray());
return RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantStatus(), params, new TypeReference<List<AnswerVO>>(){});
}
private Map<String,String[]> getAuthDataIds(String userId) {
List<DeptStationDTO> authDatas = authenticationService.getStationPermissionsById(userId);
Map<String, String[]> result = new HashMap<>(2);
String[] stationIds = authDatas.stream().map(DeptStationDTO::getStationId)
.filter(StringUtil::isNotBlank).toArray(String[]::new);
String[] projectIds = authDatas.stream().map(DeptStationDTO::getDeptId)
.filter(Func::isNotEmpty).map(String::valueOf).toArray(String[]::new);
result.put("stationids", stationIds);
result.put("projectids", projectIds);
R<Map<String, String[]>> authDataR = authClient.getAuthData(userId);
result.putAll(authDataR.getData());
return result;
}
}

430
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java

@ -1,430 +0,0 @@
package com.hnac.hzims.bigmodel.interactive.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.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl;
import com.hnac.hzims.bigmodel.entity.FunctionEntity;
import com.hnac.hzims.bigmodel.function.service.IFunctionService;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants;
import com.hnac.hzims.bigmodel.interactive.constants.SearchStationTypeEnum;
import com.hnac.hzims.bigmodel.interactive.constants.SearchTypeEnum;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService;
import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService;
import com.hnac.hzims.bigmodel.interactive.service.IParamsService;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
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.hzims.equipment.feign.IEmInfoClient;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.equipment.vo.RideDeviceVo;
import com.hnac.hzims.operational.fill.feign.IGenerateClient;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO;
import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*;
import org.springblade.system.dto.ControlDTO;
import org.springblade.system.dto.DeptStationDTO;
import org.springblade.system.feign.IDeptClient;
import org.springblade.system.feign.IRemoteClient;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.*;
import java.util.stream.Collectors;
import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.TypeEnum;
import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMODEL_ASK_KEY;
/**
* @Author: huangxing
* @Date: 2024/04/26 14:51
*/
@Service
@Slf4j
@RequiredArgsConstructor
@Deprecated
public class InteractiveServiceImpl implements IInteractiveService {
private final BladeLogger logger;
private final IEmInfoClient deviceClient;
private final IRemoteClient remoteClient;
private final IStationClient stationClient;
private final IGenerateClient generateClient;
private final IJumpPageService jumpPageService;
private final IParamsService paramsService;
private final IFunctionService functionService;
private final BigModelInvokeUrl bigModelInvokeUrl;
private final AuthenticationService authenticationService;
private final RedisTemplate redisTemplate;
private final IAnalyseDataSearchClient analyseDataSearchClient;
private final ExtraResolveStrategyService extraResolveStrategyService;
private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("station-device-generate-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy());
@Value("${fdp.host}")
private String fdpHost;
@Override
public ExtraVO resolveStations(String startTime, String endTime, String type, String enumType) {
ExtraVO extraVO = new ExtraVO();
extraVO.setType(TypeEnum.PARAMS.getType());
extraVO.setFunc("stations_num");
String label;
SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType);
if(!startTime.equals(endTime) && SearchTypeEnum.HISTORY.getSearchType().equals(type)) {
label = String.format("自%s到%s时间为止,",startTime,endTime);
}
else {
startTime = null;
endTime = null;
label = "目前";
}
R<List<StationEntity>> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationTypeEnum.getStationType());
Assert.isTrue(stationListR.isSuccess(),() -> {
throw new ServiceException("获取接入站点数量失败!");
});
Map<String, Object> params = new HashMap<>();
params.put("searchStationType",stationTypeEnum.getSearchStationType());
params.put("label",label + String.format(stationTypeEnum.getLabel(),stationListR.getData().size()));
params.put("startTime",startTime);
params.put("endTime",endTime);
extraVO.setParams(params);
return extraVO;
}
@Override
public R resolve(ModelFunctionReq req) {
logger.info("interactive:resolve","开始解析大模型函数,函数内容为:" + JSON.toJSONString(req));
FunctionEntity function = functionService.getFunctionByCode(req.getFunctionName());
TypeEnum typeEnum = TypeEnum.getTypeEnumByType(function.getType());
if(Func.isEmpty(typeEnum)) {
throw new ServiceException("函数解析失败!");
}
switch (typeEnum) {
// 页面跳转
case JUMP:
String jumpExtra = jumpPageService.dealJumpTypeFunction(function, req.getFunctionArgs());
Assert.isTrue(StringUtil.isNotBlank(jumpExtra) && Func.isNotEmpty(jumpExtra), () -> {
throw new ServiceException("解析" + function.getName() + "函数失败!");
});
return R.data(jumpExtra);
case PARAMS:
String paramExtra = paramsService.dealJumpTypeFunction(function, req.getFunctionArgs());
return R.data(paramExtra);
default:
throw new ServiceException("函数解析失败!");
}
}
@Override
public R ask(String question,String sessionId,String userId) {
Map<String,Object> params = new HashMap<>();
params.put("id",sessionId);
params.put("userid", userId);
params.put("query",question);
params.put("stationids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray());
params.put("projectids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).map(String::valueOf).toArray());
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantAsk())
.body(JSON.toJSONString(params)).execute();
logger.info("interactive:ask","问答传参为:" + JSON.toJSONString(params) + "结果为:" + response.body());
if(response.getStatus() != HttpServletResponse.SC_OK) {
log.error("远程调用大模型【发起问答】接口失败!");
return R.fail("远程调用大模型【发起问答】接口失败!");
}
this.addQuestionSessionId(sessionId);
return R.success("消息发送成功");
}
private void addQuestionSessionId(String sessionId) {
redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,sessionId);
}
@Override
public R specialAsk(String sessionId, String userId, Map<String, Object> extra) {
Map<String,Object> params = new HashMap<>();
params.put("id",sessionId);
params.put("userid", userId);
params.put("extra",extra);
params.put("stationids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray());
params.put("projectids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).map(String::valueOf).toArray());
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk())
.body(JSON.toJSONString(params)).execute();
if(response.getStatus() != HttpServletResponse.SC_OK) {
log.error("远程调用大模型【发起特殊问答】接口失败!");
return R.fail("远程调用大模型【发起特殊问答】接口失败!");
}
this.addQuestionSessionId(sessionId);
return R.success("消息发送成功");
}
@Override
public List hotQuestions() {
String url = fdpHost + bigModelInvokeUrl.getHotQuestion();
return this.postCall(url,null,List.class);
}
/**
* 远程调用http接口
* @param url 接口url
* @param body 传参
* @param resultT 结果解析对象
* @return 结果
* @param <T> 结果解析对象类型
*/
public <T> T postCall(String url,Map body,Class<T> resultT) {
HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute();
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> {
log.error("远程调用大模型接口" + url + "失败!");
throw new ServiceException("远程调用大模型接口" + url + "失败!");
});
return JSONObject.parseObject(response.body(), resultT);
}
@Override
public void updateVideo(Map<String, Object> request) {
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getUpdateVideo())
.body(JSON.toJSONString(request)).execute();
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> {
throw new ServiceException("远程调用大模型【更新实时监控】接口失败!");
});
}
@Override
public Boolean updateCanvas(Map<String, Object> request) {
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getUpdateCanvas())
.body(JSON.toJSONString(request)).execute();
if (response.getStatus() == HttpServletResponse.SC_OK) {
return true;
}
log.error("远程调用大模型【更新实时画面】接口失败!");
return false;
}
@Override
public void updateFault(Map<String, Object> request) {
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getUpdateFault())
.body(JSON.toJSONString(request)).execute();
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> {
throw new ServiceException("远程调用大模型【更新故障列表】接口失败!");
});
}
@Override
public List<AnswerVO> getAnswerBySessionIds(String sessionIds) {
Map<String,Object> params = new HashMap<>();
params.put("ids",Func.toStrList(",",sessionIds).toArray());
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantStatus())
.body(JSON.toJSONString(params)).execute();
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> {
throw new ServiceException("远程调用大模型【获取问题答案】接口失败!");
});
XxlJobLogger.log("接收到答案:"+JSON.toJSONString(response.body()));
List<AnswerVO> result = JSONArray.parseArray(response.body(), AnswerVO.class);
if(CollectionUtil.isNotEmpty(result)) {
logger.info("interactive:getAnswerBySessionIds","获取答案:" + response.body());
}
return result;
}
@Override
public Boolean authentication(String stationId, String userId, String func,String sessionId) {
// 站点鉴权
if(StringUtil.isNotBlank(stationId)) {
authenticationService.stationAuthentication(stationId,userId);
}
// 菜单鉴权
if(StringUtil.isNotBlank(func) && StringUtil.isNotBlank(userId)) {
authenticationService.menuAuthentication(userId,func);
}
// 遥控鉴权
if(FuncRouteEnum.CONFIRM_YK.getFuncCode().equals(func)) {
authenticationService.remoteAuthentication(stationId,userId,sessionId);
}
return true;
}
@Override
public Boolean removeSessionId(String sessionId) {
// 调用大模型删除对话
Map<String,Object> params = new HashMap<>();
params.put("id",sessionId);
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAskAbort())
.body(JSON.toJSONString(params)).execute();
if(response.getStatus() != HttpServletResponse.SC_OK) {
log.error("远程调用大模型【删除对话】接口失败!");
throw new ServiceException("远程调用大模型【删除对话】接口失败!");
}
// 移除对应reids中问题标记
redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,sessionId);
return true;
}
/**
* 发起知识库问答
*/
@Override
public R knowledgeAsk(String question, String sessionId, String userId, String knowledge) {
Map<String,Object> params = new HashMap<>();
params.put("id", sessionId);
params.put("userid", userId);
params.put("query", question);
params.put("knowledge", knowledge);
params.put("stationids", authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId)
.filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray());
params.put("projectids", authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId)
.filter(Func::isNotEmpty).map(String::valueOf).toArray());
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantKnowledgeAsk())
.body(JSON.toJSONString(params)).execute();
logger.info("interactive:knowledgeAsk", "知识库问答传参为:" + JSON.toJSONString(params) + " 结果为:" + response.body());
if (response.getStatus() != HttpServletResponse.SC_OK) {
log.error("远程调用大模型【发起知识库问答】接口失败!");
return R.fail("远程调用大模型【发起知识库问答】接口失败!");
}
this.addQuestionSessionId(sessionId);
return R.success("消息发送成功");
}
/**
* 下发遥控指令
* @param operate
* @return
*/
@Override
public R<Object> sendRemoteControl(ControlDTO operate) {
return remoteClient.sendCtrl(operate);
}
/**
* 站点发电量
* @param stationId
* @param startTime
* @param endTime
* @return
*/
@Override
public Double generation(String stationId, String startTime, String endTime) {
// 步骤1.查询站点
R<StationEntity> station = stationClient.getStationByCode(stationId);
if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){
return 0.0;
}
// 步骤2.查询填报发电量
double fill = generateClient.stationGenerateByTime(stationId,startTime,endTime);
// 步骤3.查询设备
List<RideDeviceVo> devices = deviceClient.rideDevices(Collections.singletonList(station.getData().getRefDept()));
if(CollectionUtil.isEmpty(devices)){
return fill;
}
// 步骤4.遍历设备查询发电量
// 监控线程执行完后返回结果
CountDownLatch countDownLatch = new CountDownLatch(devices.size());
List<Double> deviceGenerate = new CopyOnWriteArrayList();
for(RideDeviceVo device : devices){
pool.submit(()->{
deviceGenerate.add(this.periodTargetFloat(startTime,endTime,5,6,device.getNumber(),device.getRide(), HomePageConstant.HYDROPOWER_GENERATE_POWER));
});
countDownLatch.countDown();
}
//所有模板数据获取完成后释放锁
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
return fill + deviceGenerate.stream().mapToDouble(Double::doubleValue).sum();
}
/***
* 指标数据列表查询
* @param startTime 开始时间
* @param endTime 结束时间
* @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值
* @param cycleType 间隔周期 : 0-> 1-> 2-> 小时 3-> 4-> 5-> 6->
* @param deviceCode 设备编号
* @param ride 配电比
* @param signages 指标
* @return
*/
private Double periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Double ride,String signages) {
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO();
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>();
AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO();
analyzeDataConditionPO.setFull(1);
po.setDeviceCode(deviceCode);
analyzeDataConditionPO.setSignages(signages);
analyzeDataConditionPO.setKeepFigures(2);
analyzeDataConditionPO.setAccessRules(accessRules);
analyzeDataConditionPO.setSaveTimeType(cycleType);
// 间隔
analyzeDataConditionPO.setTimeInterval(1);
analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
signboardConditions.add(analyzeDataConditionPO);
po.setSignboardConditions(signboardConditions);
R<List<AnalyzeDataConditionVO>> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po);
if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) {
return 0.0;
}
List<AnalyzeDataConditionVO> records = result.getData();
if(CollectionUtil.isEmpty(records)){
return 0.0;
}
AnalyzeDataConditionVO analyzeDataConditionVO = records.get(0);
if (ObjectUtil.isEmpty(analyzeDataConditionVO)) {
return 0.0;
}
List<AnalyseDataTaosVO> analyseDataTaosVOList = analyzeDataConditionVO.getList();
if (CollectionUtil.isEmpty(analyseDataTaosVOList)) {
return 0.0;
}
AnalyseDataTaosVO analyseDataTaosVO = analyzeDataConditionVO.getList().get(0);
if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) {
return 0.0;
}
return Double.parseDouble(analyseDataTaosVO.getVal()) * ride;
}
}

46
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpPageServiceImpl.java

@ -1,46 +0,0 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.alibaba.fastjson.JSON;
import com.hnac.hzims.bigmodel.entity.FuncParamEntity;
import com.hnac.hzims.bigmodel.entity.FunctionEntity;
import com.hnac.hzims.bigmodel.function.service.IFuncParamService;
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants;
import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
/**
* @Author: huangxing
* @Date: 2024/04/26 11:46
*/
@Service
@AllArgsConstructor
@Slf4j
@Deprecated
public class JumpPageServiceImpl implements IJumpPageService {
private final IFuncParamService paramService;
private final JumpRouteJoinStrategy strategy;
@Override
public String dealJumpTypeFunction(FunctionEntity function,Map<String,String> args) {
List<FuncParamEntity> params = paramService.getParamsByFuncId(function.getId());
Optional<FuncParamEntity> paramOptional = params.stream().filter(p -> p.getIsRequire()).filter(p -> !args.containsKey(p.getAlias())).findAny();
Assert.isTrue(!paramOptional.isPresent(), () -> {
throw new ServiceException("解析参数失败,缺少参数:" + paramOptional.get().getName());
});
// 跳转页面逻辑
ExtraVO extraVO = strategy.resolve(function,args);
return JSON.toJSONString(extraVO);
}
}

145
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java

@ -1,145 +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.entity.FunctionEntity;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants;
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 lombok.RequiredArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import java.util.*;
import java.util.stream.IntStream;
/**
* @Author: huangxing
* @Date: 2024/04/30 11:38
*/
@Component
@RequiredArgsConstructor
@Deprecated
public class JumpRouteJoinStrategy {
private final IStationClient stationClient;
public static String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"};
/**
* 解析大模型传参
* @param args 大模型传参
* @return 跳转path所需要的参数
*/
public ExtraVO resolve(FunctionEntity function,Map<String,String> args) {
FuncRouteEnum routeEnum = FuncRouteEnum.getEnumByFuncCode(function.getCode());
if(Func.isNotEmpty(routeEnum)) {
switch(routeEnum) {
case OPEN_CANVAS:
return this.getScadaExtra(args,function);
default:
break;
}
}
return null;
}
public ExtraVO getScadaExtra(Map<String,String> args,FunctionEntity function) {
// 跳转页面逻辑
ExtraVO extraVO = new ExtraVO();
extraVO.setImmediatelyJump(true);
extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFuncCode());
Map<String, String> params = this.scadaResolve(args);
// 根据hz3000画面版本获取path
Integer picResource = Integer.valueOf(params.get("picResource"));
JSONObject pathObject = JSONObject.parseObject(function.getPath());
R<StationEntity> stationR = stationClient.getStationByCode(params.get("projectId"));
extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + params.get("name"));
Map<String,Object> extraParams = new HashMap<>(1);
extraParams.put("picResource",picResource);
extraVO.setParams(extraParams);
// 云组态
if(picResource == 0) {
String scada = pathObject.getString("scada");
extraVO.setRoute(this.replacePath(scada, params));
extraVO.setRoute(scada);
}
// v3.0
else if (picResource == 1) {
String v3 = pathObject.getString("v3");
extraVO.setRoute(this.replacePath(v3, params));
}
// v4.0
else if (picResource == 2) {
String v4 = pathObject.getString("v4");
// pic_name 去掉头部的/ 以及尾部的.js
String context = params.get("context");
context = this.removeHeadChars(context,"/");
context = this.removeTailChars(context,".js");
params.put("context",context);
extraVO.setRoute(this.replacePath(v4, params));
}
else {
throw new ServiceException("解析出来的画面类型在云组态、v3、v4类型之外,无法解析路由");
}
extraVO.setType(FunctionConstants.TypeEnum.JUMP.getType());
return extraVO;
}
/**
* 解析实时画面参数
* @param args 大模型解析参数
* @return 实时画面路径拼接所需参数
*/
public Map<String,String> scadaResolve(Map<String,String> args) {
String params = args.get("canvas_id");
// 参数格式为:picResource^context^stationNum^projectId^taskId^name^id
return this.resolve(params,SCADA_PARAMS_SOLVE);
}
public Map<String,String> resolve(String paramsStr,String... keys) {
Map<String,String> result = new HashMap<>();
List<String> params = Func.toStrList("\\^", paramsStr);
Assert.isTrue(params.size() == keys.length, () -> {
throw new ServiceException("大模型传参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<String,String> params) {
Set<Map.Entry<String, String>> entries = params.entrySet();
// 替换path中变量
for (Map.Entry<String, String> 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;
}
}

16
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java

@ -7,15 +7,13 @@ 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.bigmodel.interactive.vo.ResolveResultVO;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
//import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
@ -33,15 +31,15 @@ import java.util.Map;
public class VideoResolveServiceImpl implements IResolveService {
private final IStationVideoTypeClient videoClient;
private final BladeLogger logger;
// private final BladeLogger logger;
@Override
public ExtraVO resolve(ModelFunctionReq req) {
Map<String, String> args = req.getFunctionArgs();
String id = args.get("id");
String name = args.get("name");
Map<String, String> args = req.getItem();
String id = args.get("itemId");
String name = args.get("itemName");
Assert.isTrue(StringUtil.isNotBlank(id) && StringUtil.isNotBlank(name),() -> {
logger.error("hzims:video:resolve","解析传参错误,缺少必要参数video_id,传参内容为:" + JSON.toJSONString(req));
// logger.error("hzims:video:resolve","解析传参错误,缺少必要参数video_id,传参内容为:" + JSON.toJSONString(req));
throw new ServiceException("解析传参错误,缺少必要参数video_id");
});
return this.resolve(id);
@ -60,7 +58,7 @@ public class VideoResolveServiceImpl implements IResolveService {
StationVideoTypeEntity video = videoR.getData();
extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType());
extraVO.setImmediatelyJump(true);
extraVO.setFunc(FuncRouteEnum.OPEN_VIDEO.getFuncCode());
extraVO.setFunc(FuncRouteEnum.OPEN_VIDEO.getFunc());
Map<String,Object> params = new HashMap<>();
params.put("name", video.getName());
params.put("videoHost", video.getVideoHost());

4
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java

@ -24,11 +24,11 @@ import java.io.Serializable;
public class AnswerVO implements Serializable {
@ApiModelProperty("发起问答时的随机ID")
@JSONField(name = "id")
@JSONField(name = "chat_id")
private String sessionId;
@ApiModelProperty("发起问答时的用户ID")
@JSONField(name = "userid")
@JSONField(name = "user_id")
private String userId;
@ApiModelProperty("1代表代表正在进行问答,0代表已完成")

4
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java

@ -19,9 +19,9 @@ import java.io.Serializable;
public class AuthDataVO implements Serializable {
@ApiModelProperty("数据ID")
private String id;
private String itemId;
@ApiModelProperty("数据名称")
private String name;
private String itemName;
}

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java

@ -14,7 +14,7 @@ import java.io.Serializable;
@EqualsAndHashCode
public class RemoteParamVO implements Serializable {
@JSONField(name = "id")
@JSONField(name = "itemId")
private String funcId;
@JSONField(name = "yk_name")

76
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java

@ -0,0 +1,76 @@
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<IPage<DatasourceEntity>> 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<DatasourceEntity> 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>> list(DatasourceEntity req) {
return R.data(dataSourceService.list(Condition.getQueryWrapper(req).lambda()));
}
}

56
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableColumnController.java

@ -0,0 +1,56 @@
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 com.hnac.hzinfo.log.annotation.Business;
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 = "数据库表、列信息查询管理")
@Business(module = BigModelConstants.APP_NAME,value = "数据库表、列信息查询管理",ignore = false)
@AllArgsConstructor
public class TableColumnController {
private final TableColumnService tableColumnService;
@ApiOperation("获取数据库")
@ApiOperationSupport(order = 1)
@GetMapping("/getDatabase")
public R<List<Map<String,Object>>> getDatabase(@RequestParam @ApiParam(value = "数据源名") String datasource) {
return R.data(tableColumnService.getDatabase(datasource));
}
@ApiOperation("获取数据库表列表")
@ApiOperationSupport(order = 2)
@GetMapping("/getTables")
public R<List<Map<String,Object>>> 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<List<Map<String,Object>>> getColumns(String datasource,
@RequestParam @ApiParam(value = "数据源名") String database,
@RequestParam @ApiParam(value = "数据库表名") String tableName) {
return R.data(tableColumnService.getColumns(datasource,database,tableName));
}
}

61
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableInfoController.java

@ -0,0 +1,61 @@
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 com.hnac.hzinfo.log.annotation.Business;
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
@Business(module = BigModelConstants.APP_NAME,value = "数据库信息管理",ignore = false)
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<IPage<TableInfoEntity>> 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)));
}
}

66
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java

@ -0,0 +1,66 @@
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<IPage<TablePropertyEntity>> 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<TablePropertyEntity> 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));
}
}

17
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DataRecordEntity.java

@ -0,0 +1,17 @@
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;
}

37
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DatasourceEntity.java

@ -0,0 +1,37 @@
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
@TableName("HZIMS_DATASOURCE")
@ApiModel(value = "数据源配置",description = "数据源配置")
public class DatasourceEntity extends TenantEntity implements Serializable {
@ApiModelProperty("数据源")
@QueryField(condition = SqlCondition.LIKE)
private String datasource;
@ApiModelProperty("数据源名称")
@QueryField(condition = SqlCondition.LIKE)
private String datasourceName;
@ApiModelProperty("数据库名称")
@QueryField(condition = SqlCondition.LIKE)
private String databaseName;
}

56
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TableInfoEntity.java

@ -0,0 +1,56 @@
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 {
@TableField("db_source")
@ApiModelProperty("数据源")
@NotBlank
@QueryField(condition = SqlCondition.LIKE)
private String datasource;
@TableField("db_name")
@ApiModelProperty("数据库")
@NotBlank
@QueryField(condition = SqlCondition.EQUAL)
private String database;
@ApiModelProperty("数据库表名")
@NotBlank
@QueryField(condition = SqlCondition.EQUAL)
private String tableName;
@ApiModelProperty("数据库表描述信息")
@NotBlank
@QueryField(condition = SqlCondition.LIKE)
private String tableDesc;
@ApiModelProperty("数据库表列信息")
@NotBlank
private String propDesc;
@ApiModelProperty("举例")
@NotBlank
private String example;
}

49
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TablePropertyEntity.java

@ -0,0 +1,49 @@
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;
}

12
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/DatasourceMapper.java

@ -0,0 +1,12 @@
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<DatasourceEntity> {
}

12
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TableInfoMapper.java

@ -0,0 +1,12 @@
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<TableInfoEntity> {
}

11
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TablePropertyMapper.java

@ -0,0 +1,11 @@
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<TablePropertyEntity> {
}

19
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/DataSourceService.java

@ -0,0 +1,19 @@
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<DatasourceMapper, DatasourceEntity> {
}

37
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java

@ -0,0 +1,37 @@
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<Map<String,Object>> getDatabase(String datasource) {
String sql = "select distinct `table_schema` as tableName from `information_schema`.`tables` where `table_schema` <> 'information_schema';";
return dataSourceService.queryListOnSpecificDataSource(sql,datasource);
}
public List<Map<String, Object>> getTables(String datasource,String database) {
String sql = "select distinct `table_name` as tableName from `information_schema`.`tables` where `table_schema` = '" + database + "';";
return dataSourceService.queryListOnSpecificDataSource(sql,datasource);
}
public List<Map<String, Object>> getColumns(String datasource,String database,String tableName) {
String sql = "select distinct `column_name` as columnName,`column_comment` as columnComment from `information_schema`.`COLUMNS` where `TABLE_SCHEMA` = '" + database + "' and `TABLE_NAME` = '" + tableName + "';";
return dataSourceService.queryListOnSpecificDataSource(sql,datasource);
}
}

21
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableInfoService.java

@ -0,0 +1,21 @@
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<TableInfoMapper, TableInfoEntity> {
}

20
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TablePropertyService.java

@ -0,0 +1,20 @@
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<TablePropertyMapper, TablePropertyEntity> {
}

101
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java

@ -0,0 +1,101 @@
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<String,Object> 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;
}

76
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java

@ -0,0 +1,76 @@
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<String, Object> 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;
}

122
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java

@ -0,0 +1,122 @@
package com.hnac.hzims.bigmodel.question.service;
import com.alibaba.fastjson.JSON;
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 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
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())) {
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 = (VideoSelectionVO) messageDTO.getExtra().get("data");
IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_VIDEO.getFunc());
String videoId = selection.getItemId();
ExtraVO videoExtras = resolveService.resolve(videoId);
AnswerVO answerVO = new AnswerVO();
answerVO.setSessionId(messageDTO.getChatId());
answerVO.setQuery(selection.getItemName());
answerVO.setRunning(0);
answerVO.setStatus(0);
answerVO.setAnswer("已成功打开"+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) {
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 = (ScadaSelectionVO) messageDTO.getExtra().get("data");
IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_CANVAS.getFunc());
ExtraVO scadaExtra = resolveService.resolve(selection.getItemId());
AnswerVO answerVO = new AnswerVO();
answerVO.setSessionId(messageDTO.getChatId());
answerVO.setRunning(0);
answerVO.setStatus(0);
answerVO.setQuery(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);
}
}
}

8
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java

@ -16,7 +16,7 @@ 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.log.logger.BladeLogger;
//import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
@ -45,10 +45,10 @@ public class FrontEndInteractiveSchedule {
private final InteractiveWsService wsService;
private final ThreadPoolExecutor getAnswerPoolExecutor;
private final IHznlmInvokeService hznlmInvokeService;
private final BladeLogger logger;
// private final BladeLogger logger;
@XxlJob(GET_INTERACTIVE_RESULT)
public ReturnT getInteractiveResult(String params) {
public ReturnT<String> getInteractiveResult(String params) {
List<String> sessionIds = sessionRedisManager.getSessionIds();
if(CollectionUtil.isEmpty(sessionIds)){
XxlJobLogger.log("问题都已经回答完毕!");
@ -58,7 +58,7 @@ public class FrontEndInteractiveSchedule {
answerList.stream().parallel().forEach(answerVO -> CompletableFuture.runAsync(() -> {
// 如果已经获取到答案 则删除缓存
if(answerVO.getRunning() == 0) {
logger.info("hzims:bigmodel:getInteractiveResult:answer","获取大模型解析答案:" + JSON.toJSONString(answerVO));
// logger.info("hzims:bigmodel:getInteractiveResult:answer","获取大模型解析答案:" + JSON.toJSONString(answerVO));
sessionRedisManager.removeSessionId(answerVO.getSessionId());
}
Object[] extras = answerVO.getExtras();

201
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java

@ -1,201 +0,0 @@
package com.hnac.hzims.bigmodel.schedule;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService;
import com.hnac.hzims.bigmodel.interactive.service.impl.ExtraResolveStrategyService;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.interactive.vo.UpdateStationVO;
import com.hnac.hzims.bigmodel.interactive.vo.UpdateUsualVO;
import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService;
import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient;
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 com.hnac.hzinfo.sdk.v5.scada.ScadaClient;
import com.hnac.hzinfo.sdk.v5.scada.vo.CanvasVO;
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 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.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.stream.Collectors;
import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.*;
/**
* @Author: huangxing
* @Date: 2024/04/28 16:18
*/
@Component
@AllArgsConstructor
@Deprecated
public class InteractiveSchedule {
private final InteractiveWsService wsService;
private final IInteractiveService interactiveService;
private final ThreadPoolExecutor getAnswerPoolExecutor;
private final RedisTemplate redisTemplate;
private final IStationVideoTypeClient videoClient;
private final ProjectClient projectClient;
private final ScadaClient scadaClient;
private final IStationClient stationClient;
private final ExtraResolveStrategyService extraResolveStrategyService;
// @XxlJob(GET_INTERACTIVE_RESULT)
public ReturnT getInteractiveResult(String params) {
List<String> sessionIds = redisTemplate.opsForList().range(HZIMS_BIGMODEL_ASK_KEY, 0, -1);
if(CollectionUtil.isEmpty(sessionIds)){
XxlJobLogger.log("问题都已经回答完毕!");
return ReturnT.SUCCESS;
}
List<AnswerVO> answerList = interactiveService.getAnswerBySessionIds(String.join(",", sessionIds));
answerList.stream().parallel().forEach(answerVO -> CompletableFuture.runAsync(() -> {
// 如果已经获取到答案 则删除缓存
if(answerVO.getRunning() == 0) {
redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId());
}
Object[] extras = answerVO.getExtras();
if(ObjectUtil.isNotEmpty(answerVO.getExtras()) && extras.length > 0){
try {
List<String> extraList = Arrays.stream(extras).map(Object::toString).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList());
answerVO.setExtras(extraList.toArray(new String[extraList.size()]));
}
catch(Exception e) {
e.printStackTrace();
AnswerVO.error(answerVO);
answerVO.setAnswer("非常抱歉,系统在处理您的请求时遇到了问题。请稍后再试或联系我们的客服团队。");
}
}
if(sessionIds.contains(answerVO.getSessionId())){
WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId());
TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO));
if(Func.isNotEmpty(session)) {
wsService.sendMessage(session,message);
}
}
}, getAnswerPoolExecutor));
return ReturnT.SUCCESS;
}
@XxlJob(SYNCHRONOUS_VIDEO_INSTRUCT)
public ReturnT synchronousVideoInstruct(String params) {
Map<String,Object> request = new HashMap<>(2);
// 获取站点列表
R<List<StationEntity>> stationsR = stationClient.list(new StationEntity());
if(!stationsR.isSuccess() || CollectionUtil.isEmpty(stationsR.getData())) {
XxlJobLogger.log("获取站点列表失败!");
return ReturnT.FAIL;
}
List<UpdateStationVO> updateStationList = stationsR.getData().stream().map(station -> {
UpdateStationVO stationVO = new UpdateStationVO();
stationVO.setId(station.getCode());
stationVO.setName(station.getName());
return stationVO;
}).collect(Collectors.toList());
request.put("stations", updateStationList);
// 获取视频列表
R<List<StationVideoTypeEntity>> videoListR = videoClient.list(new StationVideoTypeEntity());
if(!videoListR.isSuccess() || CollectionUtil.isEmpty(videoListR.getData())) {
XxlJobLogger.log("获取视频列表失败!");
return ReturnT.FAIL;
}
List<UpdateUsualVO> updateUsualList = videoListR.getData().stream().map(video -> {
UpdateUsualVO usualVO = new UpdateUsualVO();
usualVO.setStationId(video.getStationId());
usualVO.setId(String.valueOf(video.getId()));
usualVO.setName(video.getName());
return usualVO;
}).collect(Collectors.toList());
request.put("videos", updateUsualList);
// 同步指令
interactiveService.updateVideo(request);
return ReturnT.SUCCESS;
}
@XxlJob(SYNCHRONOUS_SCADA_INSTRUCT)
public ReturnT synchronousScadaInstruct(String params) {
// 查询项目数据
Result<List<ProjectVO>> projects = projectClient.getProjectByAppId();
if(!projects.isSuccess() || CollectionUtil.isEmpty(projects.getData())){
return ReturnT.SUCCESS;
}
// 请求fdp同步实时画面方法参数定义
Map<String,Object> param = new HashMap<>(2);
List<UpdateStationVO> stations = projects.getData().stream().map(station -> {
UpdateStationVO updateStation = new UpdateStationVO();
updateStation.setId(station.getId());
updateStation.setName(station.getName());
return updateStation;
}).collect(Collectors.toList());
param.put("stations", stations);
// 查询画面信息
Result<List<CanvasVO>> canvas = scadaClient.getCanvasList(projects.getData().stream().map(ProjectVO::getId).collect(Collectors.toList()));
if(!canvas.isSuccess() || CollectionUtil.isEmpty(canvas.getData())) {
return ReturnT.SUCCESS;
}
List<UpdateUsualVO> updateUsuals = canvas.getData().stream().map(canva -> {
UpdateUsualVO usualVO = new UpdateUsualVO();
usualVO.setStationId(canva.getProjectId());
usualVO.setName(canva.getName());
// 画面id =
String id = Optional.of(canva.getPicSource()).map(String::valueOf).orElse("") + "^" +
Optional.ofNullable(canva.getContext()).orElse("") + "^" +
Optional.ofNullable(canva.getStationNum()).orElse("") + "^" +
Optional.ofNullable(canva.getProjectId()).orElse("") + "^" +
Optional.ofNullable(canva.getTaskId()).map(String::valueOf).orElse("") + "^" +
Optional.ofNullable(canva.getName()).orElse("") + "^" +
Optional.ofNullable(canva.getId()).map(String::valueOf).orElse("") + "^";
usualVO.setId(id);
return usualVO;
}).collect(Collectors.toList());
param.put("canvases", updateUsuals);
Boolean status = interactiveService.updateCanvas(param);
return ReturnT.SUCCESS;
}
@XxlJob(SYNCHRONOUS_FAULT_INSTRUCT)
public ReturnT synchronousFaultInstruct(String params) {
Map<String,Object> request = new HashMap<>(2);
// 获取站点列表
R<List<StationEntity>> stationsR = stationClient.list(new StationEntity());
if(!stationsR.isSuccess() || CollectionUtil.isEmpty(stationsR.getData())) {
XxlJobLogger.log("获取站点列表失败!");
return ReturnT.FAIL;
}
List<UpdateStationVO> updateStationList = stationsR.getData().stream().map(station -> {
UpdateStationVO stationVO = new UpdateStationVO();
stationVO.setId(station.getCode());
stationVO.setName(station.getName());
return stationVO;
}).collect(Collectors.toList());
request.put("stations", updateStationList);
interactiveService.updateFault(request);
return ReturnT.SUCCESS;
}
}

21
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java

@ -7,9 +7,9 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.ResultCode;
import org.springframework.util.Assert;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
@ -19,6 +19,21 @@ import java.util.Map;
@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() == ResultCode.SUCCESS.getCode(), () -> {
throw new ServiceException("远程调用接口" + url + "失败!");
});
}
/**
* 无返回结果远程调用http接口
* @param url 接口url
@ -28,7 +43,7 @@ public class RequestClientUtil {
log.info("开始远程调用{}接口",url);
HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute();
log.info("远程调用{}接口结束",url);
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> {
Assert.isTrue(response.getStatus() == ResultCode.SUCCESS.getCode(), () -> {
throw new ServiceException("远程调用接口" + url + "失败!");
});
}
@ -43,7 +58,7 @@ public class RequestClientUtil {
*/
public static <T> T postCall(String url, Map body, TypeReference<T> typeRef) {
HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute();
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> {
Assert.isTrue(response.getStatus() == ResultCode.SUCCESS.getCode(), () -> {
throw new ServiceException("远程调用大模型接口" + url + "失败!");
});
return JSONObject.parseObject(response.body(), typeRef);

81
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java

@ -2,26 +2,20 @@ package com.hnac.hzims.bigmodel.websocket.handler;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.bigmodel.entity.FunctionEntity;
import com.hnac.hzims.bigmodel.function.service.IFunctionService;
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.impl.JumpRouteJoinStrategy;
import com.hnac.hzims.bigmodel.interactive.service.impl.ParamStrategy;
import com.hnac.hzims.bigmodel.interactive.service.IResolveService;
import com.hnac.hzims.bigmodel.interactive.vo.*;
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService;
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.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.CloseStatus;
@ -30,10 +24,8 @@ import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.TextWebSocketHandler;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
/**
* @Author: huangxing
@ -69,8 +61,8 @@ public class InteractiveHandler extends TextWebSocketHandler {
@Override
protected void handleTextMessage(WebSocketSession session, TextMessage message) {
JSONObject messageJSON = JSONObject.parseObject(message.getPayload());
if("0".equals(messageJSON.getString("type"))) {
MessageDTO messageDTO = JSONObject.parseObject(message.getPayload(), MessageDTO.class);
if("0".equals(messageDTO.getType())) {
// 接收心跳消息,返回一条心跳消息
try {
session.sendMessage(InteractiveSessionManager.getTextMessage("0","收到心跳消息"));
@ -78,14 +70,33 @@ public class InteractiveHandler extends TextWebSocketHandler {
throw new RuntimeException(e);
}
} else {
String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey();
if(messageJSON.containsKey("content")) {
// 将发送参数存入redis
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,sessionId,messageJSON.getObject("content", SessionContentVO.class));
redisTemplate.opsForHash().put(RedisKeyConstants.SESSION_CONTENT_KEY,chatId,messageDTO.getContent());
}
this.handleMessage(messageJSON, sessionId);
QuestionHandlerService service = SpringUtil.getBean(QuestionHandlerService.class);
service.handleMessage(messageDTO);
}
// JSONObject messageJSON = JSONObject.parseObject(message.getPayload());
// if("0".equals(messageJSON.getString("type"))) {
// // 接收心跳消息,返回一条心跳消息
// try {
// session.sendMessage(InteractiveSessionManager.getTextMessage("0","收到心跳消息"));
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// } else {
// String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey();
// if(messageJSON.containsKey("content")) {
// // 将发送参数存入redis
// redisTemplate.expire(RedisKeyConstants.SESSION_CONTENT_KEY,30, TimeUnit.MINUTES);
// redisTemplate.opsForHash().put(RedisKeyConstants.SESSION_CONTENT_KEY,sessionId,messageJSON.getObject("content", SessionContentVO.class));
// }
// this.handleMessage(messageJSON, sessionId);
// }
}
private void handleMessage(JSONObject messageContext, String sessionId) {
@ -94,13 +105,11 @@ public class InteractiveHandler extends TextWebSocketHandler {
String context = messageContext.getString("context");
String userId = messageContext.getString("userId");
String knowledge = messageContext.getString("knowledge");
IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class);
IHznlmInvokeService hznlmInvokeService = SpringUtil.getBean(IHznlmInvokeService.class);
if (knowledge != null) {
R askResult = interactiveService.knowledgeAsk(context, sessionId, userId, knowledge);
log.info("知识库问答返回结果:" + JSON.toJSONString(askResult));
hznlmInvokeService.knowledgeAsk(context, sessionId, userId, knowledge);
} else {
R askResult = interactiveService.ask(context, sessionId, userId);
log.info("返回结果为:"+ JSON.toJSONString(askResult));
hznlmInvokeService.ask(context, sessionId, userId);
}
}
else {
@ -136,18 +145,16 @@ public class InteractiveHandler extends TextWebSocketHandler {
private void handleVideoChoose(JSONObject messageContext,String sessionId) {
InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class);
try {
ParamStrategy strategy = SpringUtil.getBean(ParamStrategy.class);
VideoSelectionVO selection = messageContext.getObject("selection", VideoSelectionVO.class);
String videoId = selection.getId();
Map<String,String> param = new HashMap<>(1);
param.put("canvas_id",videoId);
ExtraVO videoExtras = strategy.getVideoExtra(param);
IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_VIDEO.getFunc());
String videoId = selection.getItemId();
ExtraVO videoExtras = resolveService.resolve(videoId);
AnswerVO answerVO = new AnswerVO();
answerVO.setSessionId(sessionId);
answerVO.setQuery(selection.getName());
answerVO.setQuery(selection.getItemName());
answerVO.setRunning(0);
answerVO.setStatus(0);
answerVO.setAnswer("已成功打开"+selection.getName()+"视频");
answerVO.setAnswer("已成功打开"+selection.getItemName()+"视频");
answerVO.setExtras(new Object[]{JSON.toJSONString(videoExtras)});
TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO));
wsService.sendMessage(sessionId,textMessage);
@ -165,19 +172,15 @@ public class InteractiveHandler extends TextWebSocketHandler {
private void handleScadaChoose(JSONObject messageContext,String sessionId) {
InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class);
try {
JumpRouteJoinStrategy strategy = SpringUtil.getBean(JumpRouteJoinStrategy.class);
ScadaSelectionVO selection = messageContext.getObject("selection", ScadaSelectionVO.class);
Map<String,String> param = new HashMap<>(1);
param.put("canvas_id",selection.getId());
IFunctionService functionService = SpringUtil.getBean(IFunctionService.class);
FunctionEntity function = functionService.getFunctionByCode(FuncRouteEnum.OPEN_CANVAS.getFuncCode());
ExtraVO scadaExtra = strategy.getScadaExtra(param, function);
IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_CANVAS.getFunc());
ExtraVO scadaExtra = resolveService.resolve(selection.getItemId());
AnswerVO answerVO = new AnswerVO();
answerVO.setSessionId(sessionId);
answerVO.setRunning(0);
answerVO.setStatus(0);
answerVO.setQuery(selection.getName());
answerVO.setAnswer("已成功打开"+selection.getName()+"实时画面");
answerVO.setQuery(selection.getItemName());
answerVO.setAnswer("已成功打开"+selection.getItemName()+"实时画面");
answerVO.setExtras(new Object[]{JSON.toJSONString(scadaExtra)});
TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO));
wsService.sendMessage(sessionId,textMessage);

65
hzims-service/hzims-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='模型函数参数';

4
hzims-service/hzims-big-model/src/main/resources/template/template.yml

@ -44,10 +44,10 @@ xxl:
job:
accessToken: ''
admin:
addresses: http://192.168.60.29:7009/xxl-job-admin
addresses: http://192.168.60.104:7009/xxl-job-admin
executor:
appname: hzims-big-model
ip: 172.31.0.12
ip: 172.31.0.174
logpath: /data/applogs/xxl-job/jobhandler
logretentiondays: 7
port: 28135

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationVideoTypeClient.java

@ -7,11 +7,6 @@ import com.hnac.hzims.common.support.utils.Condition;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.service.IStationVideoTypeService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

Loading…
Cancel
Save