Browse Source

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

# Conflicts:
#	hzims-service/hzims-alarm/pom.xml
#	hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java
#	hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java
#	hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java
#	hzims-service/hzims-big-model/pom.xml
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java
#	hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java
#	hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationVideoTypeClient.java
#	pom.xml
zhongwei
yang_shj 4 months ago
parent
commit
92d823b230
  1. 8
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java
  2. 32
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/AlarmVideoVo.java
  3. 28
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java
  4. 21
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java
  5. 24
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/entity/WhitelistEntity.java
  6. 14
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java
  7. 40
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java
  8. 35
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java
  9. 25
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java
  10. 18
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java
  11. 20
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java
  12. 13
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteSelectionVO.java
  13. 18
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ScadaSelectionVO.java
  14. 20
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java
  15. 15
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSelectionVO.java
  16. 16
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/VideoSelectionVO.java
  17. 43
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/ThirtyGenerationEntity.java
  18. 43
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/ThreeGenerationEntity.java
  19. 26
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java
  20. 15
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java
  21. 14
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/ScheduledConstant.java
  22. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java
  23. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java
  24. 10
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClient.java
  25. 11
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClientFallback.java
  26. 4
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java
  27. 4
      hzims-service/hzims-alarm/pom.xml
  28. 30
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java
  29. 20
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java
  30. 109
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java
  31. 9
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/DroolsAlarmServiceImpl.java
  32. 6
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java
  33. 13
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/LevelAlarmServiceImpl.java
  34. 13
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java
  35. 27
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java
  36. 10
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java
  37. 6
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java
  38. 9
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java
  39. 2
      hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/PersonManagemetMapper.xml
  40. 19
      hzims-service/hzims-big-model/pom.xml
  41. 13
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java
  42. 37
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/controller/RemoteController.java
  43. 97
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/HistoryDataService.java
  44. 31
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/RemoteService.java
  45. 26
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java
  46. 62
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java
  47. 14
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/IDataSourceService.java
  48. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java
  49. 27
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataAuthTypeEnum.java
  50. 36
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataMethodEnum.java
  51. 41
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java
  52. 17
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java
  53. 11
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java
  54. 11
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/InfoMessageConstant.java
  55. 19
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java
  56. 22
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ProjectRemoteTypeEnum.java
  57. 44
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java
  58. 28
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java
  59. 34
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java
  60. 63
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java
  61. 47
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java
  62. 66
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java
  63. 36
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java
  64. 55
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java
  65. 44
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java
  66. 16
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnalyseDataService.java
  67. 34
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnswerResolveService.java
  68. 22
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java
  69. 63
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java
  70. 42
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java
  71. 1
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IJumpPageService.java
  72. 15
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IParamsService.java
  73. 17
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java
  74. 100
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java
  75. 128
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java
  76. 135
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java
  77. 47
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java
  78. 50
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java
  79. 259
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java
  80. 69
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java
  81. 131
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java
  82. 387
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java
  83. 1
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpPageServiceImpl.java
  84. 55
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java
  85. 106
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java
  86. 73
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java
  87. 36
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamsServiceImpl.java
  88. 59
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java
  89. 75
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java
  90. 25
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java
  91. 27
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java
  92. 37
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/HistoryDataSearchVO.java
  93. 39
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java
  94. 29
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ResolveResultVO.java
  95. 19
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SessionContentVO.java
  96. 24
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java
  97. 20
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateStationVO.java
  98. 25
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateUsualVO.java
  99. 34
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/manager/SessionRedisManager.java
  100. 88
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java
  101. Some files were not shown because too many files have changed in this diff Show More

8
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java

@ -11,6 +11,8 @@ import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Date;
@ -71,9 +73,9 @@ public class AlarmEntity extends TenantEntity {
private Integer alarmCount;
@ApiModelProperty(value = "告警时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.sss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.sss")
private Date alarmTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private LocalDateTime alarmTime;
@ApiModelProperty(value = "监测点")
private String realId;

32
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/AlarmVideoVo.java

@ -0,0 +1,32 @@
package com.hnac.hzims.alarm.show.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.mp.support.QueryField;
import org.springblade.core.mp.support.SqlCondition;
/**
* @author ysj
* @date 2023/03/17 10:02:33
* @version 4.0.0
*/
@Data
public class AlarmVideoVo {
@ApiModelProperty("视频设备编码")
private String pointCode;
@ApiModelProperty("视频名称")
@QueryField(condition = SqlCondition.LIKE)
private String videoName;
@ApiModelProperty("视频服务器host")
private String videoHost;
@ApiModelProperty("运管中心appSecret")
private String videoAppSecret;
@ApiModelProperty("运管中心appKey")
private String videoAppKey;
}

28
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java

@ -0,0 +1,28 @@
package com.hnac.hzims.alarm.show.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author ysj
* @date 2023/03/17 10:02:33
* @version 4.0.0
*/
@Data
public class ShowQueryVo {
@ApiModelProperty(value = "站点编号")
private String stationId;
@ApiModelProperty(value = "站点类型")
private Integer serveType;
@ApiModelProperty(value = "告警类型 :0- HZ3000告警 1 -等级告警 2 -条件告警 3-FDP智能预警 4-视频预警 5-开关机告警")
private Integer alarmSource;
@ApiModelProperty(value = "告警子类")
private Integer alarmType;
}

21
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java

@ -0,0 +1,21 @@
package com.hnac.hzims.business.ws.alart.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel(value = "告警弹框参数", description = "")
public class AlartParamVo {
@ApiModelProperty("站点类型: 2-云服务 1-代运维")
private Integer serveType;
@ApiModelProperty("用户权限机构集合")
private List<Long> depts;
}

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

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 = "id")
private String attrId;
@JSONField(name = "record_name")
private String attrName;
@JSONField(name = "device_name")
private String deviceName;
@JSONField(name = "device_id")
private String deviceId;
@JSONField(name = "station_id")
private String projectId;
@JSONField(name = "station_name")
private String projectName;
@JSONField(name = "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;
}

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

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

20
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.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 16:30
*/
@Data
public class SelectionVO implements Serializable {
/**选项ID**/
private String id;
/**选项名称**/
private String name;
}

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

43
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/ThirtyGenerationEntity.java

@ -0,0 +1,43 @@
package com.hnac.hzims.equipment.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import java.math.BigDecimal;
/**
* 实体类
*
* @author Chill
*/
@Data
@TableName("hzims_em_thirty_generate")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "设备30天发电量对象", description = "")
public class ThirtyGenerationEntity extends TenantEntity {
@ApiModelProperty(value = "站点编码")
private String stationId;
@ApiModelProperty(value = "站点名称")
private String stationName;
@ApiModelProperty(value = "设备编号")
private String deviceCode;
@ApiModelProperty(value = "设备名称")
private String deviceName;
@ApiModelProperty(value = "月份 : String")
private String strDay;
@ApiModelProperty(value = "月份 : Int")
private Integer day;
@ApiModelProperty(value = "发电量")
private BigDecimal generate;
}

43
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/ThreeGenerationEntity.java

@ -0,0 +1,43 @@
package com.hnac.hzims.equipment.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import java.math.BigDecimal;
/**
* 实体类
*
* @author Chill
*/
@Data
@TableName("hzims_em_three_generate")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "设备3年发电量对象", description = "")
public class ThreeGenerationEntity extends TenantEntity {
@ApiModelProperty(value = "站点编码")
private String stationId;
@ApiModelProperty(value = "站点名称")
private String stationName;
@ApiModelProperty(value = "设备编号")
private String deviceCode;
@ApiModelProperty(value = "设备名称")
private String deviceName;
@ApiModelProperty(value = "月份 : String")
private String strMonth;
@ApiModelProperty(value = "月份 : Int")
private Integer month;
@ApiModelProperty(value = "发电量")
private BigDecimal generate;
}

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

14
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/ScheduledConstant.java

@ -0,0 +1,14 @@
package com.hnac.hzims.operational.main.constant;
/**
* 定时任务JobHandler名称
* @author 11423
*/
public interface ScheduledConstant {
String THREE_YEAR_POWER_GENERATION = "threeYearPowerGeneration";
String THIRTY_DAY_POWER_GENERATION = "thirtyDayPowerGeneration";
String THIS_DAY_POWER_GENERATION = "thisDayPowerGeneration";
}

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("远程调用失败!");
}
}

4
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java

@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author liwen
@ -78,4 +79,7 @@ public class CarMilesYearVO {
@ExcelProperty(value = "合计里程/km", order = 15)
@ApiModelProperty("合计里程数")
private BigDecimal sumMiles;
@ApiModelProperty("创建时间")
private Date createTime;
}

4
hzims-service/hzims-alarm/pom.xml

@ -54,6 +54,10 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>

30
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java

@ -3,10 +3,11 @@ package com.hnac.hzims.alarm.show.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import com.hnac.hzims.alarm.source.service.SystemAlarmService;
import com.hnac.hzims.alarm.show.service.AlarmService;
import com.hnac.hzims.alarm.config.vo.AlarmCountVo;
import com.hnac.hzims.equipment.entity.EmVideoBandingEntity;
import com.hnac.hzims.alarm.show.service.AlarmService;
import com.hnac.hzims.alarm.show.vo.AlarmVideoVo;
import com.hnac.hzims.alarm.show.vo.ShowQueryVo;
import com.hnac.hzims.alarm.source.service.SystemAlarmService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -36,30 +37,33 @@ public class ShowAlarmController extends BladeController {
@ApiOperationSupport(order = 1)
@ApiOperation(value = "播报告警", notes = "传入:时间区间")
public R<List<AlarmEntity>> broadcast(@ApiParam(value = "开始时间") String startTime,
@ApiParam(value = "结束时间", required = true) String endTime) {
return R.data(alarmService.broadcast(startTime,endTime));
@ApiParam(value = "结束时间", required = true) String endTime,
@ApiParam(value = "站点类型") Integer serveType) {
return R.data(alarmService.broadcast(startTime,endTime,serveType));
}
@PostMapping("/show")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "告警列表分页", notes = "传入: AlarmConfigEntity对象,分页参数")
public R<IPage<AlarmEntity>> alarms(AlarmEntity alarm, Query query) {
return R.data(alarmService.alarms(alarm,Condition.getPage(query)));
public R<IPage<AlarmEntity>> alarms(ShowQueryVo showQuery, Query query) {
return R.data(alarmService.alarms(showQuery,Condition.getPage(query)));
}
@PostMapping("/count")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "告警分类数量", notes = "不需要传入参数")
public R<List<AlarmCountVo>> counts(@RequestBody AlarmEntity alarm) {
return R.data(alarmService.counts(alarm));
public R<List<AlarmCountVo>> counts(@RequestBody ShowQueryVo showCount) {
return R.data(alarmService.counts(showCount));
}
@GetMapping("/getVideosByStationAndRealId")
@GetMapping("/alarmVideos")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "站点")
public R<List<EmVideoBandingEntity>> getVideosByStationAndRealId(@ApiParam("站点编号") @RequestParam String stationCode,
@ApiParam("监测点ID") @RequestParam String realId) {
return R.data(alarmService.getVideosByStationAndRealId(stationCode,realId));
public R<List<AlarmVideoVo>> alarmVideos(@ApiParam("站点编号") @RequestParam(required = false) String stationCode,
@ApiParam("设备编号") @RequestParam(required = false) String deviceCode,
@ApiParam("监测点ID") @RequestParam(required = false) String realId,
@ApiParam("告警类型") @RequestParam Integer alarmType) {
return R.data(alarmService.alarmVideos(stationCode,deviceCode,realId,alarmType));
}
}

20
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java

@ -4,6 +4,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import com.hnac.hzims.alarm.config.vo.AlarmCountVo;
import com.hnac.hzims.alarm.show.vo.AlarmVideoVo;
import com.hnac.hzims.alarm.show.vo.ShowQueryVo;
import com.hnac.hzims.business.ws.alart.vo.AlartParamVo;
import org.springblade.core.mp.base.BaseService;
import com.hnac.hzims.equipment.entity.EmVideoBandingEntity;
import org.springframework.web.socket.TextMessage;
@ -15,19 +19,13 @@ import java.util.List;
*/
public interface AlarmService extends IService<AlarmEntity> {
IPage<AlarmEntity> alarms(AlarmEntity alarm, IPage<AlarmEntity> page);
IPage<AlarmEntity> alarms(ShowQueryVo showQuery, IPage<AlarmEntity> page);
List<AlarmCountVo> counts(AlarmEntity alarm);
List<AlarmCountVo> counts(ShowQueryVo showCount);
List<AlarmEntity> broadcast(String startTime, String endTime);
List<AlarmEntity> broadcast(String startTime, String endTime,Integer serveType);
TextMessage majorAlarm(List<Long> depts);
TextMessage majorAlarm(AlartParamVo param);
/**
* 根据站点realId 获取视频列表
* @param stationCode 站点编号
* @param realId hz3000点位信息
* @return 视频列表
*/
List<EmVideoBandingEntity> getVideosByStationAndRealId(String stationCode,String realId);
List<AlarmVideoVo> alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmType);
}

109
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java

@ -1,9 +1,9 @@
package com.hnac.hzims.alarm.show.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.alarm.config.constants.AlarmConstants;
import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import com.hnac.hzims.alarm.config.service.AlarmConfigService;
@ -17,20 +17,38 @@ import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.entity.EmVideoBandingEntity;
import com.hnac.hzims.equipment.feign.IEmInfoClient;
import com.hnac.hzims.equipment.feign.IEmVideoClient;
import com.hnac.hzims.message.dto.MailMessageDTO;
import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.alarm.config.service.AlarmConfigService;
import com.hnac.hzims.alarm.config.vo.AlarmCountVo;
import com.hnac.hzims.alarm.config.vo.ChildAlarmCountVo;
import com.hnac.hzims.alarm.show.vo.AlarmVideoVo;
import com.hnac.hzims.alarm.show.vo.ShowQueryVo;
import com.hnac.hzims.business.ws.alart.vo.AlartParamVo;
import com.hnac.hzims.fdp.util.HttpRequestUtil;
import com.hnac.hzims.message.dto.MailMessageDTO;
import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient;
import lombok.AllArgsConstructor;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceEventVO;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
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.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.web.socket.TextMessage;
import java.util.*;
@ -39,7 +57,7 @@ import java.util.stream.Collectors;
/**
* @author ysj
*/
@AllArgsConstructor
@RequiredArgsConstructor
@Service
@Slf4j
public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> implements AlarmService {
@ -54,21 +72,28 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
private final IStationClient stationClient;
private final IMessageClient messageClient;
private final IEmInfoClient emInfoClient;
private final DeviceClient deviceClient;
private final IEmVideoClient emVideoClient;
private final IStationVideoTypeClient stationVideoTypeClient;
@Value("${hzims.url.getFaultGraphInfo}")
private String FAULTGRAPH_INFO_PATH;
/**
* 查询告警列表
* @param alarm
* @param showQuery
* @param page
* @return
*/
@Override
public IPage<AlarmEntity> alarms(AlarmEntity alarm, IPage<AlarmEntity> page) {
List<StationEntity> stations = this.stations();
public IPage<AlarmEntity> alarms(ShowQueryVo showQuery, IPage<AlarmEntity> page) {
List<StationEntity> stations = this.stations(showQuery.getServeType());
if(CollectionUtil.isEmpty(stations)){
return page;
}
@ -79,14 +104,14 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
wrapper.eq("IS_RIGHT_TABULATION",0);
wrapper.eq("STATUS",0);
wrapper.in("STATION_ID",stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
if(!StringUtil.isEmpty(alarm.getStationId())){
wrapper.eq("STATION_ID",alarm.getStationId());
if(!StringUtil.isEmpty(showQuery.getStationId())){
wrapper.eq("STATION_ID",showQuery.getStationId());
}
if(!StringUtil.isEmpty(alarm.getAlarmSource())){
wrapper.eq("ALARM_SOURCE",alarm.getAlarmSource());
if(!StringUtil.isEmpty(showQuery.getAlarmSource())){
wrapper.eq("ALARM_SOURCE",showQuery.getAlarmSource());
}
if(!StringUtil.isEmpty(alarm.getAlarmType())){
wrapper.eq("ALARM_TYPE",alarm.getAlarmType());
if(!StringUtil.isEmpty(showQuery.getAlarmType())){
wrapper.eq("ALARM_TYPE",showQuery.getAlarmType());
}
// 处理告警过滤 :当天处理告警
@ -103,9 +128,11 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
* 获取权限站点
* @return
*/
private List<StationEntity> stations() {
private List<StationEntity> stations(Integer serveType) {
StationEntity station = new StationEntity();
station.setServeType("2");
if(ObjectUtil.isNotEmpty(serveType)){
station.setServeType(String.valueOf(serveType));
}
station.setType(0);
R<List<StationEntity>> result = stationClient.list(station);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
@ -119,9 +146,9 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
* @return
*/
@Override
public List<AlarmCountVo> counts(AlarmEntity alarm) {
public List<AlarmCountVo> counts(ShowQueryVo showCount) {
// 站点查询
List<StationEntity> stations = this.stations();
List<StationEntity> stations = this.stations(showCount.getServeType());
if(CollectionUtil.isEmpty(stations)){
return AlarmConstants.ALARAM_SOURCE.stream().map(source->{
AlarmCountVo count = new AlarmCountVo();
@ -136,14 +163,14 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
wrapper.eq("IS_RIGHT_TABULATION",0);
wrapper.eq("STATUS",0);
wrapper.in("STATION_ID",stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
if(!StringUtil.isEmpty(alarm.getStationId())){
wrapper.eq("STATION_ID",alarm.getStationId());
if(!StringUtil.isEmpty(showCount.getStationId())){
wrapper.eq("STATION_ID",showCount.getStationId());
}
if(!StringUtil.isEmpty(alarm.getAlarmSource())){
wrapper.eq("ALARM_SOURCE",alarm.getAlarmSource());
if(!StringUtil.isEmpty(showCount.getAlarmSource())){
wrapper.eq("ALARM_SOURCE",showCount.getAlarmSource());
}
if(!StringUtil.isEmpty(alarm.getAlarmType())){
wrapper.eq("ALARM_TYPE",alarm.getAlarmType());
if(!StringUtil.isEmpty(showCount.getAlarmType())){
wrapper.eq("ALARM_TYPE",showCount.getAlarmType());
}
// 处理告警过滤 :当天处理告警
List<String> handles = alarmHandleService.handles();
@ -173,9 +200,9 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
* @return
*/
@Override
public List<AlarmEntity> broadcast(String startTime, String endTime) {
public List<AlarmEntity> broadcast(String startTime, String endTime,Integer serveType) {
// 站点查询
List<StationEntity> stations = this.stations();
List<StationEntity> stations = this.stations(serveType);
if(CollectionUtil.isEmpty(stations)){
return new ArrayList<>();
}
@ -193,17 +220,17 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
/**
* 弹框告警
* @param depts
* @param param
* @return
*/
@Override
public TextMessage majorAlarm(List<Long> depts) {
public TextMessage majorAlarm(AlartParamVo param) {
// 站点查询
List<StationEntity> stations = this.stations();
if(CollectionUtil.isEmpty(stations)){
List<StationEntity> stations = this.stations(param.getServeType());
if(CollectionUtil.isEmpty(stations) || CollectionUtil.isEmpty(param.getDepts())){
return new TextMessage(new ArrayList().toString());
}
List<String> effectives = stations.stream().filter(station->depts.contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList());
List<String> effectives = stations.stream().filter(station->param.getDepts().contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList());
if(CollectionUtil.isEmpty(effectives)){
return new TextMessage(new ArrayList().toString());
}
@ -225,7 +252,8 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
return new TextMessage(JSONObject.toJSONString(alarms.stream().sorted(Comparator.comparing(AlarmEntity::getAlarmTime).reversed()).collect(Collectors.toList())));
}
@Override
/* @Override
public List<EmVideoBandingEntity> getVideosByStationAndRealId(String stationCode, String realId) {
R<StationEntity> stationR = stationClient.getStationByCode(stationCode);
Assert.isTrue(stationR.isSuccess() && Func.isNotEmpty(stationR.getData()), () -> {
@ -252,7 +280,7 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
throw new ServiceException("获取设备绑定视频列表失败!");
});
return videoListR.getData().stream().distinct().collect(Collectors.toList());
}
}*/
/**
* 验证设备编号是否绑定视频
@ -270,9 +298,20 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
* @return 绑定结果
*/
private Boolean isRealIdBanding(String realId,String emCode) {
R<List<DeviceInstanceAttrVO>> deviceAttrR = deviceClient.getOnlineAttr(emCode);
if(deviceAttrR.isSuccess() && CollectionUtil.isNotEmpty(deviceAttrR.getData())) {
return deviceAttrR.getData().stream().anyMatch(attr -> realId.equals(attr.getFacDeviceAttrId()));
// 属性
R<List<DeviceInstanceAttrVO>> attrs = deviceClient.getOnlineAttr(emCode);
if(attrs.isSuccess() && CollectionUtil.isNotEmpty(attrs.getData())) {
return attrs.getData().stream().anyMatch(attr -> realId.equals(attr.getFacDeviceAttrId()));
}
// 事件
R<List<DeviceInstanceEventVO>> events = deviceClient.getOnlineEvent(emCode);
if(events.isSuccess() && CollectionUtil.isNotEmpty(events.getData())) {
return events.getData().stream().anyMatch(event -> realId.equals(event.getFacDeviceEventId()));
}
// 功能
R<List<DeviceInstanceFuncVO>> funcs = deviceClient.getOnlineFunc(emCode);
if(funcs.isSuccess() && CollectionUtil.isNotEmpty(funcs.getData())) {
return funcs.getData().stream().anyMatch(func -> realId.equals(func.getSourceAttrSignage()));
}
return false;
}

9
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/DroolsAlarmServiceImpl.java

@ -16,6 +16,8 @@ import org.springblade.core.tool.api.R;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -55,18 +57,19 @@ public class DroolsAlarmServiceImpl implements DroolsAlarmService {
private AlarmEntity getAlarmEntity(DroolsAlarmVo item) {
AlarmEntity entity = new AlarmEntity();
String format = DateUtil.format(item.getTs(), org.springblade.core.tool.utils.DateUtil.PATTERN_DATETIME_MINI);
String format = DateUtil.format(item.getTs(), DateUtil.PATTERN_DATETIME_MINI);
entity.setAlarmId(format+"-"+item.getDeviceCode());
entity.setAlarmSource(CONDITION_ALARM);
entity.setAlarmType(CONDITION);
entity.setAlarmContext(item.getName());
entity.setAlarmTime(item.getTs());
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localDateTime = LocalDateTime.ofInstant(item.getTs().toInstant(), zoneId);
entity.setAlarmTime(localDateTime);
entity.setAlarmValue(item.getCurrentValue());
entity.setAlarmSignage(item.getSignage());
entity.setAlarmLevel(Integer.valueOf(item.getLevel()));
entity.setAlarmStatus(1);
entity.setDeviceCode(item.getDeviceCode());
entity.setTenantId("200000");
entity.setStationId(item.getProjectId());
R<StationEntity> stationByCode = stationClient.getStationByCode(item.getProjectId());
if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){

6
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java

@ -18,6 +18,8 @@ import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -82,7 +84,9 @@ public class FdpAlarmServiceImpl implements FdpAlarmService {
AlarmEntity entity = new AlarmEntity();
entity.setAlarmId(item.getUUID());
entity.setRealId(item.getFaultId());
entity.setAlarmTime(item.getCreateTime());
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localDateTime = LocalDateTime.ofInstant(item.getCreateTime().toInstant(), zoneId);
entity.setAlarmTime(localDateTime);
entity.setAlarmContext(item.getFinfo());
entity.setAlarmSource(EARLY_WARNING);
entity.setAlarmType(EARLY);

13
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/LevelAlarmServiceImpl.java

@ -21,6 +21,9 @@ import org.springblade.core.tool.utils.DateUtil;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -79,11 +82,7 @@ public class LevelAlarmServiceImpl implements LevelAlarmService {
if (CollectionUtil.isEmpty(alarms)) {
return new ArrayList<>();
}
List<AlarmEntity> res = alarms.stream().map(s -> {
AlarmEntity entity = getAlarmEntity(s);
return entity;
}).collect(Collectors.toList());
return res;
return alarms.stream().map(this::getAlarmEntity).collect(Collectors.toList());
}
private AlarmEntity getAlarmEntity(LevelVo level) {
@ -91,7 +90,9 @@ public class LevelAlarmServiceImpl implements LevelAlarmService {
AlarmEntity entity = new AlarmEntity();
entity.setAlarmSource(AlarmConstants.LEVEL_ALARM);
entity.setAlarmId(level.getId());
entity.setAlarmTime(new Date(level.getTs()));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.sss");
LocalDateTime localDateTime = LocalDateTime.parse(level.getTs(), formatter);
entity.setAlarmTime(localDateTime);
entity.setAlarmType(level.getType());
entity.setRealId(level.getSignage());
entity.setAlarmContext(level.getName());

13
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java

@ -4,6 +4,11 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import com.hnac.hzims.alarm.source.service.MessageService;
import com.hnac.hzims.common.constant.CommonConstant;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.BusinessMessageDTO;
import com.hnac.hzims.message.dto.SmsImmediatelyPushDTO;
import com.hnac.hzims.message.dto.WxMessageDTO;
import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import lombok.RequiredArgsConstructor;
@ -24,6 +29,7 @@ import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -68,7 +74,7 @@ public class MessageServiceImpl implements MessageService {
}
Long dept = stationByCode.getData().getRefDept();
// 获取站点用户
R<List<User>> result = userClient.userListByDeptId(dept);
R<List<User>> result = userClient.userByDeptIdLevel(dept,1);
if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) {
log.error("WEB/APP消息发送失败:用户获取失败 : {}",entity);
return;
@ -161,6 +167,7 @@ public class MessageServiceImpl implements MessageService {
}
userList.addAll(result.getData());
log.info("短信发送用户列表:{}",userList);
log.info("短信发送用户列表,{}",userList);
}else {
//内测只推给对应的3个用户
List<String> phoneList = Arrays.asList("18351807087", "18163793336", "18285121497");
@ -171,6 +178,7 @@ public class MessageServiceImpl implements MessageService {
}
}
log.info("短信发送用户列表:{}",userList);
log.info("短信发送用户列表,{}",userList);
}
String userIds = userList.stream().map(o -> String.valueOf(o.getId())).distinct().collect(Collectors.joining(","));
WxMessageDTO message = new WxMessageDTO();
@ -192,6 +200,9 @@ public class MessageServiceImpl implements MessageService {
map.put("thing11",getTruncateString(entity.getAlarmContext(), 20));
map.put("time2",entity.getAlarmTime());
map.put("thing14", DictCache.getValue("alarm_type", String.valueOf(entity.getAlarmType())));
DateTimeFormatter format = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME);
map.put("time2",format.format(entity.getAlarmTime()));
map.put("thing14", DictCache.getValue("alarm_type", entity.getAlarmType()));
message.setMap(map);
// 消息内容
message.setContent(entity.getAlarmContext());

27
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java

@ -9,6 +9,8 @@ import com.hnac.hzims.alarm.show.service.AlarmService;
import com.hnac.hzims.alarm.source.service.DroolsAlarmService;
import com.hnac.hzims.alarm.source.service.MessageService;
import com.hnac.hzims.alarm.source.service.SoeAlarmService;
import com.hnac.hzims.common.constant.CommonConstant;
import com.hnac.hzims.common.utils.CommonUtil;
import com.hnac.hzims.common.utils.DateUtil;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
@ -19,10 +21,9 @@ import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
import static com.hnac.hzims.alarm.config.constants.AlarmConstants.*;
@ -53,32 +54,26 @@ public class SoeAlarmServiceImpl implements SoeAlarmService {
public List<AlarmEntity> receiveMessage(String message) {
// 对象转换
SoeAlarmVo parseObject = JSONObject.parseObject(message, SoeAlarmVo.class);
List<SoeAlarmVo> alarms = Arrays.asList(parseObject);
if (CollectionUtil.isEmpty(alarms)) {
return new ArrayList<>();
}
List<AlarmEntity> res = alarms.stream().map(s -> {
AlarmEntity entity = getAlarmEntity(s);
return entity;
}).collect(Collectors.toList());
return res;
List<SoeAlarmVo> alarms = Collections.singletonList(parseObject);
return alarms.stream().map(this::getAlarmEntity).collect(Collectors.toList());
}
private AlarmEntity getAlarmEntity(SoeAlarmVo item) {
AlarmEntity entity = new AlarmEntity();
String format = DateUtil.format(item.getTs(), org.springblade.core.tool.utils.DateUtil.PATTERN_DATETIME_MINI);
entity.setAlarmId(format+"-"+item.getDeviceCode());
entity.setAlarmSource(LEVEL_ALARM);
entity.setAlarmType(ONE_LEVEL);
entity.setAlarmContext(item.getName());
entity.setAlarmTime(item.getTs());
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localDateTime = LocalDateTime.ofInstant(item.getTs().toInstant(), zoneId);
entity.setAlarmTime(localDateTime);
entity.setAlarmValue(item.getCurrentValue());
entity.setAlarmSignage(item.getSignage());
entity.setAlarmLevel(Integer.valueOf(item.getLevel()));
entity.setAlarmStatus(1);
entity.setDeviceCode(item.getDeviceCode());
entity.setTenantId("200000");
entity.setTenantId(CommonConstant.TENANT_ID);
entity.setStationId(item.getProjectId());
R<StationEntity> stationByCode = stationClient.getStationByCode(item.getProjectId());
if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){

10
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java

@ -20,6 +20,8 @@ import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@ -80,9 +82,11 @@ public class SystemAlarmServiceImpl implements SystemAlarmService {
private AlarmEntity getAlarmEntity(SystemAlarmVo item) {
AlarmEntity entity = new AlarmEntity();
entity.setAlarmId(item.getId());
// Date date = new Date(item.getTs());
// entity.setAlarmTime(DateUtil.parse(item.getTs().toString(),PATTERN_DATETIME_MILLIS));
entity.setAlarmTime( new Date(item.getTs()));
ZoneId zoneId = ZoneId.systemDefault();
Date alarmTime = new Date();
alarmTime.setTime(item.getTs());
LocalDateTime localDateTime = LocalDateTime.ofInstant(alarmTime.toInstant(), zoneId);
entity.setAlarmTime(localDateTime);
entity.setAlarmContext(item.getContext());
entity.setAlarmType(item.getType());
entity.setAlarmStatus(item.getState());

6
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java

@ -23,6 +23,8 @@ import org.springblade.core.tool.utils.DateUtil;
import org.springblade.message.fegin.IMessageClient;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -101,7 +103,9 @@ public class VideoAlarmServiceImpl implements VideoAlarmService {
private AlarmEntity getAlarmEntity(DeviceSoeVO item) {
AlarmEntity entity = new AlarmEntity();
entity.setAlarmId(item.getId());
entity.setAlarmTime(DateUtil.parse(item.getTs(), PATTERN_DATETIME_MILLIS));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.sss");
LocalDateTime localDateTime = LocalDateTime.parse(item.getTs(), formatter);
entity.setAlarmTime(localDateTime);
entity.setAlarmContext(item.getSoeExplain());
entity.setAlarmType(AlarmHandleConstant.VIDEO_ALARM);
entity.setAlarmStatus(Integer.valueOf(item.getSoeStatus()));

9
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java

@ -2,8 +2,8 @@ package com.hnac.hzims.alarm.ws.alart;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.alarm.show.service.AlarmService;
import com.hnac.hzims.business.ws.alart.vo.AlartParamVo;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -13,7 +13,6 @@ import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.TextWebSocketHandler;
import java.io.IOException;
import java.util.List;
/**
* @author ysj
@ -57,11 +56,11 @@ public class AlarmHandler extends TextWebSocketHandler {
if(StringUtil.isBlank(message)){
return;
}
List<Long> depts = JSONObject.parseArray(message,Long.class);
if(CollectionUtil.isEmpty(depts)){
AlartParamVo param = JSONObject.parseObject(message,AlartParamVo.class);
if(ObjectUtil.isEmpty(param)){
return;
}
TextMessage sendMessage = alarmService.majorAlarm(depts);
TextMessage sendMessage = alarmService.majorAlarm(param);
session.sendMessage(sendMessage);
}
}

2
hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/PersonManagemetMapper.xml

@ -57,7 +57,7 @@
LIMIT #{current}, #{size}
) as c
left join hzims_certificatet as b
on c.id=b.person_id and c.is_deleted = 0
on c.id=b.person_id and b.is_deleted = 0
where c.is_deleted = 0
<if test="type != null and type != ''">
and b.type = #{type}

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

@ -47,6 +47,25 @@
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>hzims-operational-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.hnac.hzinfo.data</groupId>
<artifactId>hzinfo-data-sdk</artifactId>
</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>

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

37
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/controller/RemoteController.java

@ -0,0 +1,37 @@
package com.hnac.hzims.bigmodel.data.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.bigmodel.BigModelConstants;
import com.hnac.hzims.bigmodel.data.service.RemoteService;
import com.hnac.hzinfo.log.annotation.Business;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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);
}
}

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

@ -0,0 +1,97 @@
package com.hnac.hzims.bigmodel.data.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/data/service/RemoteService.java

@ -0,0 +1,31 @@
package com.hnac.hzims.bigmodel.data.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);
}
}

26
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java

@ -0,0 +1,26 @@
package com.hnac.hzims.bigmodel.datasource.controller;
import com.hnac.hzims.bigmodel.datasource.service.DataSourceService;
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.RestController;
/**
* @Author: huangxing
* @Date: 2024/06/28 14:07
*/
@RestController
@RequestMapping("/dataSource/execute")
@AllArgsConstructor
public class DataSourceExecuteController {
private final DataSourceService dataSourceService;
@GetMapping("/executeQuery")
public R executeQuery(String sql,String dataSourceName) {
return R.data(dataSourceService.queryListOnSpecificDataSource(sql,dataSourceName));
}
}

62
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java

@ -0,0 +1,62 @@
package com.hnac.hzims.bigmodel.datasource.service;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
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 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);
/**
* 指定
* @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();
}
}
public static boolean isUpdateOrDelete(String sql) {
if (sql == null) {
return false;
}
return UPDATE_PATTERN.matcher(sql).find() || DELETE_PATTERN.matcher(sql).find();
}
}

14
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/IDataSourceService.java

@ -0,0 +1,14 @@
package com.hnac.hzims.bigmodel.datasource.service;
import java.util.List;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/06/28 14:22
*/
public interface IDataSourceService {
List<Map<String,Object>> queryList(String sql);
}

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

@ -41,7 +41,7 @@ public class FunctionController {
return R.status(functionService.save(req));
}
@PutMapping("/save")
@PutMapping("/updateById")
@ApiOperation("编辑函数")
@ApiOperationSupport(order = 2)
public R updateById(@RequestBody FunctionEntity req) {

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

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

@ -12,16 +12,29 @@ 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),
;
@Getter
private String funcCode;
@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();
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);
}
}

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

@ -0,0 +1,34 @@
package com.hnac.hzims.bigmodel.interactive.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService;
import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author: huangxing
* @Date: 2024/05/29 09:22
*/
@RequestMapping("/analyse/data")
@AllArgsConstructor
@Api(value = "数据查询管理",tags = "数据查询管理")
@RestController
@Deprecated
public class AnalyseDataController {
private final IAnalyseDataService analyseDataService;
@GetMapping("/getHistoryData")
@ApiOperation("获取历史数据")
@ApiOperationSupport(order = 1)
public R getHistoryData(@Validated HistoryDataSearchVO searchVO) {
return R.data(analyseDataService.getHistoryData(searchVO));
}
}

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

@ -0,0 +1,63 @@
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.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<String>> hotQuestions() {
return R.data(hznlmInvokeService.hotQuestions());
}
@ApiOperation("获取问答sessionId")
@ApiOperationSupport(order = 4)
@GetMapping("/getSessionId")
public R<String> getSessionId() {
return R.data(IdWorker.get32UUID());
}
}

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

@ -0,0 +1,47 @@
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.interactive.dto.AuthDataDTO;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService;
import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO;
import com.hnac.hzinfo.log.annotation.Business;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* @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;
@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));
}
}

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

@ -2,19 +2,22 @@ package com.hnac.hzims.bigmodel.interactive.controller;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.google.common.collect.Lists;
import com.hnac.hzims.bigmodel.BigModelConstants;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService;
import com.hnac.hzims.bigmodel.interactive.vo.StationSearchVO;
import com.hnac.hzinfo.log.annotation.Business;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.system.dto.ControlDTO;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.text.DecimalFormat;
import java.util.List;
/**
* @Author: huangxing
@ -25,6 +28,7 @@ import javax.servlet.http.HttpServletRequest;
@Api(value = "FDP大模型交互层",tags = "FDP大模型交互层")
@RequestMapping("/interactive")
@Business(module = BigModelConstants.MODULE_NAME,value = "FDP大模型交互层")
@Deprecated
public class InteractiveController {
private final IInteractiveService interactiveService;
@ -39,17 +43,20 @@ public class InteractiveController {
@ApiOperation("提问")
@ApiOperationSupport(order = 2)
@GetMapping("/ask")
public R ask(@RequestParam @ApiParam("用户提出问题") String question,@RequestParam @ApiParam("问答sessionId") String sessionId) {
return interactiveService.ask(question, sessionId);
@Deprecated
public R ask(@RequestParam @ApiParam("用户提出问题") String question,@RequestParam @ApiParam("问答sessionId") String sessionId,@RequestParam @ApiParam("用户Id") String userId) {
return interactiveService.ask(question, sessionId, userId);
}
@ApiOperation("站点、菜单鉴权")
@ApiOperationSupport(order = 3)
@Deprecated
@RequestMapping(value = "/authentication",method = {RequestMethod.GET,RequestMethod.POST})
public R authentication(@RequestParam(required = false) @ApiParam("站点编号") String stationId,
@RequestParam @ApiParam("用户ID") String userId,
@RequestParam(required = false) @ApiParam("菜单ID") String menuId) {
return R.status(interactiveService.authentication(stationId,userId,menuId));
@RequestParam(required = false) @ApiParam("菜单ID") String func,
@RequestParam(required = false) @ApiParam("会话ID")String askId) {
return R.status(interactiveService.authentication(stationId,userId,func,askId));
}
@ApiOperation("获取问答sessionId")
@ -59,4 +66,51 @@ public class InteractiveController {
return R.data(IdWorker.get32UUID());
}
@ApiOperation("删除对话sessionId")
@ApiOperationSupport(order = 5)
@GetMapping("/removeSessionId")
@Deprecated
public R<Boolean> removeSessionId(@RequestParam(value = "id") String sessionId) {
return R.data(interactiveService.removeSessionId(sessionId));
}
@ApiOperation("下发遥控指令")
@ApiOperationSupport(order = 6)
@PostMapping("/sendRemoteControl")
public R sendRemoteControl(@RequestBody ControlDTO operate) {
return interactiveService.sendRemoteControl(operate);
}
@ApiOperation("解析接入站点数量")
@ApiOperationSupport(order = 7)
@PostMapping("/resolveStations")
public R resolveStations(@RequestBody StationSearchVO req) {
return R.data(interactiveService.resolveStations(req.getStartTime(),req.getEndTime(),req.getType(),req.getEnumType()));
}
@ApiOperation("站点发电量")
@ApiOperationSupport(order = 7)
@RequestMapping(value = "/generation",method = {RequestMethod.GET,RequestMethod.POST})
public R generation(@RequestParam @ApiParam("站点编号") String stationId,
@RequestParam @ApiParam("开始时间") String startTime,
@RequestParam @ApiParam("结束时间")String endTime) {
double generate = interactiveService.generation(stationId,startTime,endTime);
DecimalFormat format = new DecimalFormat("0.00");
return R.data(format.format(generate) + "kWh");
}
@ApiOperation("获取热点问题")
@ApiOperationSupport(order = 8)
@GetMapping("/hotQuestions")
@Deprecated
public R hotQuestions() {
try{
List questions = interactiveService.hotQuestions();
return R.data(questions);
}
catch (Exception e) {
e.printStackTrace();
return R.data(Lists.newArrayList());
}
}
}

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

@ -0,0 +1,36 @@
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("chat_id")
@ApiModelProperty("问答ID,用于获取前端发起问答传入缓存中数据")
@NotBlank
private String sessionId;
@JsonProperty("user_id")
@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解析失败!");
}
}

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

@ -0,0 +1,44 @@
package com.hnac.hzims.bigmodel.interactive.factory;
import com.hnac.hzims.bigmodel.entity.FunctionEntity;
import com.hnac.hzims.bigmodel.function.service.IFunctionService;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants;
import com.hnac.hzims.bigmodel.interactive.service.IResolveService;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.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);
}
}

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

@ -0,0 +1,22 @@
package com.hnac.hzims.bigmodel.interactive.service;
import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO;
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(@RequestBody @Valid AuthDataDTO req);
ExtraVO resolve(ModelFunctionReq req);
}

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

@ -0,0 +1,63 @@
package com.hnac.hzims.bigmodel.interactive.service;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
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 提问结果
*/
void ask(String question, String sessionId, String userId);
/**
* 特殊问题
* @param sessionId 会话ID
* @param userId 提问人ID
* @param extra 特殊问题内容
* @return 提问结果
*/
void specialAsk(String sessionId, String userId, Map<String,Object> extra);
/**
* 知识库问题
* @param question 问题名称
* @param sessionId 会话ID
* @param userId 提问人ID
* @param knowledge 知识库名称
*/
void knowledgeAsk(String question, String sessionId, String userId, String knowledge);
/**
* 删除对话记录
* @param sessionId 会话ID
*/
void removeSessionId(String sessionId);
/**
* 获取热点问题
* @return 热点问题
*/
List hotQuestions();
/**
* 查询问答状态
* @param sessionIds 会话ID按逗号分隔
* @return 答案列表
*/
List<AnswerVO> getAnswerBySessionIds(String sessionIds);
}

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

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

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

@ -9,6 +9,7 @@ import java.util.Map;
* @Author: huangxing
* @Date: 2024/04/26 11:46
*/
@Deprecated
public interface IJumpPageService {
String dealJumpTypeFunction(FunctionEntity function, Map<String,String> args);

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

@ -0,0 +1,15 @@
package com.hnac.hzims.bigmodel.interactive.service;
import com.hnac.hzims.bigmodel.entity.FunctionEntity;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/05/09 08:50
*/
@Deprecated
public interface IParamsService {
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);
}

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

@ -0,0 +1,100 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.hnac.hzims.bigmodel.data.service.HistoryDataService;
import com.hnac.hzims.bigmodel.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.DeviceDataClient;
import com.hnac.hzinfo.sdk.v5.device.dto.ReductionAttrDataDTO;
import com.hnac.hzinfo.sdk.v5.device.dto.ReductionDataDTO;
import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO;
import lombok.AllArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.getFuncCode());
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;
}
}

128
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java

@ -0,0 +1,128 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.google.common.collect.Lists;
import com.hnac.hzims.bigmodel.entity.FunctionEntity;
import com.hnac.hzims.bigmodel.function.service.IFunctionService;
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;
import java.util.stream.Collectors;
/**
* @Author: huangxing
* @Date: 2024/05/21 16:10
*/
@Service
@AllArgsConstructor
public class AuthenticationService {
private final IDeptClient deptClient;
private final IFunctionService functionService;
private final IUserClient userClient;
private final ProjectClient projectClient;
private final IRemoteClient remoteClient;
private final RedisTemplate redisTemplate;
/**
* 站点鉴权
* @param stationId 站点ID
* @param userId 用户ID
*/
public void stationAuthentication(String stationId, String userId) {
List<String> stations = this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId)
.filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).collect(Collectors.toList());
Assert.isTrue(stations.contains(stationId),() -> {
throw new ServiceException("人员站点鉴权失败!");
});
}
/**
* 菜单鉴权
* @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().intValue() == 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();
}
}

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

@ -0,0 +1,135 @@
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.bigmodel.interactive.vo.ResolveResultVO;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzinfo.sdk.v5.scada.ScadaClient;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.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.getFunctionArgs();
String id = args.get("id");
String name = args.get("name");
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 id) {
ExtraVO extraVO = new ExtraVO();
extraVO.setImmediatelyJump(true);
extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFuncCode());
final String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"};
String canvasHost = ParamCache.getValue(ParamKeyConstants.CANVAS_HOST);
// 将ID解析为
Map<String, String> resolveMap = this.resolve(id, SCADA_PARAMS_SOLVE);
R<StationEntity> stationR = stationClient.getStationByCode(resolveMap.get("projectId"));
extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + resolveMap.get("name"));
Integer picResource = Integer.valueOf(resolveMap.get("picResource"));
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}&name={name}", 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;
}
}

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

@ -0,0 +1,47 @@
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);
String funcCode = originExtra.getString("func");
result.setFunc(funcCode);
result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType());
JSONArray selections = JSONArray.parseArray(JSON.toJSONString(originExtra.get("data")));
result.setSelection(selections);
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;
}
}

259
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java

@ -0,0 +1,259 @@
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.constants.FunctionConstants;
import com.hnac.hzims.bigmodel.interactive.constants.SearchTypeEnum;
import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService;
import com.hnac.hzims.bigmodel.interactive.vo.*;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient;
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*;
import org.springframework.stereotype.Service;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author: huangxing
* @Date: 2024/05/08 16:19
*/
@Service
@AllArgsConstructor
@Deprecated
public class ExtraResolveStrategyService {
public static final String PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss.SSS";
public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN_DATETIME);
private final IStationClient stationClient;
private final IStationVideoTypeClient videoTypeClient;
private final JumpRouteJoinStrategy jumpRouteJoinStrategy;
private final DeviceClient deviceClient;
private final IAnalyseDataService analyseDataService;
/**
* 解析DFP返回extra
* @param extraStr DFP返回extra
* @return 与前端交互extra
*/
public ExtraVO resolve(String extraStr) {
JSONObject extra = JSONObject.parseObject(extraStr);
String functionCode = Optional.ofNullable(extra.get("func")).map(String::valueOf).orElse("");
if(StringUtil.isNotBlank(functionCode)) {
XxlJobLogger.log("函数编号为:" + functionCode);
FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(functionCode);
if(Func.isNotEmpty(funcRouteEnum)) {
switch (funcRouteEnum) {
case DIAGNOSE:
return this.resolveDiagnose(extra);
case CHOOSE_VIDEO:
case CHOOSE_CANVAS:
case CHOOSE_STATION:
case CHOOSE_FAULT:
case CHOOSE_YC:
case CHOOSE_YK:
return this.resolveChooseSelection(extra,funcRouteEnum);
case CONFIRM_YK:
return this.resolveConfirmRemote(extra);
case SHOW_PARAM:
return this.resolveShowParam(extra);
default:
break;
}
}
}
else if(extra.containsKey("extra")){
return extra.getObject("extra",ExtraVO.class);
}
return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class);
}
private ExtraVO resolveChooseSelection(JSONObject extra,FuncRouteEnum funcRouteEnum) {
ExtraVO result = new ExtraVO();
JSONArray selections = JSONArray.parseArray(JSON.toJSONString(extra.get("data")));
result.setFunc(funcRouteEnum.getFuncCode());
result.setSpecial(true);
result.setSelection(selections);
result.setType(funcRouteEnum.getType().getType());
return result;
}
// private ExtraVO resolveChooseYc(JSONObject extra) {
// ExtraVO result = new ExtraVO();
// JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")));
// if(data.containsKey("yks")) {
//
//
// List<AttrSelectionVO> attrs = JSONArray.parseArray(JSON.toJSONString(data.get("yks")), AttrSelectionVO.class);
// result.setSelection(attrs);
// }
// result.setFuncCode(FuncRouteEnum.CHOOSE_YC.getFuncCode());
// result.setSpecial(true);
// result.setType(FuncRouteEnum.CHOOSE_YC.getType().getType());
// return result;
// }
private ExtraVO resolveShowParam(Map<String,Object> extra) {
DataVO data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")),DataVO.class);
if(Func.isNotEmpty(data)) {
if(Func.isNotEmpty(data.getReal())) {
if(Func.isNotEmpty(data.getReal().getTime()) && StringUtil.isNotBlank(data.getReal().getTime())) {
RealDataVO real = data.getReal();
Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME);
real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME));
}
}
if(Func.isNotEmpty(data.getItem()) && StringUtil.isNotBlank(data.getMethod())) {
if(SearchTypeEnum.HISTORY.getSearchType().equals(data.getType()) && Func.isNotEmpty(data.getItem())) {
DataItemVO item = data.getItem();
HistoryDataSearchVO searchVO = new HistoryDataSearchVO();
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 analyseDataService.getHistoryData(searchVO);
}
}
}
ExtraVO result = new ExtraVO();
result.setFunc(FuncRouteEnum.SHOW_PARAM.getFuncCode());
result.setType(FuncRouteEnum.SHOW_PARAM.getType().getType());
Map<String,Object> param = new HashMap(1);
param.put("data", data);
result.setParams(param);
return result;
}
@Deprecated
private ExtraVO resolveConfirmRemote(Map<String,Object> extra) {
ExtraVO result = new ExtraVO();
RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(extra.get("data")), RemoteParamVO.class);
result.setFunc(FuncRouteEnum.CONFIRM_YK.getFuncCode());
result.setType(FuncRouteEnum.CONFIRM_YK.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;
}
// private ExtraVO resolveChooseFault(Map<String,Object> extra) {
// ExtraVO result = new ExtraVO();
// JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")));
// if(data.containsKey("faults")) {
// List<FaultSelectionVO> faults = JSONArray.parseArray(JSON.toJSONString(data.get("faults")), FaultSelectionVO.class);
// result.setSelection(faults);
// }
// result.setFuncCode(FuncRouteEnum.CHOOSE_FAULT.getFuncCode());
// result.setSpecial(true);
// result.setType(FunctionConstants.TypeEnum.CHOOSE.getType());
// return result;
// }
private ExtraVO resolveDiagnose(Map<String,Object> extra) {
ExtraVO result = new ExtraVO();
JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.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);
result.setFunc(FuncRouteEnum.DIAGNOSE.getFuncCode());
result.setType(FunctionConstants.TypeEnum.PARAMS.getType());
return result;
}
/**
*
* @param extra
* @return
*/
// private ExtraVO resolveChooseStation(Map<String,Object> extra) {
// ExtraVO result = new ExtraVO();
// JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")));
// if(data.containsKey("stations")) {
// List<String> stations = JSONArray.parseArray(JSON.toJSONString(data.get("stations")), String.class);
// List<StationSelectionVO> selectionList = stations.stream().map(stationId -> {
// StationSelectionVO selectionVO = new StationSelectionVO();
// R<StationEntity> stationR = stationClient.getStationByCode(stationId);
// if (stationR.isSuccess() && Func.isNotEmpty(stationR.getData())) {
// selectionVO.setId(stationId);
// selectionVO.setName(stationR.getData().getName());
// }
// return selectionVO;
// }).collect(Collectors.toList());
// result.setSelection(selectionList);
// result.setFuncCode(FuncRouteEnum.CHOOSE_STATION.getFuncCode());
// result.setSpecial(true);
// result.setType(FunctionConstants.TypeEnum.CHOOSE.getType());
// }
// result.setType(FunctionConstants.TypeEnum.CHOOSE.getType());
// return result;
// }
private ExtraVO resolveChooseVideo(Map<String,Object> extra) {
ExtraVO result = new ExtraVO();
JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")));
if(data.containsKey("videos")) {
List<JSONObject> videoIds = JSONArray.parseArray(JSON.toJSONString(data.get("videos")), JSONObject.class);
List<VideoSelectionVO> selections = videoIds.stream().map(video -> {
R<StationVideoTypeEntity> videoR = videoTypeClient.getById(Long.valueOf(video.getString("id")));
VideoSelectionVO selectionVO = new VideoSelectionVO();
if (videoR.isSuccess() && Func.isNotEmpty(videoR.getData())) {
selectionVO.setId(video.getString("id"));
selectionVO.setName(videoR.getData().getName());
}
return selectionVO;
}).collect(Collectors.toList());
result.setFunc(FuncRouteEnum.CHOOSE_VIDEO.getFuncCode());
result.setSpecial(true);
result.setSelection(selections);
}
result.setType(FunctionConstants.TypeEnum.CHOOSE.getType());
return result;
}
private ExtraVO resolveChooseScada(Map<String,Object> extra) {
ExtraVO result = new ExtraVO();
JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")));
if(data.containsKey("canvases")) {
List<JSONObject> canvases = JSONArray.parseArray(JSON.toJSONString(data.get("canvases")), JSONObject.class);
List<ScadaSelectionVO> selections = canvases.stream().map(canvas -> {
ScadaSelectionVO selectionVO = new ScadaSelectionVO();
Map<String, String> resolve = jumpRouteJoinStrategy.resolve(canvas.getString("id"), JumpRouteJoinStrategy.SCADA_PARAMS_SOLVE);
selectionVO.setId(canvas.getString("id"));
selectionVO.setName(resolve.get("name"));
return selectionVO;
}).collect(Collectors.toList());
result.setFunc(FuncRouteEnum.CHOOSE_CANVAS.getFuncCode());
result.setSpecial(true);
result.setSelection(selections);
}
result.setType(FunctionConstants.TypeEnum.CHOOSE.getType());
return result;
}
}

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

@ -0,0 +1,69 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.hnac.hzims.bigmodel.interactive.constants.DataAuthTypeEnum;
import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO;
import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService;
import com.hnac.hzims.bigmodel.interactive.service.IResolveService;
import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.dto.DeptStationDTO;
import org.springframework.stereotype.Service;
import java.util.List;
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;
@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.getFunctionName());
return resolveService.resolve(req);
}
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.getId())).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());
}
}

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

@ -0,0 +1,131 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.TypeReference;
import com.google.common.collect.Lists;
import com.hnac.hzims.bigmodel.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.utils.RequestClientUtil;
import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.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.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/06/21 17:20
* @Describe HZN_LM大模型接口调用服务层
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
private final AuthenticationService authenticationService;
private final BigModelInvokeUrl bigModelInvokeUrl;
private final BladeLogger logger;
private final SessionRedisManager sessionRedisManager;
@Value("${fdp.host}")
private String fdpHost;
@Override
public void ask(String question, String sessionId, String userId) {
Map<String,Object> params = new HashMap<>();
params.put("id",sessionId);
params.put("userid", userId);
params.put("query",question);
Map<String, String[]> authDataIds = this.getAuthDataIds(userId);
params.putAll(authDataIds);
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantAsk(), params);
sessionRedisManager.addSessionId(sessionId);
}
@Override
public void specialAsk(String sessionId, String userId, Map<String, Object> extra) {
Map<String,Object> params = new HashMap<>();
params.put("id",sessionId);
params.put("userid", userId);
params.put("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 knowledgeAsk(String question, String sessionId, String userId, String knowledge) {
Map<String,Object> params = new HashMap<>();
params.put("id", sessionId);
params.put("userid", userId);
params.put("query", question);
params.put("knowledge", knowledge);
Map<String, String[]> authDataIds = this.getAuthDataIds(userId);
params.putAll(authDataIds);
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantKnowledgeAsk(), params);
sessionRedisManager.addSessionId(sessionId);
}
@Override
public void removeSessionId(String sessionId) {
Map<String,Object> params = new HashMap<>();
params.put("id",sessionId);
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAskAbort(), params);
// 移除内存sessionId
InteractiveSessionManager.SESSION_POOL.remove(sessionId);
sessionRedisManager.removeSessionId(sessionId);
}
@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("ids",Func.toStrList(",",sessionIds).toArray());
List<AnswerVO> answerVOList = RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantStatus(), params, new TypeReference<List<AnswerVO>>(){});
return answerVOList;
}
private Map<String,String[]> getAuthDataIds(String userId) {
List<DeptStationDTO> authDatas = authenticationService.getStationPermissionsById(userId);
Map<String, String[]> result = new HashMap<>(2);
String[] stationIds = authDatas.stream().map(DeptStationDTO::getStationId)
.filter(StringUtil::isNotBlank).toArray(String[]::new);
String[] projectIds = authDatas.stream().map(DeptStationDTO::getDeptId)
.filter(Func::isNotEmpty).map(String::valueOf).toArray(String[]::new);
result.put("stationids", stationIds);
result.put("projectids", projectIds);
return result;
}
}

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

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

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

@ -26,6 +26,7 @@ import java.util.Set;
@Service
@AllArgsConstructor
@Slf4j
@Deprecated
public class JumpPageServiceImpl implements IJumpPageService {
private final IFuncParamService paramService;

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

@ -6,24 +6,32 @@ import com.hnac.hzims.bigmodel.entity.FunctionEntity;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import lombok.RequiredArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.IntStream;
/**
* @Author: huangxing
* @Date: 2024/04/30 11:38
*/
@Component
@RequiredArgsConstructor
@Deprecated
public class JumpRouteJoinStrategy {
private final IStationClient stationClient;
public static String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"};
/**
* 解析大模型传参
* @param args 大模型传参
@ -33,7 +41,7 @@ public class JumpRouteJoinStrategy {
FuncRouteEnum routeEnum = FuncRouteEnum.getEnumByFuncCode(function.getCode());
if(Func.isNotEmpty(routeEnum)) {
switch(routeEnum) {
case OPEN_SCADA:
case OPEN_CANVAS:
return this.getScadaExtra(args,function);
default:
break;
@ -42,13 +50,20 @@ public class JumpRouteJoinStrategy {
return null;
}
private ExtraVO getScadaExtra(Map<String,String> args,FunctionEntity function) {
public ExtraVO getScadaExtra(Map<String,String> args,FunctionEntity function) {
// 跳转页面逻辑
ExtraVO extraVO = new ExtraVO();
extraVO.setImmediatelyJump(true);
extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFuncCode());
Map<String, String> params = this.scadaResolve(args);
// 根据hz3000画面版本获取path
Integer picResource = Integer.valueOf(params.get("picResource"));
JSONObject pathObject = JSONObject.parseObject(function.getPath());
R<StationEntity> stationR = stationClient.getStationByCode(params.get("projectId"));
extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + params.get("name"));
Map<String,Object> extraParams = new HashMap<>(1);
extraParams.put("picResource",picResource);
extraVO.setParams(extraParams);
// 云组态
if(picResource == 0) {
String scada = pathObject.getString("scada");
@ -78,27 +93,23 @@ public class JumpRouteJoinStrategy {
}
/**
* 打开实时画面
* 解析实时画面参数
* @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参数");
});
public Map<String,String> scadaResolve(Map<String,String> args) {
String params = args.get("canvas_id");
// 参数格式为: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"));
return this.resolve(params,SCADA_PARAMS_SOLVE);
}
public Map<String,String> resolve(String paramsStr,String... keys) {
Map<String,String> result = new HashMap<>();
List<String> params = Func.toStrList("\\^", paramsStr);
Assert.isTrue(params.size() == keys.length, () -> {
throw new ServiceException("大模型传参params长度错误,传参为:" + paramsStr);
});
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));
IntStream.iterate(0,index -> index + 1).limit(params.size()).forEach(index -> result.put(keys[index],params.get(index)));
return result;
}

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

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

@ -0,0 +1,73 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.hnac.hzims.bigmodel.entity.FunctionEntity;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/05/09 08:56
*/
@Component
@Slf4j
@AllArgsConstructor
@Deprecated
public class ParamStrategy {
private final IStationVideoTypeClient videoClient;
/**
* 解析发送参数方式函数
* @param function 函数
* @param args 大模型识别参数
* @return 前端传参EXTRA
*/
public ExtraVO resolve(FunctionEntity function, Map<String,String> args) {
FuncRouteEnum routeEnum = FuncRouteEnum.getEnumByFuncCode(function.getCode());
if(Func.isNotEmpty(routeEnum)) {
switch(routeEnum) {
case OPEN_VIDEO:
return this.getVideoExtra(args);
default:
break;
}
}
return null;
}
public ExtraVO getVideoExtra(Map<String,String> args) {
// 跳转页面逻辑
ExtraVO extraVO = new ExtraVO();
String id = args.get("canvas_id");
if(StringUtil.isNotBlank(id) && Func.isNotEmpty(id)) {
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.getFuncCode());
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;
}
}

36
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamsServiceImpl.java

@ -0,0 +1,36 @@
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.interactive.service.IParamsService;
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.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* @Author: huangxing
* @Date: 2024/05/09 08:51
*/
@Service
@Slf4j
@AllArgsConstructor
@Deprecated
public class ParamsServiceImpl implements IParamsService {
private final ParamStrategy strategy;
@Override
public String dealJumpTypeFunction(FunctionEntity function, Map<String, String> args) {
// 跳转页面逻辑
ExtraVO extraVO = strategy.resolve(function,args);
return JSON.toJSONString(extraVO);
}
}

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

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

@ -0,0 +1,75 @@
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.bigmodel.interactive.vo.ResolveResultVO;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
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.getFunctionArgs();
String id = args.get("id");
String name = args.get("name");
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.getFuncCode());
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;
}
}

25
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,6 +19,8 @@ import java.io.Serializable;
@Data
@ApiModel("HZLLM答案VO对象")
@EqualsAndHashCode
@AllArgsConstructor
@NoArgsConstructor
public class AnswerVO implements Serializable {
@ApiModelProperty("发起问答时的随机ID")
@ -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 id;
@ApiModelProperty("数据名称")
private String name;
}

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 = "id")
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;
}

34
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/manager/SessionRedisManager.java

@ -0,0 +1,34 @@
package com.hnac.hzims.bigmodel.manager;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.List;
import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMODEL_ASK_KEY;
/**
* @Author: huangxing
* @Date: 2024/06/21 18:23
*/
@Component
public class SessionRedisManager {
@Autowired
private RedisTemplate redisTemplate;
public void addSessionId(String sessionId) {
redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,sessionId);
}
public void removeSessionId(String sessionId) {
redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,sessionId);
}
public List<String> getSessionIds() {
return redisTemplate.opsForList().range(HZIMS_BIGMODEL_ASK_KEY, 0, -1);
}
}

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

@ -0,0 +1,88 @@
package com.hnac.hzims.bigmodel.schedule;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory;
import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService;
import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService;
import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService;
import com.hnac.hzims.bigmodel.interactive.service.IResolveService;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.manager.SessionRedisManager;
import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService;
import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.stream.Collectors;
import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.*;
/**
* @Author: huangxing
* @Date: 2024/06/24 09:53
*/
@Component
@AllArgsConstructor
@Slf4j
public class FrontEndInteractiveSchedule {
private final SessionRedisManager sessionRedisManager;
private final InteractiveWsService wsService;
private final ThreadPoolExecutor getAnswerPoolExecutor;
private final IHznlmInvokeService hznlmInvokeService;
private final BladeLogger logger;
@XxlJob(GET_INTERACTIVE_RESULT)
public ReturnT getInteractiveResult(String params) {
List<String> sessionIds = sessionRedisManager.getSessionIds();
if(CollectionUtil.isEmpty(sessionIds)){
XxlJobLogger.log("问题都已经回答完毕!");
return ReturnT.SUCCESS;
}
List<AnswerVO> answerList = hznlmInvokeService.getAnswerBySessionIds(String.join(",", sessionIds));
answerList.stream().parallel().forEach(answerVO -> CompletableFuture.runAsync(() -> {
// 如果已经获取到答案 则删除缓存
if(answerVO.getRunning() == 0) {
logger.info("hzims:bigmodel:getInteractiveResult:answer","获取大模型解析答案:" + JSON.toJSONString(answerVO));
sessionRedisManager.removeSessionId(answerVO.getSessionId());
}
Object[] extras = answerVO.getExtras();
if(ObjectUtil.isNotEmpty(answerVO.getExtras()) && extras.length > 0){
try {
// 解析答案
Object[] resolveExtras = Arrays.stream(extras).map(extra -> {
IAnswerResolveService answerResolveService = AnswerResolveFactory.getResolveService(extra);
if(Func.isNotEmpty(answerResolveService)) {
JSONObject extraObject = JSONObject.parseObject(JSON.toJSONString(extra));
return answerResolveService.getExtra(extraObject);
}
return extra;
}).map(JSON::toJSONString).toArray();
answerVO.setExtras(resolveExtras);
}
catch(Exception e) {
log.error("An error occurred",e);
AnswerVO.error(answerVO.getSessionId(), answerVO.getUserId(), answerVO.getQuery());
}
}
TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO));
wsService.sendMessage(answerVO.getSessionId(),message);
}, getAnswerPoolExecutor));
return ReturnT.SUCCESS;
}
}

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

Loading…
Cancel
Save