55 changed files with 1115 additions and 1018 deletions
			
			
		@ -0,0 +1,20 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.bigmodel.api.dto; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import io.swagger.annotations.ApiModel; | 
				
			||||||
 | 
					import lombok.Data; | 
				
			||||||
 | 
					import lombok.EqualsAndHashCode; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.Serializable; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: huangxing | 
				
			||||||
 | 
					 * @Date: 2024/07/09 19:48 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					@Data | 
				
			||||||
 | 
					@EqualsAndHashCode | 
				
			||||||
 | 
					@ApiModel(value = "实时画面同步DTO对象",description = "实时画面同步DTO对象") | 
				
			||||||
 | 
					public class CanvasSyncDTO extends SyncDTO implements Serializable { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,20 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.bigmodel.api.dto; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import io.swagger.annotations.ApiModel; | 
				
			||||||
 | 
					import lombok.Data; | 
				
			||||||
 | 
					import lombok.EqualsAndHashCode; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.Serializable; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: huangxing | 
				
			||||||
 | 
					 * @Date: 2024/07/09 19:51 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					@Data | 
				
			||||||
 | 
					@EqualsAndHashCode | 
				
			||||||
 | 
					@ApiModel(value = "遥控同步DTO对象",description = "遥控同步DTO对象") | 
				
			||||||
 | 
					public class ControlSyncDTO extends SyncDTO implements Serializable { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,50 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.bigmodel.api.dto; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.alibaba.fastjson.annotation.JSONField; | 
				
			||||||
 | 
					import io.swagger.annotations.ApiModel; | 
				
			||||||
 | 
					import io.swagger.annotations.ApiModelProperty; | 
				
			||||||
 | 
					import lombok.Data; | 
				
			||||||
 | 
					import lombok.EqualsAndHashCode; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.Serializable; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: huangxing | 
				
			||||||
 | 
					 * @Date: 2024/07/09 19:33 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					@Data | 
				
			||||||
 | 
					@EqualsAndHashCode | 
				
			||||||
 | 
					@ApiModel(value = "视频同步DTO",description = "视频同步DTO") | 
				
			||||||
 | 
					public class SyncDTO implements Serializable { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ApiModelProperty("数据ID") | 
				
			||||||
 | 
					    private String id; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ApiModelProperty("在问答流程中使用的数据ID") | 
				
			||||||
 | 
					    @JSONField(name = "item_id") | 
				
			||||||
 | 
					    private String itemId; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ApiModelProperty("用于匹配的名字。应包含所有匹配相关信息") | 
				
			||||||
 | 
					    @JSONField(name = "item_name") | 
				
			||||||
 | 
					    private String itemName; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ApiModelProperty("类型,可为'平台'或'业务'") | 
				
			||||||
 | 
					    private String type; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ApiModelProperty("站点I,平台yk必须有,否则可为null") | 
				
			||||||
 | 
					    @JSONField(name = "station_id") | 
				
			||||||
 | 
					    private String stationId; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ApiModelProperty("站点名称,平台yk必须有,否则可为null") | 
				
			||||||
 | 
					    @JSONField(name = "station_name") | 
				
			||||||
 | 
					    private String stationName; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ApiModelProperty("设备ID,平台yk必须有,否则可为null") | 
				
			||||||
 | 
					    @JSONField(name = "device_id") | 
				
			||||||
 | 
					    private String deviceId; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ApiModelProperty("设备名称,平台yk必须有,否则可为null") | 
				
			||||||
 | 
					    @JSONField(name = "device_name") | 
				
			||||||
 | 
					    private String deviceName; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,20 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.bigmodel.api.dto; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import io.swagger.annotations.ApiModel; | 
				
			||||||
 | 
					import lombok.Data; | 
				
			||||||
 | 
					import lombok.EqualsAndHashCode; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.Serializable; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: huangxing | 
				
			||||||
 | 
					 * @Date: 2024/07/09 19:42 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					@ApiModel(value = "视频同步DTO对象",description = "视频同步DTO对象") | 
				
			||||||
 | 
					@Data | 
				
			||||||
 | 
					@EqualsAndHashCode | 
				
			||||||
 | 
					public class VideoSyncDTO extends SyncDTO implements Serializable { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,12 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.bigmodel.api.feign; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.api.dto.CanvasSyncDTO; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: huangxing | 
				
			||||||
 | 
					 * @Date: 2024/07/09 19:53 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					public interface ICanvasSyncClient extends ISyncClient<CanvasSyncDTO> { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,11 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.bigmodel.api.feign; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.api.dto.ControlSyncDTO; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: huangxing | 
				
			||||||
 | 
					 * @Date: 2024/07/09 19:55 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					public interface IControlSyncClient extends ISyncClient<ControlSyncDTO> { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,40 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.bigmodel.api.feign; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.api.dto.SyncDTO; | 
				
			||||||
 | 
					import org.springblade.core.tool.api.R; | 
				
			||||||
 | 
					import org.springframework.web.bind.annotation.RequestBody; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: huangxing | 
				
			||||||
 | 
					 * @Date: 2024/07/09 19:32 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					public interface ISyncClient<T extends SyncDTO> { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    String SAVE_BATCH = "/saveBatch"; | 
				
			||||||
 | 
					    String UPDATE_BY_ID = "/updateById"; | 
				
			||||||
 | 
					    String DELETE_BY_IDS = "/deleteByIds"; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 同步 - 新增对象 | 
				
			||||||
 | 
					     * @param syncDTO 同步对象列表 | 
				
			||||||
 | 
					     * @return 同步结果 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    R saveBatch(List<T> syncDTO); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 同步 - 更新对象 | 
				
			||||||
 | 
					     * @param syncDTO 同步对象 | 
				
			||||||
 | 
					     * @return 同步结果 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    R updateById(T syncDTO); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 同步 - 删除对象 | 
				
			||||||
 | 
					     * @param ids 主键id按逗号分隔 | 
				
			||||||
 | 
					     * @return 删除结果 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    R deleteByIds(String ids); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,33 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.bigmodel.api.feign; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.BigModelConstants; | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.api.dto.SyncDTO; | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; | 
				
			||||||
 | 
					import org.springblade.core.tool.api.R; | 
				
			||||||
 | 
					import org.springframework.cloud.openfeign.FeignClient; | 
				
			||||||
 | 
					import org.springframework.web.bind.annotation.*; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: huangxing | 
				
			||||||
 | 
					 * @Date: 2024/07/09 19:31 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					@FeignClient(name = BigModelConstants.APP_NAME) | 
				
			||||||
 | 
					public interface IVideoSyncClient extends ISyncClient<VideoSyncDTO> { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    String PREFIX_API = "/feign/sync/video"; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override | 
				
			||||||
 | 
					    @PostMapping(PREFIX_API + SAVE_BATCH) | 
				
			||||||
 | 
					    R saveBatch(@RequestBody List<VideoSyncDTO> syncDTO); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override | 
				
			||||||
 | 
					    @PutMapping(PREFIX_API + UPDATE_BY_ID) | 
				
			||||||
 | 
					    R updateById(@RequestBody VideoSyncDTO syncDTO); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override | 
				
			||||||
 | 
					    @DeleteMapping(PREFIX_API + DELETE_BY_IDS) | 
				
			||||||
 | 
					    R deleteByIds(@RequestParam String ids); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,35 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.bigmodel.api.feign; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; | 
				
			||||||
 | 
					import lombok.AllArgsConstructor; | 
				
			||||||
 | 
					import org.springblade.core.tool.api.R; | 
				
			||||||
 | 
					import org.springframework.web.bind.annotation.*; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: huangxing | 
				
			||||||
 | 
					 * @Date: 2024/07/09 20:17 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					@RestController | 
				
			||||||
 | 
					@AllArgsConstructor | 
				
			||||||
 | 
					public class VideoSyncClient implements IVideoSyncClient{ | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override | 
				
			||||||
 | 
					    @PostMapping(PREFIX_API + SAVE_BATCH) | 
				
			||||||
 | 
					    public R saveBatch(@RequestBody List<VideoSyncDTO> syncDTO) { | 
				
			||||||
 | 
					        return null; | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override | 
				
			||||||
 | 
					    @PutMapping(PREFIX_API + UPDATE_BY_ID) | 
				
			||||||
 | 
					    public R updateById(@RequestBody VideoSyncDTO syncDTO) { | 
				
			||||||
 | 
					        return null; | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override | 
				
			||||||
 | 
					    @DeleteMapping(PREFIX_API + DELETE_BY_IDS) | 
				
			||||||
 | 
					    public R deleteByIds(@RequestParam String ids) { | 
				
			||||||
 | 
					        return null; | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,16 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.bigmodel.api.service; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import lombok.AllArgsConstructor; | 
				
			||||||
 | 
					import lombok.extern.slf4j.Slf4j; | 
				
			||||||
 | 
					import org.springframework.stereotype.Service; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: huangxing | 
				
			||||||
 | 
					 * @Date: 2024/07/10 09:03 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					@Service | 
				
			||||||
 | 
					@Slf4j | 
				
			||||||
 | 
					@AllArgsConstructor | 
				
			||||||
 | 
					public class SyncService { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -1,8 +1,8 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.datasource.controller; | 
					package com.hnac.hzims.bigmodel.business.control; | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; | 
					import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; | 
				
			||||||
import com.hnac.hzims.bigmodel.datasource.service.DataSourceService; | 
					import com.hnac.hzims.bigmodel.business.service.DataSourceService; | 
				
			||||||
import com.hnac.hzims.bigmodel.datasource.vo.SqlVO; | 
					import com.hnac.hzims.bigmodel.business.vo.SqlVO; | 
				
			||||||
import io.swagger.annotations.ApiOperation; | 
					import io.swagger.annotations.ApiOperation; | 
				
			||||||
import lombok.AllArgsConstructor; | 
					import lombok.AllArgsConstructor; | 
				
			||||||
import org.springblade.core.tool.api.R; | 
					import org.springblade.core.tool.api.R; | 
				
			||||||
@ -1,13 +1,12 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.data.controller; | 
					package com.hnac.hzims.bigmodel.business.control; | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; | 
					import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; | 
				
			||||||
import com.hnac.hzims.bigmodel.BigModelConstants; | 
					import com.hnac.hzims.bigmodel.BigModelConstants; | 
				
			||||||
import com.hnac.hzims.bigmodel.data.service.RemoteService; | 
					import com.hnac.hzims.bigmodel.business.service.RemoteService; | 
				
			||||||
import com.hnac.hzinfo.log.annotation.Business; | 
					import com.hnac.hzinfo.log.annotation.Business; | 
				
			||||||
import io.swagger.annotations.Api; | 
					import io.swagger.annotations.Api; | 
				
			||||||
import io.swagger.annotations.ApiOperation; | 
					import io.swagger.annotations.ApiOperation; | 
				
			||||||
import lombok.AllArgsConstructor; | 
					import lombok.AllArgsConstructor; | 
				
			||||||
import lombok.extern.slf4j.Slf4j; | 
					 | 
				
			||||||
import org.springblade.core.tool.api.R; | 
					import org.springblade.core.tool.api.R; | 
				
			||||||
import org.springblade.system.dto.ControlDTO; | 
					import org.springblade.system.dto.ControlDTO; | 
				
			||||||
import org.springframework.web.bind.annotation.PostMapping; | 
					import org.springframework.web.bind.annotation.PostMapping; | 
				
			||||||
@ -1,26 +1,19 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.datasource.service; | 
					package com.hnac.hzims.bigmodel.business.service; | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; | 
					import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; | 
				
			||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker; | 
					import com.hnac.hzims.bigmodel.business.vo.SqlVO; | 
				
			||||||
import com.google.common.collect.Lists; | 
					import com.hnac.hzims.bigmodel.business.vo.TableAuthVO; | 
				
			||||||
import com.hnac.hzims.bigmodel.datasource.vo.SqlVO; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.datasource.vo.TableAuthVO; | 
					 | 
				
			||||||
import com.hnac.hzims.common.service.UserAuthDataService; | 
					import com.hnac.hzims.common.service.UserAuthDataService; | 
				
			||||||
import lombok.AllArgsConstructor; | 
					import lombok.AllArgsConstructor; | 
				
			||||||
import lombok.extern.slf4j.Slf4j; | 
					import lombok.extern.slf4j.Slf4j; | 
				
			||||||
import org.springblade.core.log.exception.ServiceException; | 
					import org.springblade.core.log.exception.ServiceException; | 
				
			||||||
import org.springblade.core.tool.utils.CollectionUtil; | 
					 | 
				
			||||||
import org.springblade.core.tool.utils.StringUtil; | 
					 | 
				
			||||||
import org.springframework.jdbc.core.JdbcTemplate; | 
					import org.springframework.jdbc.core.JdbcTemplate; | 
				
			||||||
import org.springframework.stereotype.Service; | 
					import org.springframework.stereotype.Service; | 
				
			||||||
import org.springframework.util.Assert; | 
					import org.springframework.util.Assert; | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.HashMap; | 
					 | 
				
			||||||
import java.util.List; | 
					import java.util.List; | 
				
			||||||
import java.util.Map; | 
					import java.util.Map; | 
				
			||||||
import java.util.UUID; | 
					 | 
				
			||||||
import java.util.regex.Pattern; | 
					import java.util.regex.Pattern; | 
				
			||||||
import java.util.stream.Collectors; | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** | 
					/** | 
				
			||||||
 * @Author: huangxing | 
					 * @Author: huangxing | 
				
			||||||
@ -1,4 +1,4 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.data.service; | 
					package com.hnac.hzims.bigmodel.business.service; | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.alibaba.fastjson.JSON; | 
					import com.alibaba.fastjson.JSON; | 
				
			||||||
import com.google.common.collect.Lists; | 
					import com.google.common.collect.Lists; | 
				
			||||||
@ -1,4 +1,4 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.data.service; | 
					package com.hnac.hzims.bigmodel.business.service; | 
				
			||||||
 | 
					
 | 
				
			||||||
import lombok.AllArgsConstructor; | 
					import lombok.AllArgsConstructor; | 
				
			||||||
import lombok.extern.slf4j.Slf4j; | 
					import lombok.extern.slf4j.Slf4j; | 
				
			||||||
@ -1,4 +1,4 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.datasource.vo; | 
					package com.hnac.hzims.bigmodel.business.vo; | 
				
			||||||
 | 
					
 | 
				
			||||||
import io.swagger.annotations.ApiModel; | 
					import io.swagger.annotations.ApiModel; | 
				
			||||||
import io.swagger.annotations.ApiModelProperty; | 
					import io.swagger.annotations.ApiModelProperty; | 
				
			||||||
@ -1,4 +1,4 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.datasource.vo; | 
					package com.hnac.hzims.bigmodel.business.vo; | 
				
			||||||
 | 
					
 | 
				
			||||||
import io.swagger.annotations.ApiModel; | 
					import io.swagger.annotations.ApiModel; | 
				
			||||||
import io.swagger.annotations.ApiModelProperty; | 
					import io.swagger.annotations.ApiModelProperty; | 
				
			||||||
@ -1,73 +0,0 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.function.controller; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
					 | 
				
			||||||
import com.baomidou.mybatisplus.core.metadata.IPage; | 
					 | 
				
			||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.BigModelConstants; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.entity.FunctionEntity; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.function.service.IFunctionService; | 
					 | 
				
			||||||
import com.hnac.hzims.common.utils.Condition; | 
					 | 
				
			||||||
import com.hnac.hzinfo.log.annotation.Business; | 
					 | 
				
			||||||
import io.swagger.annotations.Api; | 
					 | 
				
			||||||
import io.swagger.annotations.ApiModel; | 
					 | 
				
			||||||
import io.swagger.annotations.ApiOperation; | 
					 | 
				
			||||||
import lombok.AllArgsConstructor; | 
					 | 
				
			||||||
import org.springblade.core.mp.support.Query; | 
					 | 
				
			||||||
import org.springblade.core.tool.api.R; | 
					 | 
				
			||||||
import org.springblade.core.tool.utils.BeanUtil; | 
					 | 
				
			||||||
import org.springblade.core.tool.utils.Func; | 
					 | 
				
			||||||
import org.springframework.validation.annotation.Validated; | 
					 | 
				
			||||||
import org.springframework.web.bind.annotation.*; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.List; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * @Author: huangxing | 
					 | 
				
			||||||
 * @Date: 2024/04/29 14:39 | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
@RestController | 
					 | 
				
			||||||
@RequestMapping("/function") | 
					 | 
				
			||||||
@Api(value = "大模型函数管理",tags = "大模型函数管理") | 
					 | 
				
			||||||
@Business(module = BigModelConstants.MODULE_NAME,value = "大模型函数管理") | 
					 | 
				
			||||||
@AllArgsConstructor | 
					 | 
				
			||||||
public class FunctionController { | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private final IFunctionService functionService; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @PostMapping("/save") | 
					 | 
				
			||||||
    @ApiOperation("保存函数") | 
					 | 
				
			||||||
    @ApiOperationSupport(order = 1) | 
					 | 
				
			||||||
    public R save(@RequestBody @Validated FunctionEntity req) { | 
					 | 
				
			||||||
        return R.status(functionService.save(req)); | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @PutMapping("/updateById") | 
					 | 
				
			||||||
    @ApiOperation("编辑函数") | 
					 | 
				
			||||||
    @ApiOperationSupport(order = 2) | 
					 | 
				
			||||||
    public R updateById(@RequestBody FunctionEntity req) { | 
					 | 
				
			||||||
        return R.status(functionService.save(req)); | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @GetMapping("/list") | 
					 | 
				
			||||||
    @ApiOperation("列表查询") | 
					 | 
				
			||||||
    @ApiOperationSupport(order = 3) | 
					 | 
				
			||||||
    public R<List<FunctionEntity>> list(FunctionEntity req) { | 
					 | 
				
			||||||
        return R.data(functionService.list(Condition.getQueryWrapper(BeanUtil.toMap(req),FunctionEntity.class))); | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @GetMapping("/page") | 
					 | 
				
			||||||
    @ApiOperation("分页查询") | 
					 | 
				
			||||||
    @ApiOperationSupport(order = 4) | 
					 | 
				
			||||||
    public R<IPage<FunctionEntity>> page(FunctionEntity req, Query query) { | 
					 | 
				
			||||||
        QueryWrapper<FunctionEntity> queryWrapper = Condition.getQueryWrapper(BeanUtil.toMap(req), FunctionEntity.class); | 
					 | 
				
			||||||
        return R.data(functionService.page(Condition.getPage(query),queryWrapper)); | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @DeleteMapping("/remove") | 
					 | 
				
			||||||
    @ApiOperation("删除函数") | 
					 | 
				
			||||||
    @ApiOperationSupport(order = 4) | 
					 | 
				
			||||||
    public R remove(String ids) { | 
					 | 
				
			||||||
        return R.data(functionService.removeByIds(Func.toLongList(",",ids))); | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,74 +0,0 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.function.controller; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
					 | 
				
			||||||
import com.baomidou.mybatisplus.core.metadata.IPage; | 
					 | 
				
			||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.BigModelConstants; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.entity.FuncParamEntity; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.entity.FunctionEntity; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.function.service.IFuncParamService; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.function.service.IFunctionService; | 
					 | 
				
			||||||
import com.hnac.hzims.common.utils.Condition; | 
					 | 
				
			||||||
import com.hnac.hzinfo.log.annotation.Business; | 
					 | 
				
			||||||
import io.swagger.annotations.Api; | 
					 | 
				
			||||||
import io.swagger.annotations.ApiOperation; | 
					 | 
				
			||||||
import lombok.AllArgsConstructor; | 
					 | 
				
			||||||
import org.springblade.core.mp.support.Query; | 
					 | 
				
			||||||
import org.springblade.core.tool.api.R; | 
					 | 
				
			||||||
import org.springblade.core.tool.utils.BeanUtil; | 
					 | 
				
			||||||
import org.springblade.core.tool.utils.Func; | 
					 | 
				
			||||||
import org.springframework.validation.annotation.Validated; | 
					 | 
				
			||||||
import org.springframework.web.bind.annotation.*; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.List; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * @Author: huangxing | 
					 | 
				
			||||||
 * @Date: 2024/04/29 15:46 | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
@RestController | 
					 | 
				
			||||||
@RequestMapping("/function/param") | 
					 | 
				
			||||||
@Api(value = "大模型函数参数管理",tags = "大模型函数参数管理") | 
					 | 
				
			||||||
@Business(module = BigModelConstants.MODULE_NAME,value = "大模型函数参数管理") | 
					 | 
				
			||||||
@AllArgsConstructor | 
					 | 
				
			||||||
public class FunctionParamController { | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private final IFuncParamService funcParamService; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @PostMapping("/save") | 
					 | 
				
			||||||
    @ApiOperation("保存函数参数") | 
					 | 
				
			||||||
    @ApiOperationSupport(order = 1) | 
					 | 
				
			||||||
    public R save(@RequestBody @Validated FuncParamEntity req) { | 
					 | 
				
			||||||
        return R.status(funcParamService.save(req)); | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @PutMapping("/save") | 
					 | 
				
			||||||
    @ApiOperation("编辑函数参数") | 
					 | 
				
			||||||
    @ApiOperationSupport(order = 2) | 
					 | 
				
			||||||
    public R updateById(@RequestBody FuncParamEntity req) { | 
					 | 
				
			||||||
        return R.status(funcParamService.save(req)); | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @GetMapping("/list") | 
					 | 
				
			||||||
    @ApiOperation("列表查询") | 
					 | 
				
			||||||
    @ApiOperationSupport(order = 3) | 
					 | 
				
			||||||
    public R<List<FuncParamEntity>> list(FuncParamEntity req) { | 
					 | 
				
			||||||
        return R.data(funcParamService.list(Condition.getQueryWrapper(BeanUtil.toMap(req),FuncParamEntity.class))); | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @GetMapping("/page") | 
					 | 
				
			||||||
    @ApiOperation("分页查询") | 
					 | 
				
			||||||
    @ApiOperationSupport(order = 4) | 
					 | 
				
			||||||
    public R<IPage<FuncParamEntity>> page(FuncParamEntity req, Query query) { | 
					 | 
				
			||||||
        QueryWrapper<FuncParamEntity> queryWrapper = Condition.getQueryWrapper(BeanUtil.toMap(req), FuncParamEntity.class); | 
					 | 
				
			||||||
        return R.data(funcParamService.page(Condition.getPage(query),queryWrapper)); | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @DeleteMapping("/remove") | 
					 | 
				
			||||||
    @ApiOperation("删除函数参数") | 
					 | 
				
			||||||
    @ApiOperationSupport(order = 4) | 
					 | 
				
			||||||
    public R remove(String ids) { | 
					 | 
				
			||||||
        return R.data(funcParamService.removeByIds(Func.toLongList(",",ids))); | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,11 +0,0 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.function.mapper; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.entity.FuncParamEntity; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * @Author: huangxing | 
					 | 
				
			||||||
 * @Date: 2024/04/26 11:11 | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public interface FuncParamMapper extends BaseMapper<FuncParamEntity> { | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,12 +0,0 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.function.mapper; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.entity.FunctionEntity; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * @Author: huangxing | 
					 | 
				
			||||||
 * @Date: 2024/04/26 11:10 | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public interface FunctionMapper extends BaseMapper<FunctionEntity> { | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,21 +0,0 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.function.service; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.entity.FuncParamEntity; | 
					 | 
				
			||||||
import org.springblade.core.mp.base.BaseService; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.List; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * @Author: huangxing | 
					 | 
				
			||||||
 * @Date: 2024/04/26 11:12 | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public interface IFuncParamService extends BaseService<FuncParamEntity> { | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * 根据函数ID获取参数列表 | 
					 | 
				
			||||||
     * @param funcId 函数ID | 
					 | 
				
			||||||
     * @return 参数列表 | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    List<FuncParamEntity> getParamsByFuncId(Long funcId); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,14 +0,0 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.function.service; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.entity.FunctionEntity; | 
					 | 
				
			||||||
import org.springblade.core.mp.base.BaseService; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * @Author: huangxing | 
					 | 
				
			||||||
 * @Date: 2024/04/26 11:08 | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public interface IFunctionService extends BaseService<FunctionEntity> { | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    FunctionEntity getFunctionByCode(String code); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,28 +0,0 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.function.service.impl; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
					 | 
				
			||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.entity.FuncParamEntity; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.function.mapper.FuncParamMapper; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.function.service.IFuncParamService; | 
					 | 
				
			||||||
import lombok.extern.slf4j.Slf4j; | 
					 | 
				
			||||||
import org.springblade.core.mp.base.BaseServiceImpl; | 
					 | 
				
			||||||
import org.springframework.stereotype.Service; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.List; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * @Author: huangxing | 
					 | 
				
			||||||
 * @Date: 2024/04/26 11:13 | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
@Service | 
					 | 
				
			||||||
@Slf4j | 
					 | 
				
			||||||
public class FuncParamServiceImpl extends BaseServiceImpl<FuncParamMapper, FuncParamEntity> implements IFuncParamService { | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override | 
					 | 
				
			||||||
    public List<FuncParamEntity> getParamsByFuncId(Long funcId) { | 
					 | 
				
			||||||
        LambdaQueryWrapper<FuncParamEntity> queryWrapper = Wrappers.<FuncParamEntity>lambdaQuery().eq(FuncParamEntity::getFuncId, funcId); | 
					 | 
				
			||||||
        return this.list(queryWrapper); | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,27 +0,0 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.function.service.impl; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
					 | 
				
			||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.entity.FunctionEntity; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.function.mapper.FunctionMapper; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.function.service.IFunctionService; | 
					 | 
				
			||||||
import lombok.AllArgsConstructor; | 
					 | 
				
			||||||
import lombok.extern.slf4j.Slf4j; | 
					 | 
				
			||||||
import org.springblade.core.mp.base.BaseServiceImpl; | 
					 | 
				
			||||||
import org.springframework.stereotype.Service; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * @Author: huangxing | 
					 | 
				
			||||||
 * @Date: 2024/04/26 11:09 | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
@Service | 
					 | 
				
			||||||
@Slf4j | 
					 | 
				
			||||||
@AllArgsConstructor | 
					 | 
				
			||||||
public class FunctionServiceImpl extends BaseServiceImpl<FunctionMapper, FunctionEntity> implements IFunctionService { | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override | 
					 | 
				
			||||||
    public FunctionEntity getFunctionByCode(String code) { | 
					 | 
				
			||||||
        LambdaQueryWrapper<FunctionEntity> queryWrapper = Wrappers.<FunctionEntity>lambdaQuery().eq(FunctionEntity::getCode, code); | 
					 | 
				
			||||||
        return this.getOne(queryWrapper); | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,58 +0,0 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.interactive.service; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; | 
					 | 
				
			||||||
import org.springblade.core.tool.api.R; | 
					 | 
				
			||||||
import org.springblade.system.dto.ControlDTO; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.List; | 
					 | 
				
			||||||
import java.util.Map; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * @Author: huangxing | 
					 | 
				
			||||||
 * @Date: 2024/04/26 14:51 | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
@Deprecated | 
					 | 
				
			||||||
public interface IInteractiveService { | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ExtraVO resolveStations(String startTime, String endTime, String type, String enumType); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    R resolve(ModelFunctionReq req); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    R ask(String question,String sessionId,String userId); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    R specialAsk(String sessionId,String userId,Map<String,Object> extra); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void updateVideo(Map<String,Object> request); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Boolean updateCanvas(Map<String,Object> request); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void updateFault(Map<String,Object> request); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    List<AnswerVO> getAnswerBySessionIds(String sessionIds); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Boolean authentication(String stationId, String userId, String func,String sessionId); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Boolean removeSessionId(String sessionId); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * 发起知识库问答 | 
					 | 
				
			||||||
     * @param question 问题 | 
					 | 
				
			||||||
     * @param sessionId 会话id | 
					 | 
				
			||||||
     * @param userId 用户id | 
					 | 
				
			||||||
     * @param knowledge 知识库名称 | 
					 | 
				
			||||||
     * @return 发起结果 | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    R knowledgeAsk(String question, String sessionId, String userId, String knowledge); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    R<Object> sendRemoteControl(ControlDTO operate); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Double generation(String stationId, String startTime, String endTime); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * 获取热点问题 | 
					 | 
				
			||||||
     * @return 热点问题 | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    List hotQuestions(); | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,17 +0,0 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.interactive.service; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.entity.FunctionEntity; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.Map; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * @Author: huangxing | 
					 | 
				
			||||||
 * @Date: 2024/04/26 11:46 | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
@Deprecated | 
					 | 
				
			||||||
public interface IJumpPageService { | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    String dealJumpTypeFunction(FunctionEntity function, Map<String,String> args); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,144 +0,0 @@ | 
				
			|||||||
package com.hnac.hzims.bigmodel.interactive.service.impl; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.alibaba.fastjson.JSONObject; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.entity.FunctionEntity; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; | 
					 | 
				
			||||||
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; | 
					 | 
				
			||||||
import com.hnac.hzims.operational.station.entity.StationEntity; | 
					 | 
				
			||||||
import com.hnac.hzims.operational.station.feign.IStationClient; | 
					 | 
				
			||||||
import lombok.RequiredArgsConstructor; | 
					 | 
				
			||||||
import org.springblade.core.log.exception.ServiceException; | 
					 | 
				
			||||||
import org.springblade.core.tool.api.R; | 
					 | 
				
			||||||
import org.springblade.core.tool.utils.Func; | 
					 | 
				
			||||||
import org.springblade.core.tool.utils.StringUtil; | 
					 | 
				
			||||||
import org.springframework.stereotype.Component; | 
					 | 
				
			||||||
import org.springframework.util.Assert; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.*; | 
					 | 
				
			||||||
import java.util.stream.IntStream; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * @Author: huangxing | 
					 | 
				
			||||||
 * @Date: 2024/04/30 11:38 | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
@Component | 
					 | 
				
			||||||
@RequiredArgsConstructor | 
					 | 
				
			||||||
@Deprecated | 
					 | 
				
			||||||
public class JumpRouteJoinStrategy { | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private final IStationClient stationClient; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public static String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"}; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * 解析大模型传参 | 
					 | 
				
			||||||
     * @param args 大模型传参 | 
					 | 
				
			||||||
     * @return 跳转path所需要的参数 | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    public ExtraVO resolve(FunctionEntity function,Map<String,String> args) { | 
					 | 
				
			||||||
        FuncRouteEnum routeEnum = FuncRouteEnum.getEnumByFuncCode(function.getCode()); | 
					 | 
				
			||||||
        if(Func.isNotEmpty(routeEnum)) { | 
					 | 
				
			||||||
            switch(routeEnum) { | 
					 | 
				
			||||||
                case OPEN_CANVAS: | 
					 | 
				
			||||||
                    return this.getScadaExtra(args,function); | 
					 | 
				
			||||||
                default: | 
					 | 
				
			||||||
                    break; | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
        return null; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public ExtraVO getScadaExtra(Map<String,String> args,FunctionEntity function) { | 
					 | 
				
			||||||
        // 跳转页面逻辑
 | 
					 | 
				
			||||||
        ExtraVO extraVO = new ExtraVO(); | 
					 | 
				
			||||||
        extraVO.setImmediatelyJump(true); | 
					 | 
				
			||||||
        extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFunc()); | 
					 | 
				
			||||||
        Map<String, String> params = this.scadaResolve(args); | 
					 | 
				
			||||||
        // 根据hz3000画面版本获取path
 | 
					 | 
				
			||||||
        Integer picResource = Integer.valueOf(params.get("picResource")); | 
					 | 
				
			||||||
        JSONObject pathObject = JSONObject.parseObject(function.getPath()); | 
					 | 
				
			||||||
        R<StationEntity> stationR = stationClient.getStationByCode(params.get("projectId")); | 
					 | 
				
			||||||
        extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + params.get("name")); | 
					 | 
				
			||||||
        Map<String,Object> extraParams = new HashMap<>(1); | 
					 | 
				
			||||||
        extraParams.put("picResource",picResource); | 
					 | 
				
			||||||
        extraVO.setParams(extraParams); | 
					 | 
				
			||||||
        // 云组态
 | 
					 | 
				
			||||||
        if(picResource == 0) { | 
					 | 
				
			||||||
            String scada = pathObject.getString("scada"); | 
					 | 
				
			||||||
            extraVO.setRoute(this.replacePath(scada, params)); | 
					 | 
				
			||||||
            extraVO.setRoute(scada); | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
        // v3.0
 | 
					 | 
				
			||||||
        else if (picResource == 1) { | 
					 | 
				
			||||||
            String v3 = pathObject.getString("v3"); | 
					 | 
				
			||||||
            extraVO.setRoute(this.replacePath(v3, params)); | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
        // v4.0
 | 
					 | 
				
			||||||
        else if (picResource == 2) { | 
					 | 
				
			||||||
            String v4 = pathObject.getString("v4"); | 
					 | 
				
			||||||
            // pic_name 去掉头部的/ 以及尾部的.js
 | 
					 | 
				
			||||||
            String context = params.get("context"); | 
					 | 
				
			||||||
            context = this.removeHeadChars(context,"/"); | 
					 | 
				
			||||||
            context = this.removeTailChars(context,".js"); | 
					 | 
				
			||||||
            params.put("context",context); | 
					 | 
				
			||||||
            extraVO.setRoute(this.replacePath(v4, params)); | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
        else { | 
					 | 
				
			||||||
            throw new ServiceException("解析出来的画面类型在云组态、v3、v4类型之外,无法解析路由"); | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
        extraVO.setType(FunctionConstants.TypeEnum.JUMP.getType()); | 
					 | 
				
			||||||
        return extraVO; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * 解析实时画面参数 | 
					 | 
				
			||||||
     * @param args 大模型解析参数 | 
					 | 
				
			||||||
     * @return 实时画面路径拼接所需参数 | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    public Map<String,String> scadaResolve(Map<String,String> args) { | 
					 | 
				
			||||||
        String params = args.get("canvas_id"); | 
					 | 
				
			||||||
        // 参数格式为:picResource^context^stationNum^projectId^taskId^name^id
 | 
					 | 
				
			||||||
        return this.resolve(params,SCADA_PARAMS_SOLVE); | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public Map<String,String> resolve(String paramsStr,String... keys) { | 
					 | 
				
			||||||
        Map<String,String> result = new HashMap<>(); | 
					 | 
				
			||||||
        List<String> params = Func.toStrList("\\^", paramsStr); | 
					 | 
				
			||||||
        Assert.isTrue(params.size() == keys.length, () -> { | 
					 | 
				
			||||||
            throw new ServiceException("大模型传参params长度错误,传参为:" + paramsStr); | 
					 | 
				
			||||||
        }); | 
					 | 
				
			||||||
        IntStream.iterate(0,index -> index + 1).limit(params.size()).forEach(index -> result.put(keys[index],params.get(index))); | 
					 | 
				
			||||||
        return result; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private String replacePath(String path,Map<String,String> params) { | 
					 | 
				
			||||||
        Set<Map.Entry<String, String>> entries = params.entrySet(); | 
					 | 
				
			||||||
        // 替换path中变量
 | 
					 | 
				
			||||||
        for (Map.Entry<String, String> entry : entries) { | 
					 | 
				
			||||||
            String replaceVariables = "{" + entry.getKey() + "}"; | 
					 | 
				
			||||||
            path = StringUtil.replace(path,replaceVariables,entry.getValue()); | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
        return path; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public String removeHeadChars(String str, String charsToRemove) { | 
					 | 
				
			||||||
        if (str == null || charsToRemove == null || charsToRemove.isEmpty()) { | 
					 | 
				
			||||||
            return str; | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
        while (str.startsWith(charsToRemove)) { | 
					 | 
				
			||||||
            str = str.substring(charsToRemove.length()); | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
        return str; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public String removeTailChars(String str, String charsToRemove) { | 
					 | 
				
			||||||
        if (str == null || charsToRemove == null || charsToRemove.isEmpty()) { | 
					 | 
				
			||||||
            return str; | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
        while (str.endsWith(charsToRemove)) { | 
					 | 
				
			||||||
            str = str.substring(0, str.length() - charsToRemove.length()); | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
        return str; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,73 +0,0 @@ | 
				
			|||||||
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.getFunc()); | 
					 | 
				
			||||||
                Map<String,Object> params = new HashMap<>(); | 
					 | 
				
			||||||
                params.put("name", video.getName()); | 
					 | 
				
			||||||
                params.put("videoHost", video.getVideoHost()); | 
					 | 
				
			||||||
                params.put("pointCode", video.getPointCode()); | 
					 | 
				
			||||||
                params.put("appKey", video.getAppKey()); | 
					 | 
				
			||||||
                params.put("appSecret", video.getAppSecret()); | 
					 | 
				
			||||||
                params.put("liveSourceAddress",video.getLiveSourceAddress()); | 
					 | 
				
			||||||
                extraVO.setParams(params); | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
        return extraVO; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -0,0 +1,106 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.bigmodel.question.dto; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.alibaba.fastjson.annotation.JSONField; | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.interactive.vo.SessionContentVO; | 
				
			||||||
 | 
					import lombok.Data; | 
				
			||||||
 | 
					import lombok.EqualsAndHashCode; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.Serializable; | 
				
			||||||
 | 
					import java.util.Map; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: huangxing | 
				
			||||||
 | 
					 * @Date: 2024/07/10 10:22 | 
				
			||||||
 | 
					 * @Describe: 接收前端发送消息 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					@Data | 
				
			||||||
 | 
					@EqualsAndHashCode | 
				
			||||||
 | 
					public class MessageDTO implements Serializable { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 消息类型 0-心跳消息 1-问题 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private String type; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 前端提出问题 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private String context; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 前端传参附带参数 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private SessionContentVO content; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 是否发起特殊问答 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private Boolean isSpecial; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 发起问题用户ID | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private String userId; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 知识库 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private String knowledge; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 会话ID | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private String chatId; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 选项 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private Object selection; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 大模型函数 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private String func; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 特殊问题参数 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private Map<String,Object> extra; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 是否允许大模型查询数据,默认为1 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @JSONField(name = "enable_record") | 
				
			||||||
 | 
					    private int enableRecord = 1; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 是否允许大模型发送指令,默认为1 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @JSONField(name = "enable_yk") | 
				
			||||||
 | 
					    private int enableControl = 1; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 是否允许大模型打开视频,默认为1 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @JSONField(name = "enable_video") | 
				
			||||||
 | 
					    private int enableVideo = 1; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 是否允许大模型打开画面,默认为1 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @JSONField(name = "enable_canvas") | 
				
			||||||
 | 
					    private int enableCanvas = 1; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 是否允许大模型诊断故障,默认为1 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @JSONField(name = "enable_fault") | 
				
			||||||
 | 
					    private int enableFault = 1; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 大模型默认的意图理解方式,可以为"default","yk"... | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @JSONField(name = "default") | 
				
			||||||
 | 
					    private String defaultMode; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,78 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.bigmodel.question.dto; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.alibaba.fastjson.annotation.JSONField; | 
				
			||||||
 | 
					import lombok.Data; | 
				
			||||||
 | 
					import lombok.EqualsAndHashCode; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.Serializable; | 
				
			||||||
 | 
					import java.util.Map; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: huangxing | 
				
			||||||
 | 
					 * @Date: 2024/07/10 10:27 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					@Data | 
				
			||||||
 | 
					@EqualsAndHashCode | 
				
			||||||
 | 
					public class QuestionDTO implements Serializable { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 随机ID,同一个用户的对话使用统一的ID | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @JSONField(name = "chat_id") | 
				
			||||||
 | 
					    private String chatId; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 用户ID,同一个随机ID只能对应一个用户ID | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @JSONField(name = "user_id") | 
				
			||||||
 | 
					    private String userId; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 用户的问题 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private String query; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 特殊提问内容 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private Map<String, Object> extra; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Object data; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 是否允许大模型查询数据,默认为 1 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @JSONField(name = "enable_record") | 
				
			||||||
 | 
					    private int enableRecord = 1; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 是否允许大模型发送指令,默认为 1 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @JSONField(name = "enable_yk") | 
				
			||||||
 | 
					    private int enableControl = 1; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 是否允许大模型打开视频,默认为 1 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @JSONField(name = "enable_video") | 
				
			||||||
 | 
					    private int enableVideo = 1; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 是否允许大模型打开画面,默认为 1 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @JSONField(name = "enable_canvas") | 
				
			||||||
 | 
					    private int enableCanvas = 1; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 是否允许大模型诊断故障,默认为 1 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @JSONField(name = "enable_fault") | 
				
			||||||
 | 
					    private int enableFault = 1; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 大模型默认的意图理解方式,可以为"default","yk"... | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @JSONField(name = "default") | 
				
			||||||
 | 
					    private String defaultMode; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,123 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.bigmodel.question.service; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.alibaba.fastjson.JSON; | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.interactive.service.IResolveService; | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.interactive.vo.ScadaSelectionVO; | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.interactive.vo.VideoSelectionVO; | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.question.dto.MessageDTO; | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.question.dto.QuestionDTO; | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; | 
				
			||||||
 | 
					import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; | 
				
			||||||
 | 
					import lombok.AllArgsConstructor; | 
				
			||||||
 | 
					import org.springblade.core.tool.utils.BeanUtil; | 
				
			||||||
 | 
					import org.springblade.core.tool.utils.Func; | 
				
			||||||
 | 
					import org.springblade.core.tool.utils.SpringUtil; | 
				
			||||||
 | 
					import org.springblade.core.tool.utils.StringUtil; | 
				
			||||||
 | 
					import org.springframework.stereotype.Service; | 
				
			||||||
 | 
					import org.springframework.web.socket.TextMessage; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: huangxing | 
				
			||||||
 | 
					 * @Date: 2024/07/10 11:03 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					@Service | 
				
			||||||
 | 
					@AllArgsConstructor | 
				
			||||||
 | 
					public class QuestionHandlerService { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final IHznlmInvokeService hznlmInvokeService; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 处理用户发起问题 | 
				
			||||||
 | 
					     * @param messageDTO 接收前端消息内容体 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    public void handleMessage(MessageDTO messageDTO) { | 
				
			||||||
 | 
					        // 将message转换为question
 | 
				
			||||||
 | 
					        QuestionDTO question = BeanUtil.copy(messageDTO,QuestionDTO.class); | 
				
			||||||
 | 
					        question.setQuery(messageDTO.getContext()); | 
				
			||||||
 | 
					        // 普通问答
 | 
				
			||||||
 | 
					        if(Func.isEmpty(messageDTO.getIsSpecial()) || !messageDTO.getIsSpecial()) { | 
				
			||||||
 | 
					            if (StringUtil.isNotBlank(messageDTO.getKnowledge())) { | 
				
			||||||
 | 
					                hznlmInvokeService.knowledgeAsk(question); | 
				
			||||||
 | 
					            } else { | 
				
			||||||
 | 
					                hznlmInvokeService.ask(question); | 
				
			||||||
 | 
					            } | 
				
			||||||
 | 
					        } else { | 
				
			||||||
 | 
					            FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode(messageDTO.getFunc()); | 
				
			||||||
 | 
					            switch (funcEnum) { | 
				
			||||||
 | 
					                case CHOOSE_STATION: | 
				
			||||||
 | 
					                case CHOOSE_YC: | 
				
			||||||
 | 
					                case CHOOSE_FAULT: | 
				
			||||||
 | 
					                case CHOOSE_YK: | 
				
			||||||
 | 
					                    question.setData(messageDTO.getSelection()); | 
				
			||||||
 | 
					                    hznlmInvokeService.specialAsk(question); | 
				
			||||||
 | 
					                    break; | 
				
			||||||
 | 
					                case CHOOSE_VIDEO: | 
				
			||||||
 | 
					                    this.handleVideoChoose(messageDTO); | 
				
			||||||
 | 
					                    break; | 
				
			||||||
 | 
					                case CHOOSE_CANVAS: | 
				
			||||||
 | 
					                    this.handleScadaChoose(messageDTO); | 
				
			||||||
 | 
					                    break; | 
				
			||||||
 | 
					                default: | 
				
			||||||
 | 
					                    break; | 
				
			||||||
 | 
					            } | 
				
			||||||
 | 
					        } | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void handleVideoChoose(MessageDTO messageDTO) { | 
				
			||||||
 | 
					        InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); | 
				
			||||||
 | 
					        try { | 
				
			||||||
 | 
					            VideoSelectionVO selection = (VideoSelectionVO) messageDTO.getSelection(); | 
				
			||||||
 | 
					            IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_VIDEO.getFunc()); | 
				
			||||||
 | 
					            String videoId = selection.getItemId(); | 
				
			||||||
 | 
					            ExtraVO videoExtras = resolveService.resolve(videoId); | 
				
			||||||
 | 
					            AnswerVO answerVO = new AnswerVO(); | 
				
			||||||
 | 
					            answerVO.setSessionId(messageDTO.getChatId()); | 
				
			||||||
 | 
					            answerVO.setQuery(selection.getItemName()); | 
				
			||||||
 | 
					            answerVO.setRunning(0); | 
				
			||||||
 | 
					            answerVO.setStatus(0); | 
				
			||||||
 | 
					            answerVO.setAnswer("已成功打开"+selection.getItemName()+"视频"); | 
				
			||||||
 | 
					            answerVO.setExtras(new Object[]{JSON.toJSONString(videoExtras)}); | 
				
			||||||
 | 
					            TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); | 
				
			||||||
 | 
					            wsService.sendMessage(messageDTO.getChatId(),textMessage); | 
				
			||||||
 | 
					        } | 
				
			||||||
 | 
					        catch (Exception e) { | 
				
			||||||
 | 
					            AnswerVO answerVO = new AnswerVO(); | 
				
			||||||
 | 
					            answerVO.setRunning(0); | 
				
			||||||
 | 
					            answerVO.setStatus(-2); | 
				
			||||||
 | 
					            answerVO.setAnswer("视频解析失败!"); | 
				
			||||||
 | 
					            TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); | 
				
			||||||
 | 
					            wsService.sendMessage(messageDTO.getChatId(),textMessage); | 
				
			||||||
 | 
					        } | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void handleScadaChoose(MessageDTO messageDTO) { | 
				
			||||||
 | 
					        InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); | 
				
			||||||
 | 
					        try { | 
				
			||||||
 | 
					            ScadaSelectionVO selection = (ScadaSelectionVO) messageDTO.getSelection(); | 
				
			||||||
 | 
					            IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_CANVAS.getFunc()); | 
				
			||||||
 | 
					            ExtraVO scadaExtra = resolveService.resolve(selection.getItemId()); | 
				
			||||||
 | 
					            AnswerVO answerVO = new AnswerVO(); | 
				
			||||||
 | 
					            answerVO.setSessionId(messageDTO.getChatId()); | 
				
			||||||
 | 
					            answerVO.setRunning(0); | 
				
			||||||
 | 
					            answerVO.setStatus(0); | 
				
			||||||
 | 
					            answerVO.setQuery(selection.getItemName()); | 
				
			||||||
 | 
					            answerVO.setAnswer("已成功打开"+selection.getItemName()+"实时画面"); | 
				
			||||||
 | 
					            answerVO.setExtras(new Object[]{JSON.toJSONString(scadaExtra)}); | 
				
			||||||
 | 
					            TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); | 
				
			||||||
 | 
					            wsService.sendMessage(messageDTO.getChatId(),textMessage); | 
				
			||||||
 | 
					        } | 
				
			||||||
 | 
					        catch (Exception e) { | 
				
			||||||
 | 
					            AnswerVO answerVO = new AnswerVO(); | 
				
			||||||
 | 
					            answerVO.setRunning(0); | 
				
			||||||
 | 
					            answerVO.setStatus(-2); | 
				
			||||||
 | 
					            answerVO.setAnswer("实时画面解析失败!"); | 
				
			||||||
 | 
					            TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); | 
				
			||||||
 | 
					            wsService.sendMessage(messageDTO.getChatId(),textMessage); | 
				
			||||||
 | 
					        } | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					} | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue