Browse Source

fix:大模型代码同步

zhongwei
haungxing 5 months ago
parent
commit
25baab8939
  1. 20
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/CanvasSyncDTO.java
  2. 20
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/ControlSyncDTO.java
  3. 50
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java
  4. 20
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java
  5. 12
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ICanvasSyncClient.java
  6. 11
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IControlSyncClient.java
  7. 40
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java
  8. 33
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java
  9. 23
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/ControlDeviceAuthDTO.java
  10. 45
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/feign/IAuthClient.java
  11. 24
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/entity/WhitelistEntity.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. 14
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java
  16. 40
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java
  17. 35
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java
  18. 31
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java
  19. 18
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java
  20. 20
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java
  21. 13
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteSelectionVO.java
  22. 18
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ScadaSelectionVO.java
  23. 23
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java
  24. 15
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSelectionVO.java
  25. 16
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/VideoSelectionVO.java
  26. 26
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java
  27. 15
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java
  28. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java
  29. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java
  30. 10
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClient.java
  31. 11
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClientFallback.java
  32. 37
      hzims-service/hzims-big-model/pom.xml
  33. 32
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java
  34. 35
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java
  35. 16
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java
  36. 33
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/DataSourceExecuteController.java
  37. 36
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/RemoteController.java
  38. 87
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/feign/AuthClient.java
  39. 119
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/AuthenticationService.java
  40. 121
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java
  41. 97
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/HistoryDataService.java
  42. 31
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/RemoteService.java
  43. 32
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/SqlVO.java
  44. 28
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/TableAuthVO.java
  45. 13
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java
  46. 73
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java
  47. 74
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionParamController.java
  48. 11
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/mapper/FuncParamMapper.java
  49. 12
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/mapper/FunctionMapper.java
  50. 22
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/IFuncParamService.java
  51. 15
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/IFunctionService.java
  52. 28
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/impl/FuncParamServiceImpl.java
  53. 27
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/impl/FunctionServiceImpl.java
  54. 27
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataAuthTypeEnum.java
  55. 36
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataMethodEnum.java
  56. 41
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java
  57. 22
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java
  58. 11
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java
  59. 11
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/InfoMessageConstant.java
  60. 19
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java
  61. 22
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ProjectRemoteTypeEnum.java
  62. 44
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java
  63. 28
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java
  64. 72
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java
  65. 65
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java
  66. 62
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java
  67. 35
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java
  68. 55
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java
  69. 41
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java
  70. 16
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnalyseDataService.java
  71. 34
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnswerResolveService.java
  72. 26
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java
  73. 77
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java
  74. 26
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java
  75. 16
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IJumpPageService.java
  76. 17
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java
  77. 89
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java
  78. 129
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java
  79. 43
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java
  80. 50
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java
  81. 100
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java
  82. 143
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java
  83. 105
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java
  84. 45
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpPageServiceImpl.java
  85. 134
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java
  86. 106
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java
  87. 59
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java
  88. 73
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java
  89. 29
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java
  90. 27
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java
  91. 37
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/HistoryDataSearchVO.java
  92. 39
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java
  93. 29
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ResolveResultVO.java
  94. 19
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SessionContentVO.java
  95. 24
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java
  96. 20
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateStationVO.java
  97. 25
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateUsualVO.java
  98. 76
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java
  99. 56
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableColumnController.java
  100. 61
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableInfoController.java
  101. Some files were not shown because too many files have changed in this diff Show More

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 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);
}

24
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/entity/WhitelistEntity.java

@ -0,0 +1,24 @@
package com.hnac.hzims.bigmodel.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
/**
* @author ysj
*/
@EqualsAndHashCode(callSuper = true)
@TableName("hzims_whitelist")
@ApiModel(value = "白名单实体类",description = "大模型白名单")
@Data
public class WhitelistEntity extends TenantEntity {
@ApiModelProperty(value = "用户Id")
private Long userId;
@ApiModelProperty(value = "用户登录账号")
private String account;
}

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;
}

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

@ -0,0 +1,14 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import lombok.Data;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/24 15:55
*/
@Data
public class AttrSelectionVO extends SelectionVO implements Serializable {
private DataItemVO item;
}

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

@ -0,0 +1,40 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/22 10:20
*/
@Data
public class DataItemVO implements Serializable {
private String name;
@JSONField(name = "itemId")
private String attrId;
@JSONField(name = "record_name")
private String attrName;
@JSONField(name = "device_name")
private String deviceName;
@JSONField(name = "device_id")
private String deviceId;
@JSONField(name = "station_id")
private String projectId;
@JSONField(name = "station_name")
private String projectName;
@JSONField(name = "record_id")
private String signage;
private String units;
}

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

@ -0,0 +1,35 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/22 10:28
*/
@Data
public class DataVO implements Serializable {
/**数据查询类型:实时、历史**/
private String type;
@JSONField(name = "time_begin")
private String startTime;
@JSONField(name = "time_end")
private String endTime;
/**实时数据结果集**/
private RealDataVO real;
private DataItemVO item;
/**包括:"其它"、"最大值"、"最小值"、"总和值"、"平均值"**/
private String method;
@JSONField(name = "data_type")
private String dataType;
}

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

@ -1,10 +1,15 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @Author: huangxing
@ -14,16 +19,38 @@ import java.io.Serializable;
@ApiModel("响应内容")
public class ExtraVO implements Serializable {
@ApiModelProperty("交互类型")
@ApiModelProperty("交互类型 1:打开页面,2:打开链接,3:参数传递,4:完善选项")
private String type;
@ApiModelProperty("若为弹窗,则返回路由")
@JsonInclude(JsonInclude.Include.NON_NULL)
private String route;
@ApiModelProperty("链接显示文字")
@JsonInclude(JsonInclude.Include.NON_NULL)
private String label;
@ApiModelProperty("函数编号")
private String func;
@ApiModelProperty("是否立即跳转")
private boolean isImmediatelyJump = true;
private boolean isImmediatelyJump = false;
@ApiModelProperty("附带参数")
@JsonInclude(JsonInclude.Include.NON_NULL)
private Map<String,Object> params;
@ApiModelProperty("是否为特殊函数")
private boolean isSpecial;
@ApiModelProperty("选项")
@JsonInclude(JsonInclude.Include.NON_NULL)
private List data;
@JSONField(name = "agent_name")
private String agentName;
@JSONField(name = "agent_data")
private Map<String,Object> agentData;
}

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

@ -0,0 +1,18 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/16 15:10
*/
@Data
@EqualsAndHashCode
public class FaultSelectionVO extends SelectionVO implements Serializable {
private Object item;
}

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

@ -0,0 +1,20 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springblade.core.tool.utils.DateUtil;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/24 10:26
*/
@Data
public class RealDataVO implements Serializable {
private String time;
private String value;
}

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

@ -0,0 +1,13 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/31 09:15
*/
public class RemoteSelectionVO extends SelectionVO implements Serializable {
private Object item;
}

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

@ -0,0 +1,18 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/11 16:21
*/
@Data
@EqualsAndHashCode
public class ScadaSelectionVO extends SelectionVO implements Serializable {
private Object item;
}

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

@ -0,0 +1,23 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/09 16:30
*/
@Data
public class SelectionVO implements Serializable {
/**选项ID**/
@JSONField(name = "item_id")
private String itemId;
/**选项名称**/
@JSONField(name = "item_name")
private String itemName;
}

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

@ -0,0 +1,15 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import com.hnac.hzims.bigmodel.interactive.vo.SelectionVO;
import lombok.Data;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/09 16:32
*/
@Data
public class StationSelectionVO extends SelectionVO implements Serializable {
}

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

@ -0,0 +1,16 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/11 16:20
*/
@Data
@EqualsAndHashCode
public class VideoSelectionVO extends SelectionVO implements Serializable {
}

26
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java

@ -0,0 +1,26 @@
package com.hnac.hzims.operational.fill.feign;
import com.hnac.hzims.operational.OperationalConstants;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @author ysj
*/
@FeignClient(
value = OperationalConstants.APP_NAME,
fallback = IGenerateClientFallback.class
)
public interface IGenerateClient {
String API_PREFIX = "/feign/generate/";
String STATION_GENERATE_BY_TIME = API_PREFIX + "/stationGenerateByTime";
@GetMapping(STATION_GENERATE_BY_TIME)
Double stationGenerateByTime(@RequestParam("stationId") String stationId,
@RequestParam("startTime") String startTime,
@RequestParam("endTime") String endTime);
}

15
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java

@ -0,0 +1,15 @@
package com.hnac.hzims.operational.fill.feign;
import org.springframework.stereotype.Component;
/**
* @author hx
*/
@Component
public class IGenerateClientFallback implements IGenerateClient {
@Override
public Double stationGenerateByTime(String stationId, String startTime, String endTime) {
return 0.0;
}
}

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

@ -30,7 +30,7 @@ public interface IStationClient {
String LIST = API_PREFIX + "/list";
String QUERY_EXIST_LGTD_LTTD = API_PREFIX + "/queryExistLgtdAndLttd";
String GET_ONE = API_PREFIX + "/getOne";
String GET_STATIONS_BY_TYPE_AND_DURATION = API_PREFIX + "/getStationByTypeAndDuration";
String QUERY_STATION_BY_CODES = API_PREFIX + "/querySatationByCodes";
@GetMapping(GET_LIST_ALL)
@ -81,4 +81,7 @@ public interface IStationClient {
*/
@PostMapping(QUERY_STATION_BY_CODES)
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);
}

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

@ -77,4 +77,9 @@ public class IStationClientFallBack implements IStationClient {
public R<List<StationEntity>> querySatationByCodes(List<String> codes) {
return R.data(new ArrayList<>());
}
@Override
public R<List<StationEntity>> getStationByTypeAndDuration(String startTime, String endTime, String type) {
return R.fail("远程调用失败!");
}
}

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

@ -4,6 +4,7 @@ import com.hnac.hzims.operational.OperationalConstants;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@ -16,7 +17,16 @@ import java.util.List;
public interface IStationVideoTypeClient {
String API_PREFIX = "/feign/station/videoType";
String LIST_BY_STATION_ID = API_PREFIX + "/listByStationId";
String LIST = API_PREFIX + "/list";
String GET_BY_ID = API_PREFIX + "/getById";
String GET_RTSP_ADDRESS_BY_ID = API_PREFIX + "/getRtspAddressById";
@PostMapping(LIST_BY_STATION_ID)
List<StationVideoTypeEntity> listByStationId(@RequestParam("stationId") String stationId);
@GetMapping(LIST)
R<List<StationVideoTypeEntity>> list(StationVideoTypeEntity req);
@GetMapping(GET_BY_ID)
R<StationVideoTypeEntity> getById(@RequestParam Long id);
}

11
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClientFallback.java

@ -16,4 +16,15 @@ public class IStationVideoTypeClientFallback implements IStationVideoTypeClient
log.info("调用{}接口失败",LIST_BY_STATION_ID);
return new ArrayList();
}
@Override
public R<List<StationVideoTypeEntity>> list(StationVideoTypeEntity req) {
return R.fail("远程调用失败!");
}
@Override
public R<StationVideoTypeEntity> getById(Long id) {
return R.fail("远程调用失败!");
}
}

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

@ -13,24 +13,12 @@
<dependencies>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-common</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-system-api</artifactId>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>big-model-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
</dependency>
<!-- spring-boot-websocket start -->
<dependency>
<groupId>org.springframework.boot</groupId>
@ -47,6 +35,29 @@
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-system-api</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>
</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>
</dependency>
</dependencies>
<build>

32
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java

@ -1,31 +1,39 @@
package com.hnac.hzims.bigmodel;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springblade.core.cloud.feign.EnableBladeFeign;
import org.springblade.core.jwt.JwtUtil;
import org.springblade.core.launch.BladeApplication;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.data.redis.core.RedisTemplate;
import javax.annotation.Resource;
@SpringBootApplication(scanBasePackages = {"org.springblade", "com.hnac.*"})
@MapperScan(basePackages = {"com.hnac.hzinfo.**.mapper","com.hnac.hzims.**.mapper"})
@EnableFeignClients(basePackages = {"org.springblade", "com.hnac"})
public class HzimsBigModelApplication {
import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMODEL_ASK_KEY;
@EnableBladeFeign(basePackages = {"org.springblade","com.hnac"})
@SpringCloudApplication
@MapperScan("com.hnac.hzims.**.mapper.**")
@Resource
@ComponentScan(basePackages = {"com.hnac.hzims.**"})
@Slf4j
public class HzimsBigModelApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
BladeApplication.run(BigModelConstants.APP_NAME, HzimsBigModelApplication.class, args);
RedisTemplate<String, Object> redisTemplate = JwtUtil.getRedisTemplate();
redisTemplate.delete(HZIMS_BIGMODEL_ASK_KEY);
log.info("服务重启删除问题reids缓存:{}",HZIMS_BIGMODEL_ASK_KEY);
}
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
// return BladeApplication.createSpringApplicationBuilder(builder, BigModelConstants.APP_NAME, HzimsBigModelApplication.class);
// }
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return BladeApplication.createSpringApplicationBuilder(builder, BigModelConstants.APP_NAME, HzimsBigModelApplication.class);
}
}

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;
}

13
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java

@ -15,6 +15,19 @@ public class BigModelInvokeUrl {
private String assistantAsk;
private String assistantSpecialAsk;
private String assistantStatus;
private String askAbort;
private String updateVideo;
private String updateFault;
private String updateCanvas;
private String assistantKnowledgeAsk;
private String hotQuestion;
}

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("/save")
@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);
}
}

27
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataAuthTypeEnum.java

@ -0,0 +1,27 @@
package com.hnac.hzims.bigmodel.interactive.constants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import java.util.Arrays;
import java.util.Optional;
/**
* @Author: huangxing
* @Date: 2024/06/21 10:49
*/
@AllArgsConstructor
@Getter
public enum DataAuthTypeEnum {
/**站点鉴权**/
STATION("station"),
DEPT("dept"),
;
private final String type;
public static DataAuthTypeEnum getEnumByType(String type) {
Optional<DataAuthTypeEnum> typeEnumOptional = Arrays.stream(DataAuthTypeEnum.class.getEnumConstants()).filter(e -> e.getType().equals(type)).findFirst();
return typeEnumOptional.orElse(null);
}
}

36
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataMethodEnum.java

@ -0,0 +1,36 @@
package com.hnac.hzims.bigmodel.interactive.constants;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
* @Author: huangxing
* @Date: 2024/05/29 08:31
*/
@AllArgsConstructor
public enum DataMethodEnum {
USUAL("详情",6,"详情"),
EARLIEST("最早值",0,"最早值"),
MAX("最大值",1,"最大值"),
MIN("最小值",2,"最小值"),
AVERAGE("平均值",3,"平均值"),
SUM("累计值/和值",4,"总和值"),
DIFFERENCE("变化值/差值",5,"变化值"),
LATEST("最新值",6,"最新值"),
;
@Getter
private String name;
@Getter
private Integer accessRule;
@Getter
private String method;
public static DataMethodEnum getEnumByMethod(String method) {
return Arrays.stream(DataMethodEnum.class.getEnumConstants())
.filter(e -> e.getMethod().equals(method))
.findFirst().orElse(null);
}
}

41
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java

@ -0,0 +1,41 @@
package com.hnac.hzims.bigmodel.interactive.constants;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
* @Author: huangxing
* @Date: 2024/05/28 11:37
*/
@AllArgsConstructor
public enum DateEnum {
YEAR("year","每年","按年",5,6),
MONTH("month","每月","按月",4,5),
DAY("day","每天","按天",3,3),
HOUR("hour","每小时","按小时",2,2),
MINUTE("minute","每分钟","按分钟",1,1),
SECOND("second","每秒","按秒",0,0),
USUAL("usual","详情","按秒",0,0)
;
@Getter
private String code;
@Getter
private String name;
@Getter
private String dateType;
@Getter
private int order;
@Getter
private Integer saveTimeType;
public static DateEnum getDateEnumByType(String dateType) {
return Arrays.stream(DateEnum.class.getEnumConstants()).filter(d -> d.getDateType().equals(dateType)).findFirst().orElse(null);
}
public static DateEnum getDateEnumByOrder(int order) {
return Arrays.stream(DateEnum.class.getEnumConstants()).filter(d -> d.getOrder() == order).findFirst().orElse(null);
}
}

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

@ -12,16 +12,30 @@ import java.util.Optional;
*/
@AllArgsConstructor
public enum FuncRouteEnum {
OPEN_SCADA("open_scada","打开实时画面"),
OPEN_CANVAS("open_canvas","打开实时画面",FunctionConstants.TypeEnum.JUMP),
OPEN_VIDEO("open_video","打开视频监控",FunctionConstants.TypeEnum.PARAMS),
DIAGNOSE("result_diagnose","智能诊断",FunctionConstants.TypeEnum.PARAMS),
CHOOSE_STATION("choose_station","选择站点",FunctionConstants.TypeEnum.CHOOSE),
CHOOSE_VIDEO("choose_video","选择视频",FunctionConstants.TypeEnum.CHOOSE),
CHOOSE_CANVAS("choose_canvas","选择画面",FunctionConstants.TypeEnum.CHOOSE),
CHOOSE_FAULT("choose_fault","选择故障",FunctionConstants.TypeEnum.CHOOSE),
CHOOSE_YK("choose_yk","选择遥控",FunctionConstants.TypeEnum.CHOOSE),
CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS),
SHOW_PARAM("result_record","设备参数查询", FunctionConstants.TypeEnum.PARAMS),
CHOOSE_YC("choose_yc","选择遥测数据",FunctionConstants.TypeEnum.CHOOSE),
HISTORY_DATA("history_data","查询历史数据",FunctionConstants.TypeEnum.CHART),
CONTROL_DEVICE("control_device","设备控制",FunctionConstants.TypeEnum.PARAMS)
;
@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();
return FuncRoute.get();
Optional<FuncRouteEnum> FuncRoute = Arrays.stream(FuncRouteEnum.class.getEnumConstants()).filter(e -> funcCode.equals(e.getFunc())).findFirst();
return FuncRoute.orElse(null);
}
}

11
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java → hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java

@ -15,7 +15,16 @@ public interface FunctionConstants {
@AllArgsConstructor
enum TypeEnum {
/**跳转页面**/
JUMP("1")
JUMP("1"),
/**链接**/
LINK("2"),
/**参数**/
PARAMS("3"),
/**选项**/
CHOOSE("4"),
/**确认**/
CONFIRM("5"),
CHART("6");
;
@Getter
private String type;

11
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/InfoMessageConstant.java

@ -0,0 +1,11 @@
package com.hnac.hzims.bigmodel.interactive.constants;
/**
* @Author: huangxing
* @Date: 2024/06/21 16:35
*/
public interface InfoMessageConstant {
String ERROR_MESSAGE = "非常抱歉,系统在处理您的请求时遇到了问题。请稍后再试或联系我们的客服团队。";
}

19
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java

@ -0,0 +1,19 @@
package com.hnac.hzims.bigmodel.interactive.constants;
/**
* @Author: huangxing
* @Date: 2024/07/01 14:26
* @Describe: 参数key管理
*/
public interface ParamKeyConstants {
/**实时画面host**/
String CANVAS_HOST = "hzims:bigModel:canvas:host";
/**实时画面v3路径 {context}&stationNum={stationNum}&projectId={projectId}**/
String CANVAS_V3_PATH = "hzims:bigModel:canvas:v3:path";
/**实时画面v4路径 other/v4/canvas/index.html?hzinfowebkit=true&taskId={taskId}&stationNum={stationNum}&projectId={projectId}&source=app&picName={context}&name={name}**/
String CANVAS_V4_PATH = "hzims:bigModel:canvas:v4:path";
/**实时画面云组态路径 hzinfo-data-scada/view/{projectId}/{id}?source=app**/
String CANVAS_YZT_PATH = "hzims:bigModel:canvas:yzt:path";
}

22
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ProjectRemoteTypeEnum.java

@ -0,0 +1,22 @@
package com.hnac.hzims.bigmodel.interactive.constants;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @Author: huangxing
* @Date: 2024/05/21 16:34
*/
@AllArgsConstructor
public enum ProjectRemoteTypeEnum {
/**不允许发送遥控**/
NOT_ALLOW(0),
/**运行发送遥控并且需要校验权限**/
VALID(1),
/**运行发送遥控并免校验权限**/
ALLOW(2),
;
@Getter
private Integer ctrlType;
}

44
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java

@ -0,0 +1,44 @@
package com.hnac.hzims.bigmodel.interactive.constants;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
* @Author: huangxing
* @Date: 2024/05/24 17:14
*/
@AllArgsConstructor
public enum SearchStationTypeEnum {
STATION_TOTAL("电站总数量",null,"智能运维平台接入电站总数为:%s"),
SET_TOTAL("站点总数量",null,"智能运维平台接入站点总数为:%s"),
HYDROPOWER_TOTAL("水电站总数量","0","智能运维平台接入水电站总数为:%s"),
WIND_POWER_TOTAL("风电场总数量","1","智能运维平台接入风电场总数为:%s"),
ENERGY_STORAGE_TOTAL("储能站总数量","3","智能运维平台接入储能站总数为:%s"),
PHOTOVOLTAIC_TOTAL("光伏站总数量","5","智能运维平台接入光伏站总数为:%s"),
CHARGE_TOTAL("充电站总数量","7","智能运维平台接入充电站总数为:%s"),
STATION_NUM("电站接入量",null,"智能运维平台接入电站总数为:%s"),
SET_NUM("站点接入量",null,"智能运维平台接入站点总数为:%s"),
HYDROPOWER_NUM("水电站接入量","0","智能运维平台接入水电站接入量为:%s"),
WIND_POWER_NUM("风电场接入量","1","智能运维平台接入风电场接入量为:%s"),
ENERGY_STORAGE_NUM("储能站接入量","3","智能运维平台接入储能站接入量为:%s"),
PHOTOVOLTAIC_NUM("光伏站接入量","5","智能运维平台接入光伏站接入量为:%s"),
CHARGE_NUM("充电站接入量","7","智能运维平台接入充电站接入量为:%s"),
;
@Getter
private String searchStationType;
@Getter
private String stationType;
@Getter
private String label;
public static SearchStationTypeEnum getTypeEnum(String searchStationType) {
return Arrays.stream(SearchStationTypeEnum.class.getEnumConstants())
.filter(e -> e.getSearchStationType().equals(searchStationType))
.findFirst()
.orElse(null);
}
}

28
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java

@ -0,0 +1,28 @@
package com.hnac.hzims.bigmodel.interactive.constants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import java.util.Arrays;
/**
* @Author: huangxing
* @Date: 2024/05/24 17:13
*/
@AllArgsConstructor
public enum SearchTypeEnum {
REAL("实时"),
HISTORY("历史")
;
@Getter
private String searchType;
public static SearchTypeEnum getSearchType(String searchType) {
return Arrays.stream(SearchTypeEnum.class.getEnumConstants())
.filter(e -> e.getSearchType().equals(searchType))
.findFirst()
.orElse(null);
}
}

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

@ -0,0 +1,72 @@
package com.hnac.hzims.bigmodel.interactive.controller;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.google.common.collect.Lists;
import com.hnac.hzims.bigmodel.BigModelConstants;
import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService;
import 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.IResultCode;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @Author: huangxing
* @Date: 2024/06/24 14:19
*/
@RestController
@RequestMapping("/fontEnd/interactive")
@Api(value = "前端交互控制层",tags = "前端交互控制层")
@AllArgsConstructor
@Business(module = BigModelConstants.APP_NAME,value = "前端交互层管理",ignore = false)
public class FontEndInteractiveController {
private final IHznlmInvokeService hznlmInvokeService;
@ApiOperation("提问")
@ApiOperationSupport(order = 1)
@GetMapping("/ask")
public R ask(@RequestParam @ApiParam("用户提出问题") String question, @RequestParam @ApiParam("问答sessionId") String sessionId, @RequestParam @ApiParam("用户Id") String userId) {
hznlmInvokeService.ask(question, sessionId, userId);
return R.success("操作成功!");
}
@ApiOperation("删除对话sessionId")
@ApiOperationSupport(order = 2)
@GetMapping("/removeSessionId")
public R<Boolean> removeSessionId(@RequestParam(value = "id") String sessionId) {
hznlmInvokeService.removeSessionId(sessionId);
return R.success("操作成功!");
}
@ApiOperation("获取热点问题")
@ApiOperationSupport(order = 3)
@GetMapping("/hotQuestions")
public R<List> hotQuestions() {
return R.data(hznlmInvokeService.hotQuestions());
}
@ApiOperation("获取问答sessionId")
@ApiOperationSupport(order = 4)
@GetMapping("/getSessionId")
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("操作成功!");
}
}

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

@ -0,0 +1,65 @@
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.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.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/06/21 10:21
*/
@RestController
@AllArgsConstructor
@Api(value = "HZLLM大模型交互层",tags = "HZLLM大模型交互层")
@RequestMapping("/hzn_lm/interactive")
@Business(module = BigModelConstants.MODULE_NAME,value = "HZLLM大模型交互层")
public class HznlmInteractiveController {
private final IHznlmInteractiveService interactiveService;
private final DataSourceService dataSourceService;
@PostMapping(value = "/get_auth_data")
@ApiOperation("获取鉴权数据")
@ApiOperationSupport(order = 1)
public R<List<AuthDataVO>> getAuthData(@RequestBody AuthDataDTO req) {
return R.data(interactiveService.getAuthData(req));
}
@ApiOperation("解析大模型函数")
@ApiOperationSupport(order = 2)
@PostMapping("/resolve")
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));
}
}

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

@ -1,62 +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.hnac.hzims.bigmodel.BigModelConstants;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService;
import com.hnac.hzinfo.log.annotation.Business;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
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.*;
import javax.servlet.http.HttpServletRequest;
/**
* @Author: huangxing
* @Date: 2024/04/26 14:51
*/
@RestController
@AllArgsConstructor
@Api(value = "FDP大模型交互层",tags = "FDP大模型交互层")
@RequestMapping("/interactive")
@Business(module = BigModelConstants.MODULE_NAME,value = "FDP大模型交互层")
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")
public R ask(@RequestParam @ApiParam("用户提出问题") String question,@RequestParam @ApiParam("问答sessionId") String sessionId) {
return interactiveService.ask(question, sessionId);
}
@ApiOperation("站点、菜单鉴权")
@ApiOperationSupport(order = 3)
@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 menuId) {
return R.status(interactiveService.authentication(stationId,userId,menuId));
}
@ApiOperation("获取问答sessionId")
@ApiOperationSupport(order = 4)
@GetMapping("/getSessionId")
public R<String> getSessionId() {
return R.data(IdWorker.get32UUID());
}
}

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

@ -0,0 +1,35 @@
package com.hnac.hzims.bigmodel.interactive.dto;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/06/21 10:39
*/
@Data
@ApiModel(value = "获取权限接口传参格式",description = "获取权限接口传参格式")
@EqualsAndHashCode
public class AuthDataDTO implements Serializable {
@JsonProperty("chatId")
@ApiModelProperty("问答ID,用于获取前端发起问答传入缓存中数据")
@NotBlank
private String sessionId;
@ApiModelProperty("提问用户ID")
@NotBlank
private String userId;
@ApiModelProperty("鉴权类型")
@NotBlank
private String type;
}

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

@ -0,0 +1,55 @@
package com.hnac.hzims.bigmodel.interactive.factory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService;
import com.hnac.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.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;
/**
* @Author: huangxing
* @Date: 2024/06/21 18:44
*/
public class AnswerResolveFactory {
public static final String DIAGNOSE_ANSWER_SERVICE = "diagnoseAnswerResolveService";
public static final String CHOICE_ANSWER_SERVICE = "choiceAnswerResolveService";
public static final String REMOTE_ANSWER_SERVICE = "remoteAnswerResolveService";
public static final String PARAM_ANSWER_SERVICE = "paramAnswerResolveService";
public static final String PRE_ANSWER_SERVICE = "preAnswerResolveService";
public static IAnswerResolveService getResolveService(Object extra) {
String funcCode = JSONObject.parseObject(JSON.toJSONString(extra)).getString("func");
return AnswerResolveFactory.getResolveService(funcCode);
}
public static IAnswerResolveService getResolveService(String funcCode) {
FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(funcCode);
if(Func.isNotEmpty(funcRouteEnum)) {
switch (funcRouteEnum) {
case DIAGNOSE:
return SpringUtil.getBean(DIAGNOSE_ANSWER_SERVICE);
case CHOOSE_VIDEO:
case CHOOSE_CANVAS:
case CHOOSE_STATION:
case CHOOSE_FAULT:
case CHOOSE_YC:
case CHOOSE_YK:
return SpringUtil.getBean(CHOICE_ANSWER_SERVICE);
case CONFIRM_YK:
return SpringUtil.getBean(REMOTE_ANSWER_SERVICE);
case SHOW_PARAM:
return SpringUtil.getBean(PARAM_ANSWER_SERVICE);
default:
return null;
}
}
throw new ServiceException("service解析失败!");
}
}

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

@ -0,0 +1,41 @@
package com.hnac.hzims.bigmodel.interactive.factory;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
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.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;
/**
* @Author: huangxing
* @Date: 2024/06/21 15:53
*/
public class ResolveFactory {
public static final String CANVAS_RESOLVE_SERVICE = "canvasResolveService";
public static final String VIDEO_RESOLVE_SERVICE = "videoResolveService";
/**
* 获取解析函数需要的service
* @param funcCode 函数编号
* @return 解析函数所需service
*/
public static IResolveService getResolveService(String funcCode) {
BladeLogger logger = SpringUtil.getBean(BladeLogger.class);
FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(funcCode);
if(Func.isNotEmpty(funcRouteEnum)) {
switch(funcRouteEnum) {
case OPEN_CANVAS:
return SpringUtil.getBean("canvasResolveService");
case OPEN_VIDEO:
return SpringUtil.getBean("videoResolveService");
default:
logger.error("hzims:bigModel:getResolveService","函数解析失败,函数编号为:" + funcCode);
throw new ServiceException("service解析失败");
}
}
throw new ServiceException("service解析失败");
}
}

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

@ -0,0 +1,16 @@
package com.hnac.hzims.bigmodel.interactive.service;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO;
/**
* @Author: huangxing
* @Date: 2024/05/28 11:29
*/
public interface IAnalyseDataService {
ExtraVO getHistoryData(HistoryDataSearchVO searchVO);
}

34
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnswerResolveService.java

@ -0,0 +1,34 @@
package com.hnac.hzims.bigmodel.interactive.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import java.util.Arrays;
import java.util.stream.Stream;
/**
* @Author: huangxing
* @Date: 2024/06/21 18:39
*/
public interface IAnswerResolveService {
AnswerVO resolve(AnswerVO answer);
/**
* 解析 extra
* @param originExtra 大模型传入 extra
* @return 解析后的 extra
*/
ExtraVO getExtra(JSONObject originExtra);
/***
*
* @param answer
* @return
*/
default Stream<JSONObject> extraStream(AnswerVO answer) {
return Arrays.stream(answer.getExtras()).map(JSON::toJSONString).map(JSONObject::parseObject);
}
}

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

@ -0,0 +1,26 @@
package com.hnac.hzims.bigmodel.interactive.service;
import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO;
import com.hnac.hzims.bigmodel.interactive.dto.ControlDTO;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO;
import org.springframework.web.bind.annotation.RequestBody;
import javax.validation.Valid;
import java.util.List;
/**
* @Author: huangxing
* @Date: 2024/06/21 10:23
*/
public interface IHznlmInteractiveService {
List<AuthDataVO> getAuthData(AuthDataDTO req);
ExtraVO resolve(ModelFunctionReq req);
ExtraVO controlDevice(ControlDTO req);
}

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

@ -0,0 +1,77 @@
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;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/06/21 17:20
*/
public interface IHznlmInvokeService {
/**
* 基础问题
* @param question 提问问题
* @param sessionId 会话ID
* @param userId 提问人ID
* @return 提问结果
*/
@Deprecated
void ask(String question, String sessionId, String userId);
void ask(QuestionDTO question);
/**
* 特殊问题
* @param sessionId 会话ID
* @param userId 提问人ID
* @param extra 特殊问题内容
* @return 提问结果
*/
@Deprecated
void specialAsk(String sessionId, String userId, Map<String,Object> extra);
void specialAsk(QuestionDTO questionDTO);
/**
* 知识库问题
* @param question 问题名称
* @param sessionId 会话ID
* @param userId 提问人ID
* @param knowledge 知识库名称
*/
@Deprecated
void knowledgeAsk(String question, String sessionId, String userId, String knowledge);
void knowledgeAsk(QuestionDTO questionDTO);
/**
* 删除对话记录
* @param sessionId 会话ID
*/
void removeSessionId(String sessionId);
/**
* 获取热点问题
* @return 热点问题
*/
List hotQuestions();
/**
* 查询问答状态
* @param sessionIds 会话ID按逗号分隔
* @return 答案列表
*/
List<AnswerVO> getAnswerBySessionIds(String sessionIds);
/**
* 中断当前的问答
* @param sessionId 会话ID
*/
void askAbort(String sessionId);
}

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

@ -1,26 +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 io.swagger.annotations.ApiParam;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @Author: huangxing
* @Date: 2024/04/26 14:51
*/
public interface IInteractiveService {
R resolve(ModelFunctionReq req);
R ask(String question,String sessionId);
List<AnswerVO> getAnswerBySessionIds(String sessionIds);
Boolean authentication(String stationId, String userId, String menuId);
}

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

@ -1,16 +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
*/
public interface IJumpPageService {
String dealJumpTypeFunction(FunctionEntity function, Map<String,String> args);
}

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

@ -0,0 +1,17 @@
package com.hnac.hzims.bigmodel.interactive.service;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO;
/**
* @Author: huangxing
* @Date: 2024/06/21 15:39
*/
public interface IResolveService {
ExtraVO resolve(String id);
ExtraVO resolve(ModelFunctionReq req);
}

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

@ -0,0 +1,89 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.google.common.collect.Lists;
import com.hnac.hzims.bigmodel.business.service.HistoryDataService;
import com.hnac.hzims.bigmodel.interactive.constants.DataMethodEnum;
import com.hnac.hzims.bigmodel.interactive.constants.DateEnum;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO;
import com.hnac.hzinfo.sdk.core.response.Result;
import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Author: huangxing
* @Date: 2024/05/28 11:29
*/
@Service
@AllArgsConstructor
public class AnalyseDataServiceImpl implements IAnalyseDataService {
private final HistoryDataService historyDataService;
@Override
public ExtraVO getHistoryData(HistoryDataSearchVO searchVO) {
if(Func.isEmpty(searchVO.getDataType()) || StringUtil.isBlank(searchVO.getDataType())
|| DataMethodEnum.USUAL.getMethod().equals(searchVO.getMethod())) {
searchVO.setDataType(DateEnum.SECOND.getDateType());
}
// 聚合数据方式处理
DateEnum dateEnum = DateEnum.getDateEnumByType(searchVO.getDataType());
searchVO.setDataType(dateEnum.getDateType());
// 获取最适配时间段
DateEnum adapterDate = historyDataService.getDateEnumByDuration(searchVO.getStartTime(), searchVO.getEndTime(), dateEnum);
String note = adapterDate.getDateType().equals(searchVO.getDataType()) ? "" : "(由于数据量过大,只能帮您" + adapterDate.getDateType() + "查询)";
searchVO.setDataType(adapterDate.getDateType());
ExtraVO extraVO = new ExtraVO();
extraVO.setType(FuncRouteEnum.HISTORY_DATA.getType().getType());
extraVO.setFunc(FuncRouteEnum.HISTORY_DATA.getFunc());
Map<String,Object> params = new HashMap<>(1);
Result<ReductionDataVO> reductionDataVOR = historyDataService.getPolymerizationData(searchVO);
String label;
if(!reductionDataVOR.isSuccess()) {
params.put("errorInfo",reductionDataVOR.getMsg());
label = "查询数据失败!";
}
else {
ReductionDataVO dataVO = reductionDataVOR.getData();
label = "暂未查到数据";
params.put("data",Lists.newArrayList());
if(Func.isNotEmpty(dataVO) && CollectionUtil.isNotEmpty(dataVO.getDataList())) {
List<Map> datalist = dataVO.getDataList().stream().map(m -> {
m.put("val", m.get(searchVO.getSignage()));
m.remove(searchVO.getSignage());
return m;
}).collect(Collectors.toList());
DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod());
if(CollectionUtil.isNotEmpty(datalist)) {
label = searchVO.getStationName() + "_"
+ searchVO.getDeviceName() + "_"
+ dataVO.getFieldMap().get(searchVO.getSignage()) + "_"
+ (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : adapterDate.getName())
+ enumByMethod.getMethod()
+ (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : note)
+ ":";
}
params.put("data",datalist);
}
}
extraVO.setLabel(label);
params.put("deviceName",searchVO.getDeviceName());
params.put("attrName",searchVO.getAttrName());
params.put("stationName",searchVO.getStationName());
params.put("beginTime",searchVO.getStartTime());
params.put("endTime",searchVO.getEndTime());
extraVO.setParams(params);
return extraVO;
}
}

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

@ -0,0 +1,129 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.alibaba.fastjson.JSON;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.constants.ParamKeyConstants;
import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IResolveService;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import 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.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.cache.ParamCache;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.*;
import java.util.stream.IntStream;
/**
* @Author: huangxing
* @Date: 2024/06/21 15:39
*/
@Service(ResolveFactory.CANVAS_RESOLVE_SERVICE)
@AllArgsConstructor
@Slf4j
public class CanvasResolveServiceImpl implements IResolveService {
private final IStationClient stationClient;
private final BladeLogger logger;
@Override
public ExtraVO resolve(ModelFunctionReq req) {
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");
});
return this.resolve(id);
}
@Override
public ExtraVO resolve(String id) {
ExtraVO extraVO = new ExtraVO();
extraVO.setImmediatelyJump(true);
extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFunc());
final String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"};
String canvasHost = ParamCache.getValue(ParamKeyConstants.CANVAS_HOST);
// 将ID解析为
Map<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"));
int picResource = Integer.parseInt(resolveMap.get("picResource"));
Map<String,Object> extraParams = new HashMap<>(1);
extraParams.put("picResource",picResource);
extraVO.setParams(extraParams);
// 云组态
if(picResource == 0) {
String path = this.replacePath(ParamCache.getValue(ParamKeyConstants.CANVAS_YZT_PATH), resolveMap);
extraVO.setRoute(canvasHost + path);
}
// v3.0
else if(picResource == 1) {
String path = this.replacePath(ParamCache.getValue(ParamKeyConstants.CANVAS_V3_PATH), resolveMap);
extraVO.setRoute(canvasHost + path);
}
// v4.0
else if (picResource == 2) {
// pic_name 去掉头部的/ 以及尾部的.js
String context = resolveMap.get("context");
context = this.removeHeadChars(context,"/");
context = this.removeTailChars(context,".js");
resolveMap.put("context",context);
extraVO.setRoute(this.replacePath("other/v4/canvas/index.html?hzinfowebkit=true&taskId={taskId}&stationNum={stationNum}&projectId={projectId}&source=app&picName={context}&itemName={itemName}", resolveMap));
}
else {
throw new ServiceException("解析出来的画面类型在云组态、v3、v4类型之外,无法解析路由");
}
return extraVO;
}
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;
}
}

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

@ -0,0 +1,43 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory;
import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author: huangxing
* @Date: 2024/06/21 19:02
* @Describe 选项答案解析服务层
*/
@AllArgsConstructor
@Service(AnswerResolveFactory.CHOICE_ANSWER_SERVICE)
@Slf4j
public class ChoiceAnswerResolveServiceImpl implements IAnswerResolveService {
@Override
public AnswerVO resolve(AnswerVO answer) {
Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray();
answer.setExtras(extraArray);
return answer;
}
@Override
public ExtraVO getExtra(JSONObject originExtra) {
ExtraVO result = JSONObject.parseObject(JSON.toJSONString(originExtra),ExtraVO.class);
result.setSpecial(true);
result.setType(FuncRouteEnum.getEnumByFuncCode(result.getFunc()).getType().getType());
return result;
}
}

50
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java

@ -0,0 +1,50 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants;
import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory;
import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/06/21 18:59
*/
@Service(AnswerResolveFactory.DIAGNOSE_ANSWER_SERVICE)
@Slf4j
@AllArgsConstructor
public class DiagnoseAnswerResolveServiceImpl implements IAnswerResolveService {
@Override
public AnswerVO resolve(AnswerVO answer) {
Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray();
answer.setExtras(extraArray);
return answer;
}
@Override
public ExtraVO getExtra(JSONObject originExtra) {
ExtraVO result = new ExtraVO();
JSONObject data = JSONObject.parseObject(JSON.toJSONString(originExtra.get("data")));
Map<String,Object> params = new HashMap<>(5);
params.put("faultId",data.getString("fault_id"));
params.put("name",data.getString("fault_name"));
params.put("station",data.getString("station_id"));
params.put("fdpDeviceName",data.getString("device_name"));
params.put("fdpOrd",data.getString("ord"));
result.setParams(params);
String funcCode = originExtra.getString("func");
result.setFunc(funcCode);
result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType());
return result;
}
}

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

@ -0,0 +1,100 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.hnac.hzims.bigmodel.business.dto.ControlDeviceAuthDTO;
import com.hnac.hzims.bigmodel.business.feign.IAuthClient;
import com.hnac.hzims.bigmodel.business.service.AuthenticationService;
import com.hnac.hzims.bigmodel.interactive.constants.DataAuthTypeEnum;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO;
import com.hnac.hzims.bigmodel.interactive.dto.ControlDTO;
import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService;
import com.hnac.hzims.bigmodel.interactive.service.IResolveService;
import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.dto.DeptStationDTO;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @Author: huangxing
* @Date: 2024/06/21 10:24
*/
@Service
@AllArgsConstructor
@Slf4j
public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService {
private final AuthenticationService authenticationService;
private final IAuthClient authClient;
@Override
public List<AuthDataVO> getAuthData(AuthDataDTO req) {
DataAuthTypeEnum authTypeEnum = DataAuthTypeEnum.getEnumByType(req.getType());
switch(authTypeEnum) {
case STATION:
return this.getStationAuthData(req.getUserId());
case DEPT:
return this.getDeptAuthData(req.getUserId());
default:
throw new ServiceException(req.getType() + "改类型获取权限数据暂不支持");
}
}
@Override
public ExtraVO resolve(ModelFunctionReq req) {
IResolveService resolveService = ResolveFactory.getResolveService(req.getFunc());
return resolveService.resolve(req);
}
@Override
public ExtraVO controlDevice(ControlDTO req) {
ExtraVO result = new ExtraVO();
Optional<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());
}
public List<AuthDataVO> getStationAuthData(String userId) {
List<DeptStationDTO> deptStationDTOs = authenticationService.getStationPermissionsById(userId);
return deptStationDTOs.stream().map(this::convertStationAuthData).filter(d -> Func.isNotBlank(d.getItemId())).collect(Collectors.toList());
}
private AuthDataVO convertStationAuthData(DeptStationDTO req) {
return new AuthDataVO(req.getStationId(),req.getDeptName());
}
private AuthDataVO convertDeptAuthData(DeptStationDTO req) {
return new AuthDataVO(String.valueOf(req.getDeptId()),req.getDeptName());
}
}

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

@ -0,0 +1,143 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.alibaba.fastjson.JSON;
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 lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.logger.BladeLogger;
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.StringUtil;
import org.springblade.system.dto.DeptStationDTO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/06/21 17:20
* @Describe HZN_LM大模型接口调用服务层
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
private final BigModelInvokeUrl bigModelInvokeUrl;
private final BladeLogger logger;
private final SessionRedisManager sessionRedisManager;
private final IAuthClient authClient;
@Value("${fdp.host}")
private String fdpHost;
@Override
public void ask(String question, String sessionId, String userId) {
Map<String,Object> params = new HashMap<>();
params.put("chat_id",sessionId);
params.put("user_id", userId);
params.put("query",question);
Map<String, String[]> authDataIds = this.getAuthDataIds(userId);
params.putAll(authDataIds);
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantAsk(), params);
sessionRedisManager.addSessionId(sessionId);
}
@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("chat_id",sessionId);
params.put("user_id", userId);
params.put("extra",extra);
Map<String, String[]> authDataIds = this.getAuthDataIds(userId);
params.putAll(authDataIds);
log.info("调用大模型接口:{},传参为:{}",fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk(),JSON.toJSONString(params));
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk(), params);
sessionRedisManager.addSessionId(sessionId);
}
@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("chat_id", sessionId);
params.put("user_id", userId);
params.put("query", question);
params.put("knowledge", knowledge);
Map<String, String[]> authDataIds = this.getAuthDataIds(userId);
params.putAll(authDataIds);
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantKnowledgeAsk(), params);
sessionRedisManager.addSessionId(sessionId);
}
@Override
public void knowledgeAsk(QuestionDTO question) {
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantKnowledgeAsk(), JSON.toJSONString(question));
sessionRedisManager.addSessionId(question.getChatId());
}
@Override
public void removeSessionId(String sessionId) {
this.askAbort(sessionId);
// 移除内存sessionId
InteractiveSessionManager.SESSION_POOL.remove(sessionId);
sessionRedisManager.removeSessionId(sessionId);
}
@Override
public void askAbort(String sessionId) {
Map<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>>(){});
}
catch (Exception e) {
log.error("An error occurred",e);
return Lists.newArrayList();
}
}
@Override
public List<AnswerVO> getAnswerBySessionIds(String sessionIds) {
Map<String,Object> params = new HashMap<>();
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) {
Map<String, String[]> result = new HashMap<>(2);
R<Map<String, String[]>> authDataR = authClient.getAuthData(userId);
result.putAll(authDataR.getData());
return result;
}
}

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

@ -1,105 +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.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl;
import com.hnac.hzims.bigmodel.entity.FunctionEntity;
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.function.service.IFunctionService;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.*;
/**
* @Author: huangxing
* @Date: 2024/04/26 14:51
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class InteractiveServiceImpl implements IInteractiveService {
private final IJumpPageService jumpPageService;
private final IFunctionService functionService;
private final BigModelInvokeUrl bigModelInvokeUrl;
@Value("${fdp.host}")
private String fdpHost;
@Override
public R resolve(ModelFunctionReq req) {
//TODO 数据鉴权
FunctionEntity function = functionService.getFunctionByCode(req.getFunctionName());
TypeEnum typeEnum = TypeEnum.getTypeEnumByType(function.getType());
switch (typeEnum) {
// 页面跳转
case JUMP:
String extra = jumpPageService.dealJumpTypeFunction(function, req.getFunctionArgs());
Assert.isTrue(StringUtil.isNotBlank(extra) && Func.isNotEmpty(extra), () -> {
throw new ServiceException("解析" + function.getName() + "函数失败!");
});
return R.data(extra);
default:
throw new ServiceException("函数解析失败!");
}
}
@Override
public R ask(String question,String sessionId) {
Long userId = AuthUtil.getUserId();
//TODO 保存问题
Map<String,String> params = new HashMap<>();
params.put("id",sessionId);
params.put("userid",userId.toString());
params.put("query",question);
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantAsk())
.body(JSON.toJSONString(params)).execute();
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK && "1".equals(JSONObject.parseObject(response.body()).getString("success")), () -> {
throw new ServiceException("远程调用大模型【发起问答】接口失败!");
});
return R.data(JSONObject.parseObject(response.body()).getString("data"));
}
@Override
public List<AnswerVO> getAnswerBySessionIds(String sessionIds) {
Map<String,String> params = new HashMap<>();
params.put("ids",sessionIds);
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantStatus())
.body(JSON.toJSONString(params)).execute();
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK && "1".equals(JSONObject.parseObject(response.body()).getString("success")), () -> {
throw new ServiceException("远程调用大模型【发起问答】接口失败!");
});
String data = JSONObject.parseObject(response.body()).getString("data");
return JSONArray.parseArray(data,AnswerVO.class);
}
@Override
public Boolean authentication(String stationId, String userId, String menuId) {
//TODO 鉴权逻辑完善
return true;
}
}

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

@ -1,45 +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
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);
}
}

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

@ -1,134 +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 org.springblade.core.log.exception.ServiceException;
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.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @Author: huangxing
* @Date: 2024/04/30 11:38
*/
@Component
public class JumpRouteJoinStrategy {
/**
* 解析大模型传参
* @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_SCADA:
return this.getScadaExtra(args,function);
default:
break;
}
}
return null;
}
private ExtraVO getScadaExtra(Map<String,String> args,FunctionEntity function) {
// 跳转页面逻辑
ExtraVO extraVO = new ExtraVO();
Map<String, String> params = this.scadaResolve(args);
// 根据hz3000画面版本获取path
Integer picResource = Integer.valueOf(params.get("picResource"));
JSONObject pathObject = JSONObject.parseObject(function.getPath());
// 云组态
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 实时画面路径拼接所需参数
*/
private Map<String,String> scadaResolve(Map<String,String> args) {
Map<String,String> result = new HashMap<>();
Assert.isTrue(args.containsKey("params"), () -> {
throw new ServiceException("大模型传参缺少params参数");
});
// 参数格式为:picResource^context^stationNum^projectId^taskId^name^id
List<String> params = Func.toStrList("\\^", args.get("params"));
Assert.isTrue(params.size() == 7,() -> {
throw new ServiceException("大模型传参params长度错误,传参为:" + args.get("params"));
});
result.put("picResource",params.get(0));
result.put("context",params.get(1));
result.put("stationNum",params.get(2));
result.put("projectId",params.get(3));
result.put("taskId",params.get(4));
result.put("name",params.get(5));
result.put("id",params.get(6));
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;
}
}

106
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java

@ -0,0 +1,106 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.constants.SearchTypeEnum;
import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory;
import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService;
import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService;
import com.hnac.hzims.bigmodel.interactive.vo.*;
import com.xxl.job.core.log.XxlJobLogger;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/06/21 19:02
*/
@Service(AnswerResolveFactory.PARAM_ANSWER_SERVICE)
@Slf4j
@AllArgsConstructor
public class ParamAnswerResolveServiceImpl implements IAnswerResolveService {
private final IAnalyseDataService analyseDataService;
public static final String PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss.SSS";
@Override
public AnswerVO resolve(AnswerVO answer) {
Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray();
answer.setExtras(extraArray);
return answer;
}
@Override
public ExtraVO getExtra(JSONObject originExtra) {
DataVO data = JSONObject.parseObject(JSON.toJSONString(originExtra.get("data")),DataVO.class);
Assert.isTrue(Func.isNotEmpty(data),() -> {
XxlJobLogger.log("解析参数答案失败,extra不能为空!");
throw new ServiceException("解析参数答案失败,extra不能为空!");
});
if(Func.isNotEmpty(data.getReal())) {
// 处理查询实时数据
RealDataVO real = data.getReal();
Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME);
real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME));
}
else if(StringUtil.isNotBlank(data.getType()) && SearchTypeEnum.HISTORY.getSearchType().equals(data.getType())) {
// 处理查询历史数据
return this.getHistoryData(data);
}
String funcCode = originExtra.getString("func");
ExtraVO result = new ExtraVO();
result.setFunc(funcCode);
result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType());
Map<String,Object> param = new HashMap(1);
param.put("data", data);
result.setParams(param);
return result;
}
/**
* 查询历史数据
* @param data 大模型识别数据信息
* @return 历史数据
*/
private ExtraVO getHistoryData(DataVO data) {
// 确认查询聚合方式传入
Assert.isTrue(Func.isNotEmpty(data.getItem()) && StringUtil.isNotBlank(data.getMethod()),() -> {
XxlJobLogger.log("历史数据查询方式为空,查询失败!");
throw new ServiceException("历史数据查询方式为空,查询失败!");
});
return analyseDataService.getHistoryData(this.convertHistoryDataSearch(data));
}
/**
* 获取历史数据查询对象
* @param data 大模型解析点位信息
* @return 历史数据查询对象
*/
private HistoryDataSearchVO convertHistoryDataSearch(DataVO data) {
HistoryDataSearchVO searchVO = new HistoryDataSearchVO();
DataItemVO item = data.getItem();
searchVO.setDataType(data.getDataType());
searchVO.setAttrName(item.getAttrName());
searchVO.setDeviceCode(item.getDeviceId());
searchVO.setDeviceName(item.getDeviceName());
searchVO.setStationName(item.getProjectName());
searchVO.setMethod(data.getMethod());
searchVO.setSignage(item.getSignage());
searchVO.setStartTime(data.getStartTime());
searchVO.setEndTime(data.getEndTime());
return searchVO;
}
}

59
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java

@ -0,0 +1,59 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory;
import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.bigmodel.interactive.vo.RemoteParamVO;
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/06/21 19:02
*/
@Service(AnswerResolveFactory.REMOTE_ANSWER_SERVICE)
@Slf4j
@AllArgsConstructor
public class RemoteAnswerResolveServiceImpl implements IAnswerResolveService {
private final DeviceClient deviceClient;
@Override
public AnswerVO resolve(AnswerVO answer) {
Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray();
answer.setExtras(extraArray);
return answer;
}
@Override
public ExtraVO getExtra(JSONObject originExtra) {
ExtraVO result = new ExtraVO();
RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(originExtra.get("data")), RemoteParamVO.class);
String funcCode = originExtra.getString("func");
result.setFunc(funcCode);
result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType());
R<DeviceInstanceFuncVO> funcVOR = deviceClient.getFuncById(remoteParam.getFuncId());
if(funcVOR.isSuccess()) {
Map<String,Object> param = new HashMap();
param.put("control",funcVOR.getData());
param.put("deviceName",remoteParam.getDeviceName());
param.put("projectName",remoteParam.getProjectName());
param.put("deviceCode",remoteParam.getDeviceId());
param.put("value",remoteParam.getValue());
result.setParams(param);
}
return result;
}
}

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

@ -0,0 +1,73 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.alibaba.fastjson.JSON;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants;
import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IResolveService;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient;
import 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.tool.api.R;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.HashMap;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/06/21 16:17
*/
@Service(ResolveFactory.VIDEO_RESOLVE_SERVICE)
@AllArgsConstructor
@Slf4j
public class VideoResolveServiceImpl implements IResolveService {
private final IStationVideoTypeClient videoClient;
private final BladeLogger logger;
@Override
public ExtraVO resolve(ModelFunctionReq req) {
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");
});
return this.resolve(id);
// ExtraVO extra = this.resolve(id);
// String message = "已成功打开" + name + ";";
// return new ResolveResultVO(message,extra);
}
@Override
public ExtraVO resolve(String idStr) {
Long id = Long.valueOf(idStr);
// 跳转页面逻辑
ExtraVO extraVO = new ExtraVO();
R<StationVideoTypeEntity> videoR = videoClient.getById(Long.valueOf(id));
if(videoR.isSuccess()) {
StationVideoTypeEntity video = videoR.getData();
extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType());
extraVO.setImmediatelyJump(true);
extraVO.setFunc(FuncRouteEnum.OPEN_VIDEO.getFunc());
Map<String,Object> params = new HashMap<>();
params.put("name", video.getName());
params.put("videoHost", video.getVideoHost());
params.put("pointCode", video.getPointCode());
params.put("appKey", video.getAppKey());
params.put("appSecret", video.getAppSecret());
params.put("liveSourceAddress",video.getLiveSourceAddress());
extraVO.setParams(params);
}
return extraVO;
}
}

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

@ -1,10 +1,14 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import com.alibaba.fastjson.annotation.JSONField;
import com.hnac.hzims.bigmodel.interactive.constants.InfoMessageConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springblade.core.tool.utils.BeanUtil;
import java.io.Serializable;
@ -15,14 +19,16 @@ import java.io.Serializable;
@Data
@ApiModel("HZLLM答案VO对象")
@EqualsAndHashCode
@AllArgsConstructor
@NoArgsConstructor
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代表已完成")
@ -44,4 +50,23 @@ public class AnswerVO implements Serializable {
@ApiModelProperty("query对应的答案")
private String answer;
@ApiModelProperty("其它调用的参数")
private Object[] extras;
@ApiModelProperty("用于语音回复的状态文本")
@JSONField(name = "voice_text")
private String[] voiceText;
@ApiModelProperty("用于语音回复的答案")
@JSONField(name = "voice_answer")
private String[] voiceAnswer;
public static AnswerVO error(String sessionId,String userId,String query) {
return new AnswerVO(sessionId,userId,0,-2,null,query, InfoMessageConstant.ERROR_MESSAGE, null,null,new String[]{InfoMessageConstant.ERROR_MESSAGE});
}
public static void error(AnswerVO usualVO) {
usualVO.setRunning(0);
usualVO.setStatus(-2);
}
}

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

@ -0,0 +1,27 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/06/21 10:26
*/
@Data
@AllArgsConstructor
@ApiModel(value = "鉴权数据VO",description = "鉴权数据VO,包含站点、机构、遥控权限")
@EqualsAndHashCode
public class AuthDataVO implements Serializable {
@ApiModelProperty("数据ID")
private String itemId;
@ApiModelProperty("数据名称")
private String itemName;
}

37
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/HistoryDataSearchVO.java

@ -0,0 +1,37 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @Author: huangxing
* @Date: 2024/05/28 11:48
*/
@Data
public class HistoryDataSearchVO {
@NotBlank
private String startTime;
@NotBlank
private String endTime;
@NotBlank
private String deviceCode;
@NotBlank
private String signage;
private String attrName;
@NotBlank
private String method;
private String dataType;
private String stationName;
private String deviceName;
}

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

@ -0,0 +1,39 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/20 14:46
*/
@Data
@EqualsAndHashCode
public class RemoteParamVO implements Serializable {
@JSONField(name = "itemId")
private String funcId;
@JSONField(name = "yk_name")
private String remoteName;
@JSONField(name = "device_id")
private String deviceId;
@JSONField(name = "device_name")
private String deviceName;
@JSONField(name = "station_id")
private String projectId;
@JSONField(name = "station_name")
private String projectName;
private String signage;
private String value;
}

29
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ResolveResultVO.java

@ -0,0 +1,29 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import com.hnac.hzims.bigmodel.interactive.constants.InfoMessageConstant;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/06/21 16:31
*/
@EqualsAndHashCode
@Data
@AllArgsConstructor
@ApiModel(value = "解析结果",description = "解析结果")
public class ResolveResultVO implements Serializable {
private String content;
private ExtraVO extraVO;
public static ResolveResultVO error() {
return new ResolveResultVO(InfoMessageConstant.ERROR_MESSAGE,null);
}
}

19
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SessionContentVO.java

@ -0,0 +1,19 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/20 19:31
*/
@Data
@EqualsAndHashCode
public class SessionContentVO implements Serializable {
/**机器码**/
private String machineCode;
}

24
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java

@ -0,0 +1,24 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/25 14:03
*/
@Data
public class StationSearchVO implements Serializable {
private String startTime;
private String endTime;
@NotBlank(message = "查询类型不能为空")
private String type;
private String enumType;
}

20
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateStationVO.java

@ -0,0 +1,20 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import lombok.Data;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/09 09:50
*/
@Data
public class UpdateStationVO implements Serializable {
/**站点ID**/
private String id;
/**站点名称**/
private String name;
}

25
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateUsualVO.java

@ -0,0 +1,25 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/09 09:53
*/
@Data
public class UpdateUsualVO implements Serializable {
/**站点ID**/
@JSONField(name = "station_id")
private String stationId;
/**业务ID**/
private String id;
/**业务名称**/
private String name;
}

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)));
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save