Browse Source
# Conflicts: # hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java # hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java # hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java # hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java # hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClient.java # hzims-service/hzims-big-model/pom.xml # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IJumpPageService.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpPageServiceImpl.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java # hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java # hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationVideoTypeClient.javazhongwei
yang_shj
4 months ago
88 changed files with 2196 additions and 1472 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(value = "ids") String ids); |
||||
|
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.hnac.hzims.bigmodel.business.dto; |
||||
|
||||
import com.hnac.hzims.bigmodel.interactive.dto.ControlDeviceDTO; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/09 09:43 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode |
||||
@ApiModel(value = "遥控设备鉴权DTO",description = "遥控设备鉴权DTO") |
||||
public class ControlDeviceAuthDTO extends ControlDeviceDTO implements Serializable { |
||||
|
||||
@ApiModelProperty("用户ID") |
||||
private String userId; |
||||
|
||||
} |
@ -0,0 +1,45 @@
|
||||
package com.hnac.hzims.bigmodel.business.feign; |
||||
|
||||
import com.hnac.hzims.bigmodel.business.dto.ControlDeviceAuthDTO; |
||||
import org.springblade.core.tool.api.R; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/09 09:11 |
||||
* 鉴权接口 - 业务实现 |
||||
*/ |
||||
public interface IAuthClient { |
||||
|
||||
/** |
||||
* 遥控鉴权 |
||||
* @param req 遥控信息 |
||||
* @return 鉴权结果 |
||||
*/ |
||||
R remoteAuth(ControlDeviceAuthDTO req); |
||||
|
||||
/** |
||||
* 站点鉴权 |
||||
* @param userId 用户ID |
||||
* @param stationId 站点ID |
||||
* @return 鉴权结果 |
||||
*/ |
||||
R stationAuth(String userId,String stationId); |
||||
|
||||
/** |
||||
* 机构鉴权 |
||||
* @param userId 用户ID |
||||
* @param deptId 站点ID |
||||
* @return 鉴权结果 |
||||
*/ |
||||
R deptAuth(String userId,String deptId); |
||||
|
||||
/** |
||||
* 获取用户权限数据 |
||||
* @param userId 用户ID |
||||
* @return 权限数据 |
||||
*/ |
||||
R<Map<String, String[]>> getAuthData(String userId); |
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.dto; |
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/08 09:20 |
||||
*/ |
||||
@ApiModel("设备控制DTO") |
||||
@Data |
||||
@EqualsAndHashCode |
||||
public class ControlDTO implements Serializable { |
||||
|
||||
@ApiModelProperty("用户ID") |
||||
@NotBlank |
||||
private String userId; |
||||
|
||||
@ApiModelProperty("会话ID") |
||||
@NotBlank |
||||
private String chatId; |
||||
|
||||
@ApiModelProperty("value目前有值、'大' '小' '最大' '最小' ‘开’ '关'") |
||||
private String value; |
||||
|
||||
@ApiModelProperty("遥控点位") |
||||
private List<ControlDeviceDTO> yks; |
||||
|
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.dto; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/08 16:22 |
||||
*/ |
||||
@Data |
||||
@ApiModel(value = "",description = "") |
||||
@EqualsAndHashCode |
||||
public class ControlDeviceDTO implements Serializable { |
||||
|
||||
@ApiModelProperty(value = "站点ID") |
||||
private String stationId; |
||||
|
||||
@ApiModelProperty(value = "设备ID") |
||||
@NotBlank |
||||
private String deviceId; |
||||
|
||||
@ApiModelProperty(value = "控制ID") |
||||
@NotBlank |
||||
private String itemId; |
||||
|
||||
@ApiModelProperty(value = "控制名称") |
||||
private String itemName; |
||||
|
||||
@ApiModelProperty(value = "遥控类型,平台、业务") |
||||
@NotBlank |
||||
private String type; |
||||
|
||||
} |
@ -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 { |
||||
|
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.hnac.hzims.bigmodel.business.control; |
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.hnac.hzims.bigmodel.business.service.DataSourceService; |
||||
import com.hnac.hzims.bigmodel.business.vo.SqlVO; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.validation.Valid; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/28 14:07 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/dataSource/execute") |
||||
@AllArgsConstructor |
||||
public class DataSourceExecuteController { |
||||
|
||||
private final DataSourceService dataSourceService; |
||||
|
||||
@PostMapping("/executeQuery") |
||||
@ApiOperation("执行大模型sql") |
||||
@ApiOperationSupport(order = 1) |
||||
public R<List<Map<String, Object>>> executeQuery(@RequestBody @Valid SqlVO sqlVO) { |
||||
return R.data(dataSourceService.queryListOnSpecificDataSource(sqlVO)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.hnac.hzims.bigmodel.business.control; |
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.hnac.hzims.bigmodel.BigModelConstants; |
||||
import com.hnac.hzims.bigmodel.business.service.RemoteService; |
||||
import com.hnac.hzinfo.log.annotation.Business; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.system.dto.ControlDTO; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/24 14:42 |
||||
*/ |
||||
@AllArgsConstructor |
||||
@RequestMapping("/remote") |
||||
@RestController |
||||
@Api(value = "数据平台遥控指令管理",tags = "数据平台遥控指令管理") |
||||
@Business(module = BigModelConstants.APP_NAME,value = "数据平台遥控指令管理") |
||||
public class RemoteController { |
||||
|
||||
private final RemoteService remoteService; |
||||
|
||||
@ApiOperation("下发遥控指令") |
||||
@ApiOperationSupport(order = 1) |
||||
@PostMapping("/sendRemoteControl") |
||||
public R<Object> sendRemoteControl(ControlDTO controlDTO) { |
||||
return remoteService.sendRemoteControl(controlDTO); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,87 @@
|
||||
package com.hnac.hzims.bigmodel.business.feign; |
||||
|
||||
import com.hnac.hzims.bigmodel.business.dto.ControlDeviceAuthDTO; |
||||
import com.hnac.hzims.bigmodel.business.service.AuthenticationService; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.StringUtil; |
||||
import org.springblade.system.dto.DeptStationDTO; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Optional; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/09 09:31 |
||||
*/ |
||||
@Component |
||||
@AllArgsConstructor |
||||
@Slf4j |
||||
public class AuthClient implements IAuthClient { |
||||
|
||||
private final AuthenticationService authenticationService; |
||||
|
||||
/** |
||||
* 设备控制鉴权 |
||||
* @param req 遥控信息 |
||||
* @return 鉴权结果 |
||||
*/ |
||||
@Override |
||||
public R remoteAuth(ControlDeviceAuthDTO req) { |
||||
// 若站点不为空 则对站点进行鉴权
|
||||
if(StringUtil.isNotBlank(req.getStationId())) { |
||||
if(!authenticationService.stationAuthentication(req.getStationId(), req.getUserId())) { |
||||
return R.fail("站点鉴权失败!"); |
||||
} |
||||
} |
||||
if("业务".equals(req.getType())) { |
||||
|
||||
} |
||||
return R.success("鉴权成功"); |
||||
} |
||||
|
||||
/** |
||||
* 站点鉴权 |
||||
* @param userId 用户ID |
||||
* @param stationId 站点ID |
||||
* @return 鉴权结果 |
||||
*/ |
||||
@Override |
||||
public R stationAuth(String userId, String stationId) { |
||||
return R.status(authenticationService.stationAuthentication(stationId,userId)); |
||||
} |
||||
|
||||
/** |
||||
* 机构鉴权 |
||||
* @param userId 用户ID |
||||
* @param deptId 站点ID |
||||
* @return 鉴权结果 |
||||
*/ |
||||
@Override |
||||
public R deptAuth(String userId, String deptId) { |
||||
List<DeptStationDTO> deptStationDTOList = authenticationService.getStationPermissionsById(userId); |
||||
boolean result = deptStationDTOList.stream().map(DeptStationDTO::getDeptId).anyMatch(d -> Long.valueOf(deptId).equals(d)); |
||||
return R.status(result); |
||||
} |
||||
|
||||
/** |
||||
* 获取用户权限数据 |
||||
* @param userId 用户ID |
||||
* @return 权限数据 - 站点、机构 |
||||
*/ |
||||
@Override |
||||
public R<Map<String,String[]>> getAuthData(String userId) { |
||||
Map<String,String[]> result = new HashMap<>(2); |
||||
List<DeptStationDTO> deptStationDTOList = authenticationService.getStationPermissionsById(userId); |
||||
String[] stationIds = deptStationDTOList.stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).toArray(String[]::new); |
||||
String[] deptIds = deptStationDTOList.stream().map(DeptStationDTO::getDeptId).map(String::valueOf).toArray(String[]::new); |
||||
result.put("stationids",stationIds); |
||||
result.put("projectids",deptIds); |
||||
return R.data(result); |
||||
} |
||||
} |
@ -0,0 +1,119 @@
|
||||
package com.hnac.hzims.bigmodel.business.service; |
||||
|
||||
import com.google.common.collect.Lists; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.ProjectRemoteTypeEnum; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.SessionContentVO; |
||||
import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; |
||||
import com.hnac.hzinfo.sdk.core.response.Result; |
||||
import com.hnac.hzinfo.sdk.v5.project.ProjectClient; |
||||
import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.CollectionUtil; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.core.tool.utils.StringUtil; |
||||
import org.springblade.system.dto.DeptStationDTO; |
||||
import org.springblade.system.entity.CtrlAuth; |
||||
import org.springblade.system.feign.IDeptClient; |
||||
import org.springblade.system.feign.IRemoteClient; |
||||
import org.springblade.system.user.feign.IUserClient; |
||||
import org.springframework.data.redis.core.RedisTemplate; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.util.Assert; |
||||
|
||||
import java.util.List; |
||||
import java.util.Optional; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/05/21 16:10 |
||||
*/ |
||||
@Service |
||||
@AllArgsConstructor |
||||
public class AuthenticationService { |
||||
|
||||
private final IDeptClient deptClient; |
||||
private final ProjectClient projectClient; |
||||
private final IRemoteClient remoteClient; |
||||
private final RedisTemplate redisTemplate; |
||||
|
||||
/** |
||||
* 站点鉴权 |
||||
* @param stationId 站点ID |
||||
* @param userId 用户ID |
||||
*/ |
||||
public Boolean stationAuthentication(String stationId, String userId) { |
||||
List<DeptStationDTO> deptStationDTOList = this.getStationPermissionsById(userId); |
||||
return deptStationDTOList.stream().map(DeptStationDTO::getStationId).anyMatch(stationId::equals); |
||||
} |
||||
|
||||
/** |
||||
* 菜单鉴权 |
||||
* @param userId 用户ID |
||||
* @param func 函数编号 |
||||
*/ |
||||
// public void menuAuthentication(String userId, String func) {
|
||||
// FunctionEntity function = functionService.getFunctionByCode(func);
|
||||
// if(Func.isNotEmpty(function) && Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) {
|
||||
// R<Boolean> authenticationR = userClient.permissionMenuById(Long.valueOf(userId), function.getRoute());
|
||||
// Assert.isTrue(authenticationR.isSuccess() && authenticationR.getData(), () -> {
|
||||
// throw new ServiceException("人员菜单鉴权失败!");
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
/** |
||||
* 遥控鉴权 |
||||
* @param stationId 站点ID |
||||
* @param userId 用户ID |
||||
*/ |
||||
public void remoteAuthentication(String stationId, String userId,String sessionId) { |
||||
// 查询数据平台站点是否可被遥控
|
||||
Result<List<ProjectVO>> projectR = projectClient.getProjectIds(Lists.newArrayList(stationId)); |
||||
Assert.isTrue(projectR.isSuccess() && CollectionUtil.isNotEmpty(projectR.getData()) && projectR.getData().size() == 1,() -> { |
||||
throw new ServiceException("未查询到站点,鉴权失败!"); |
||||
}); |
||||
ProjectVO project = projectR.getData().get(0); |
||||
if(ProjectRemoteTypeEnum.NOT_ALLOW.getCtrlType().equals(project.getCtrlType())) { |
||||
// 不允许发送遥控
|
||||
throw new ServiceException("该站点不允许发送遥控指令,校验失败!"); |
||||
} |
||||
else if(ProjectRemoteTypeEnum.VALID.getCtrlType().equals(project.getCtrlType())) { |
||||
// 运行发送遥控并且需要校验权限
|
||||
R<List<CtrlAuth>> ctrlAuthR = remoteClient.getCtrlAuth(Optional.ofNullable(userId).filter(StringUtil::isNotBlank).map(Long::parseLong).orElse(null)); |
||||
Assert.isTrue(ctrlAuthR.isSuccess(),() -> { |
||||
throw new ServiceException("该站点未设置鉴权用户,校验失败!"); |
||||
}); |
||||
List<CtrlAuth> ctrlAuthList = ctrlAuthR.getData(); |
||||
Optional<CtrlAuth> authOptional = ctrlAuthList.stream().filter(c -> c.getProjectId().equals(stationId)).findFirst(); |
||||
Assert.isTrue(authOptional.isPresent() && Func.isNotEmpty(authOptional.get().getIsLimitMachine()), () -> { |
||||
throw new ServiceException("该用户不存在相应站点权限,校验不通过!"); |
||||
}); |
||||
CtrlAuth ctrlAuth = authOptional.get(); |
||||
// 如限制机器发送遥控指令
|
||||
if(ctrlAuth.getIsLimitMachine() == 1) { |
||||
SessionContentVO sessionContent = (SessionContentVO) redisTemplate.opsForHash().get(RedisKeyConstants.SESSION_CONTENT_KEY, sessionId); |
||||
Assert.isTrue(Func.isNotEmpty(sessionContent),() -> { |
||||
throw new ServiceException("获取问题机器码失败,校验不通过!"); |
||||
}); |
||||
String machineCode = sessionContent.getMachineCode(); |
||||
Assert.isTrue(StringUtil.isNotBlank(machineCode) && Func.isNotEmpty(machineCode) ,() -> { |
||||
throw new ServiceException("获取问题机器码失败,校验不通过!"); |
||||
}); |
||||
Assert.isTrue(machineCode.equals(ctrlAuth.getMachineCode()),() -> { |
||||
throw new ServiceException("站点校验码校验失败,校验不通过!"); |
||||
}); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public List<DeptStationDTO> getStationPermissionsById(String userId) { |
||||
R<List<DeptStationDTO>> deptSattionR = deptClient.getStationPermissionsById(Long.valueOf(userId)); |
||||
Assert.isTrue(deptSattionR.isSuccess() && CollectionUtil.isNotEmpty(deptSattionR.getData()),() -> { |
||||
throw new ServiceException("获取人员站点权限失败!"); |
||||
}); |
||||
return deptSattionR.getData(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,121 @@
|
||||
package com.hnac.hzims.bigmodel.business.service; |
||||
|
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; |
||||
import com.hnac.hzims.bigmodel.business.vo.SqlVO; |
||||
import com.hnac.hzims.bigmodel.business.vo.TableAuthVO; |
||||
import com.hnac.hzims.common.service.UserAuthDataService; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springframework.jdbc.core.JdbcTemplate; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.util.Assert; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.regex.Pattern; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/28 15:24 |
||||
*/ |
||||
@Service |
||||
@AllArgsConstructor |
||||
@Slf4j |
||||
public class DataSourceService { |
||||
|
||||
private final JdbcTemplate jdbcTemplate; |
||||
private final UserAuthDataService userAuthDataService; |
||||
|
||||
private static final Pattern UPDATE_PATTERN = Pattern.compile("^UPDATE\\s", Pattern.CASE_INSENSITIVE); |
||||
private static final Pattern DELETE_PATTERN = Pattern.compile("^DELETE\\s", Pattern.CASE_INSENSITIVE); |
||||
|
||||
|
||||
public List<Map<String, Object>> queryListOnSpecificDataSource(SqlVO sqlVO) { |
||||
// 过滤更新、删除语句
|
||||
Assert.isTrue(!DataSourceService.isUpdateOrDelete(sqlVO.getSql()),() -> { |
||||
throw new ServiceException("执行sql语句包含更新/删除操作,执行失败!"); |
||||
}); |
||||
String sql = sqlVO.getSql(); |
||||
String userAuthDataSQL = userAuthDataService.getUserAuthDataSQL(Long.parseLong(sqlVO.getUserId())); |
||||
for (TableAuthVO tableAuthVO : sqlVO.getTableAuthVOList()) { |
||||
String tableSubStr = "(SELECT * FROM " + tableAuthVO.getTableName() + " where" + userAuthDataSQL +") temp"; |
||||
sql = sql.replace(tableAuthVO.getTableName(),tableSubStr); |
||||
} |
||||
log.info("执行sql:{}",sql); |
||||
return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName()); |
||||
// 过滤更新、删除语句
|
||||
// Assert.isTrue(!DataSourceService.isUpdateOrDelete(sqlVO.getSql()),() -> {
|
||||
// throw new ServiceException("执行sql语句包含更新/删除操作,执行失败!");
|
||||
// });
|
||||
// String sql = sqlVO.getSql();
|
||||
// String userAuthDataSQL = userAuthDataService.getUserAuthDataSQL(Long.parseLong(sqlVO.getUserId()));
|
||||
// List<Map<String,String>> tempViewList = Lists.newArrayList();
|
||||
// try {
|
||||
// for (TableAuthVO tableAuthVO : sqlVO.getTableAuthVOList()) {
|
||||
// // 创建视图语句
|
||||
// String viewName = "V_TEMP_" + UUID.randomUUID().toString().replace("-", "");
|
||||
// String createView = "CREATE VIEW " + viewName + " AS SELECT * FROM " + tableAuthVO.getTableName() + " where " + userAuthDataSQL;
|
||||
// this.updateOnSpecificDataSource(createView,tableAuthVO.getDatasourceName());
|
||||
// Map<String,String> viewMap = new HashMap(2);
|
||||
// viewMap.put("datasource",tableAuthVO.getDatasourceName());
|
||||
// viewMap.put("viewName",viewName);
|
||||
// tempViewList.add(viewMap);
|
||||
// sql = sql.replace(tableAuthVO.getTableName(),viewName);
|
||||
// }
|
||||
// log.info("执行sql:{}",sql);
|
||||
// return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName());
|
||||
// }
|
||||
// catch(Exception e) {
|
||||
// log.error("An Error occurred!",e);
|
||||
// throw new ServiceException("sql执行失败!");
|
||||
// }
|
||||
// finally {
|
||||
// if(CollectionUtil.isNotEmpty(tempViewList)) {
|
||||
// tempViewList.forEach(viewMap -> {
|
||||
// this.updateOnSpecificDataSource("DROP VIEW IF EXISTS `" + viewMap.get("viewName")+"`;",viewMap.get("datasource"));
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
} |
||||
|
||||
/** |
||||
* sql |
||||
* @param sql |
||||
* @param dataSourceName |
||||
* @return |
||||
*/ |
||||
public List<Map<String, Object>> queryListOnSpecificDataSource(String sql,String dataSourceName) { |
||||
// 切换到指定的数据源
|
||||
DynamicDataSourceContextHolder.push(dataSourceName); |
||||
try { |
||||
return jdbcTemplate.queryForList(sql); |
||||
} finally { |
||||
// 清除,恢复默认数据源
|
||||
DynamicDataSourceContextHolder.clear(); |
||||
} |
||||
} |
||||
|
||||
public Integer updateOnSpecificDataSource(String sql,String dataSourceName) { |
||||
// 切换到指定的数据源
|
||||
DynamicDataSourceContextHolder.push(dataSourceName); |
||||
try { |
||||
return jdbcTemplate.update(sql); |
||||
} finally { |
||||
// 清除,恢复默认数据源
|
||||
DynamicDataSourceContextHolder.clear(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 过滤更新、删除语法的sql脚本 |
||||
* @param sql 待执行sql脚本 |
||||
* @return 执行结果 |
||||
*/ |
||||
public static boolean isUpdateOrDelete(String sql) { |
||||
if (sql == null) { |
||||
return false; |
||||
} |
||||
return UPDATE_PATTERN.matcher(sql).find() || DELETE_PATTERN.matcher(sql).find(); |
||||
} |
||||
} |
@ -0,0 +1,97 @@
|
||||
package com.hnac.hzims.bigmodel.business.service; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.google.common.collect.Lists; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.DataMethodEnum; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.DateEnum; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO; |
||||
import com.hnac.hzinfo.sdk.core.response.Result; |
||||
import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; |
||||
import com.hnac.hzinfo.sdk.v5.device.dto.ReductionAttrDataDTO; |
||||
import com.hnac.hzinfo.sdk.v5.device.dto.ReductionDataDTO; |
||||
import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
//import org.springblade.core.log.logger.BladeLogger;
|
||||
import org.springblade.core.tool.utils.DateUtil; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.util.Assert; |
||||
|
||||
import java.time.Duration; |
||||
import java.time.LocalDateTime; |
||||
import java.time.temporal.ChronoUnit; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/24 14:57 |
||||
*/ |
||||
@Service |
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
public class HistoryDataService { |
||||
|
||||
private final DeviceDataClient deviceDataClient; |
||||
//private final BladeLogger logger;
|
||||
public static final int DATA_COUNT_MAX = 1000; |
||||
|
||||
public Result<ReductionDataVO> getPolymerizationData(HistoryDataSearchVO searchVO) { |
||||
DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); |
||||
Assert.isTrue(Func.isNotEmpty(enumByMethod),() -> { |
||||
throw new ServiceException("数据查询聚合方式传参有误,查询失败!"); |
||||
}); |
||||
// 聚合数据方式处理
|
||||
DateEnum dateEnum = DateEnum.getDateEnumByType(searchVO.getDataType()); |
||||
ReductionDataDTO dataDTO = new ReductionDataDTO(); |
||||
ReductionAttrDataDTO reductionAttrData = new ReductionAttrDataDTO(); |
||||
reductionAttrData.setSignage(searchVO.getSignage()); |
||||
reductionAttrData.setAccessRules(enumByMethod.getAccessRule()); |
||||
reductionAttrData.setKeepFigures(2); |
||||
dataDTO.setBeginTime(LocalDateTime.parse(searchVO.getStartTime(), DateUtil.DATETIME_FORMATTER)); |
||||
dataDTO.setEndTime(LocalDateTime.parse(searchVO.getEndTime(),DateUtil.DATETIME_FORMATTER)); |
||||
dataDTO.setDeviceCode(searchVO.getDeviceCode()); |
||||
dataDTO.setNeedPage(false); |
||||
dataDTO.setSaveTimeType(dateEnum.getSaveTimeType()); |
||||
dataDTO.setTimeInterval(1); |
||||
dataDTO.setDtos(Lists.newArrayList(reductionAttrData)); |
||||
//logger.info("interactive:getPolymerizationData","config传参为:" + JSON.toJSONString(dataDTO));
|
||||
return deviceDataClient.pageDeviceCodeAndSignages(dataDTO); |
||||
} |
||||
|
||||
public DateEnum getDateEnumByDuration(String startTime,String endTime,DateEnum dateEnum) { |
||||
LocalDateTime start = LocalDateTime.parse(startTime, DateUtil.DATETIME_FORMATTER); |
||||
LocalDateTime end = LocalDateTime.parse(endTime, DateUtil.DATETIME_FORMATTER); |
||||
Duration duration = Duration.between(start, end); |
||||
int count; |
||||
switch(dateEnum) { |
||||
case YEAR: |
||||
count = Long.valueOf(ChronoUnit.YEARS.between(start.toLocalDate(), end.toLocalDate())).intValue(); |
||||
break; |
||||
case MONTH: |
||||
count = Long.valueOf(ChronoUnit.MONTHS.between(start.toLocalDate(), end.toLocalDate())).intValue(); |
||||
break; |
||||
case DAY: |
||||
count = Long.valueOf(ChronoUnit.DAYS.between(start.toLocalDate(), end.toLocalDate())).intValue(); |
||||
break; |
||||
case HOUR: |
||||
count = Long.valueOf(duration.toHours()).intValue(); |
||||
break; |
||||
case MINUTE: |
||||
count = Long.valueOf(duration.toMinutes()).intValue(); |
||||
break; |
||||
case SECOND: |
||||
count = Long.valueOf(duration.getSeconds()).intValue(); |
||||
break; |
||||
default: |
||||
throw new ServiceException("未找到相关时间类型,查询失败!"); |
||||
} |
||||
if(count <= DATA_COUNT_MAX) { |
||||
return dateEnum; |
||||
} |
||||
else { |
||||
return getDateEnumByDuration(startTime, endTime, DateEnum.getDateEnumByOrder(dateEnum.getOrder() + 1)); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.hnac.hzims.bigmodel.business.service; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.system.dto.ControlDTO; |
||||
import org.springblade.system.feign.IRemoteClient; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/24 14:36 |
||||
* @Descirbe: 数据平台 - 遥控服务类 |
||||
*/ |
||||
@Service |
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
public class RemoteService { |
||||
|
||||
private final IRemoteClient remoteClient; |
||||
|
||||
/** |
||||
* 发送遥控指令 |
||||
* @param controlDTO 遥控指令 |
||||
* @return 结果 |
||||
*/ |
||||
public R<Object> sendRemoteControl(ControlDTO controlDTO) { |
||||
return remoteClient.sendCtrl(controlDTO); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.hnac.hzims.bigmodel.business.vo; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/05 08:19 |
||||
*/ |
||||
@ApiModel(value = "",description = "") |
||||
@Data |
||||
@EqualsAndHashCode |
||||
public class SqlVO implements Serializable { |
||||
|
||||
@ApiModelProperty("执行sql") |
||||
@NotBlank |
||||
private String sql; |
||||
|
||||
@ApiModelProperty("执行人") |
||||
@NotBlank |
||||
private String userId; |
||||
|
||||
@ApiModelProperty("执行sql设计表信息") |
||||
private List<TableAuthVO> tableAuthVOList; |
||||
|
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.hnac.hzims.bigmodel.business.vo; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/04 17:29 |
||||
*/ |
||||
@ApiModel(value = "表鉴权对象",description = "表鉴权对象") |
||||
@Data |
||||
@EqualsAndHashCode |
||||
public class TableAuthVO implements Serializable { |
||||
|
||||
@ApiModelProperty("鉴权类型,目前不为空即为平台数据权限") |
||||
private String auth; |
||||
|
||||
@ApiModelProperty("数据源名称") |
||||
private String datasourceName; |
||||
|
||||
@ApiModelProperty("数据表名称") |
||||
private String tableName; |
||||
|
||||
} |
@ -0,0 +1,27 @@
|
||||
package com.hnac.hzims.bigmodel.configuration; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.CommandLineRunner; |
||||
import org.springframework.data.redis.core.RedisTemplate; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMODEL_ASK_KEY; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/12 09:23 |
||||
*/ |
||||
@Component |
||||
@Slf4j |
||||
public class RedisKeyDeleter implements CommandLineRunner { |
||||
@Autowired |
||||
private RedisTemplate<String, Object> redisTemplate; |
||||
|
||||
@Override |
||||
public void run(String... args) throws Exception { |
||||
// 删除指定的Redis key
|
||||
redisTemplate.delete(HZIMS_BIGMODEL_ASK_KEY); |
||||
log.info("服务重启删除问题reids缓存:{}",HZIMS_BIGMODEL_ASK_KEY); |
||||
} |
||||
} |
@ -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,22 +0,0 @@
|
||||
package com.hnac.hzims.bigmodel.function.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.hnac.hzims.bigmodel.entity.FuncParamEntity; |
||||
|
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/04/26 11:12 |
||||
*/ |
||||
public interface IFuncParamService extends IService<FuncParamEntity> { |
||||
|
||||
/** |
||||
* 根据函数ID获取参数列表 |
||||
* @param funcId 函数ID |
||||
* @return 参数列表 |
||||
*/ |
||||
List<FuncParamEntity> getParamsByFuncId(Long funcId); |
||||
|
||||
} |
@ -1,15 +0,0 @@
|
||||
package com.hnac.hzims.bigmodel.function.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.hnac.hzims.bigmodel.entity.FunctionEntity; |
||||
|
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/04/26 11:08 |
||||
*/ |
||||
public interface IFunctionService extends IService<FunctionEntity> { |
||||
|
||||
FunctionEntity getFunctionByCode(String code); |
||||
|
||||
} |
@ -1,28 +0,0 @@
|
||||
package com.hnac.hzims.bigmodel.function.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.hnac.hzims.bigmodel.entity.FuncParamEntity; |
||||
import com.hnac.hzims.bigmodel.function.mapper.FuncParamMapper; |
||||
import com.hnac.hzims.bigmodel.function.service.IFuncParamService; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/04/26 11:13 |
||||
*/ |
||||
@Service |
||||
@Slf4j |
||||
public class FuncParamServiceImpl extends ServiceImpl<FuncParamMapper, FuncParamEntity> implements IFuncParamService { |
||||
|
||||
@Override |
||||
public List<FuncParamEntity> getParamsByFuncId(Long funcId) { |
||||
LambdaQueryWrapper<FuncParamEntity> queryWrapper = Wrappers.<FuncParamEntity>lambdaQuery().eq(FuncParamEntity::getFuncId, funcId); |
||||
return this.list(queryWrapper); |
||||
} |
||||
|
||||
} |
@ -1,27 +0,0 @@
|
||||
package com.hnac.hzims.bigmodel.function.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.hnac.hzims.bigmodel.entity.FunctionEntity; |
||||
import com.hnac.hzims.bigmodel.function.mapper.FunctionMapper; |
||||
import com.hnac.hzims.bigmodel.function.service.IFunctionService; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/04/26 11:09 |
||||
*/ |
||||
@Service |
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
public class FunctionServiceImpl extends ServiceImpl<FunctionMapper, FunctionEntity> implements IFunctionService { |
||||
|
||||
@Override |
||||
public FunctionEntity getFunctionByCode(String code) { |
||||
LambdaQueryWrapper<FunctionEntity> queryWrapper = Wrappers.<FunctionEntity>lambdaQuery().eq(FunctionEntity::getCode, code); |
||||
return this.getOne(queryWrapper); |
||||
} |
||||
} |
@ -1,116 +0,0 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.google.common.collect.Lists; |
||||
import com.hnac.hzims.bigmodel.BigModelConstants; |
||||
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.StationSearchVO; |
||||
import com.hnac.hzinfo.log.annotation.Business; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.system.dto.ControlDTO; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.text.DecimalFormat; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/04/26 14:51 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@Api(value = "FDP大模型交互层",tags = "FDP大模型交互层") |
||||
@RequestMapping("/interactive") |
||||
@Business(module = BigModelConstants.MODULE_NAME,value = "FDP大模型交互层") |
||||
@Deprecated |
||||
public class InteractiveController { |
||||
|
||||
private final IInteractiveService interactiveService; |
||||
|
||||
@ApiOperation("解析大模型函数") |
||||
@ApiOperationSupport(order = 1) |
||||
@PostMapping("/resolve") |
||||
public R resolve(@RequestBody ModelFunctionReq req) { |
||||
return interactiveService.resolve(req); |
||||
} |
||||
|
||||
@ApiOperation("提问") |
||||
@ApiOperationSupport(order = 2) |
||||
@GetMapping("/ask") |
||||
@Deprecated |
||||
public R ask(@RequestParam @ApiParam("用户提出问题") String question,@RequestParam @ApiParam("问答sessionId") String sessionId,@RequestParam @ApiParam("用户Id") String userId) { |
||||
return interactiveService.ask(question, sessionId, userId); |
||||
} |
||||
|
||||
@ApiOperation("站点、菜单鉴权") |
||||
@ApiOperationSupport(order = 3) |
||||
@Deprecated |
||||
@RequestMapping(value = "/authentication",method = {RequestMethod.GET,RequestMethod.POST}) |
||||
public R authentication(@RequestParam(required = false) @ApiParam("站点编号") String stationId, |
||||
@RequestParam @ApiParam("用户ID") String userId, |
||||
@RequestParam(required = false) @ApiParam("菜单ID") String func, |
||||
@RequestParam(required = false) @ApiParam("会话ID")String askId) { |
||||
return R.status(interactiveService.authentication(stationId,userId,func,askId)); |
||||
} |
||||
|
||||
@ApiOperation("获取问答sessionId") |
||||
@ApiOperationSupport(order = 4) |
||||
@GetMapping("/getSessionId") |
||||
public R<String> getSessionId() { |
||||
return R.data(IdWorker.get32UUID()); |
||||
} |
||||
|
||||
@ApiOperation("删除对话sessionId") |
||||
@ApiOperationSupport(order = 5) |
||||
@GetMapping("/removeSessionId") |
||||
@Deprecated |
||||
public R<Boolean> removeSessionId(@RequestParam(value = "id") String sessionId) { |
||||
return R.data(interactiveService.removeSessionId(sessionId)); |
||||
} |
||||
|
||||
@ApiOperation("下发遥控指令") |
||||
@ApiOperationSupport(order = 6) |
||||
@PostMapping("/sendRemoteControl") |
||||
public R sendRemoteControl(@RequestBody ControlDTO operate) { |
||||
return interactiveService.sendRemoteControl(operate); |
||||
} |
||||
|
||||
@ApiOperation("解析接入站点数量") |
||||
@ApiOperationSupport(order = 7) |
||||
@PostMapping("/resolveStations") |
||||
public R resolveStations(@RequestBody StationSearchVO req) { |
||||
return R.data(interactiveService.resolveStations(req.getStartTime(),req.getEndTime(),req.getType(),req.getEnumType())); |
||||
} |
||||
|
||||
@ApiOperation("站点发电量") |
||||
@ApiOperationSupport(order = 7) |
||||
@RequestMapping(value = "/generation",method = {RequestMethod.GET,RequestMethod.POST}) |
||||
public R generation(@RequestParam @ApiParam("站点编号") String stationId, |
||||
@RequestParam @ApiParam("开始时间") String startTime, |
||||
@RequestParam @ApiParam("结束时间")String endTime) { |
||||
double generate = interactiveService.generation(stationId,startTime,endTime); |
||||
DecimalFormat format = new DecimalFormat("0.00"); |
||||
return R.data(format.format(generate) + "kWh"); |
||||
} |
||||
|
||||
@ApiOperation("获取热点问题") |
||||
@ApiOperationSupport(order = 8) |
||||
@GetMapping("/hotQuestions") |
||||
@Deprecated |
||||
public R hotQuestions() { |
||||
try{ |
||||
List questions = interactiveService.hotQuestions(); |
||||
return R.data(questions); |
||||
} |
||||
catch (Exception e) { |
||||
e.printStackTrace(); |
||||
return R.data(Lists.newArrayList()); |
||||
} |
||||
} |
||||
} |
@ -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,430 +0,0 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service.impl; |
||||
|
||||
import cn.hutool.http.HttpRequest; |
||||
import cn.hutool.http.HttpResponse; |
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
||||
import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl; |
||||
import com.hnac.hzims.bigmodel.entity.FunctionEntity; |
||||
import com.hnac.hzims.bigmodel.function.service.IFunctionService; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.SearchStationTypeEnum; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.SearchTypeEnum; |
||||
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IParamsService; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; |
||||
import com.hnac.hzims.operational.station.entity.StationEntity; |
||||
import com.hnac.hzims.operational.station.feign.IStationClient; |
||||
import com.hnac.hzims.equipment.feign.IEmInfoClient; |
||||
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
||||
import com.hnac.hzims.equipment.vo.RideDeviceVo; |
||||
import com.hnac.hzims.operational.fill.feign.IGenerateClient; |
||||
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
||||
import com.hnac.hzims.operational.station.entity.StationEntity; |
||||
import com.hnac.hzims.operational.station.feign.IStationClient; |
||||
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; |
||||
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; |
||||
import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; |
||||
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; |
||||
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; |
||||
import com.xxl.job.core.log.XxlJobLogger; |
||||
import lombok.RequiredArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.poi.ss.formula.functions.T; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.log.logger.BladeLogger; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.*; |
||||
import org.springblade.system.dto.ControlDTO; |
||||
import org.springblade.system.dto.DeptStationDTO; |
||||
import org.springblade.system.feign.IDeptClient; |
||||
import org.springblade.system.feign.IRemoteClient; |
||||
import org.springblade.system.user.feign.IUserClient; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.data.redis.core.RedisTemplate; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.util.Assert; |
||||
import org.springframework.util.StringUtils; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.time.LocalDateTime; |
||||
import java.time.format.DateTimeFormatter; |
||||
import java.util.*; |
||||
import java.util.concurrent.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.TypeEnum; |
||||
import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMODEL_ASK_KEY; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/04/26 14:51 |
||||
*/ |
||||
@Service |
||||
@Slf4j |
||||
@RequiredArgsConstructor |
||||
@Deprecated |
||||
public class InteractiveServiceImpl implements IInteractiveService { |
||||
|
||||
private final BladeLogger logger; |
||||
|
||||
private final IEmInfoClient deviceClient; |
||||
|
||||
private final IRemoteClient remoteClient; |
||||
|
||||
private final IStationClient stationClient; |
||||
|
||||
private final IGenerateClient generateClient; |
||||
|
||||
private final IJumpPageService jumpPageService; |
||||
|
||||
private final IParamsService paramsService; |
||||
|
||||
private final IFunctionService functionService; |
||||
|
||||
private final BigModelInvokeUrl bigModelInvokeUrl; |
||||
|
||||
private final AuthenticationService authenticationService; |
||||
|
||||
private final RedisTemplate redisTemplate; |
||||
|
||||
private final IAnalyseDataSearchClient analyseDataSearchClient; |
||||
|
||||
private final ExtraResolveStrategyService extraResolveStrategyService; |
||||
|
||||
private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("station-device-generate-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy()); |
||||
|
||||
@Value("${fdp.host}") |
||||
private String fdpHost; |
||||
|
||||
@Override |
||||
public ExtraVO resolveStations(String startTime, String endTime, String type, String enumType) { |
||||
ExtraVO extraVO = new ExtraVO(); |
||||
extraVO.setType(TypeEnum.PARAMS.getType()); |
||||
extraVO.setFunc("stations_num"); |
||||
String label; |
||||
SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType); |
||||
if(!startTime.equals(endTime) && SearchTypeEnum.HISTORY.getSearchType().equals(type)) { |
||||
label = String.format("自%s到%s时间为止,",startTime,endTime); |
||||
} |
||||
else { |
||||
startTime = null; |
||||
endTime = null; |
||||
label = "目前"; |
||||
} |
||||
R<List<StationEntity>> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationTypeEnum.getStationType()); |
||||
Assert.isTrue(stationListR.isSuccess(),() -> { |
||||
throw new ServiceException("获取接入站点数量失败!"); |
||||
}); |
||||
Map<String, Object> params = new HashMap<>(); |
||||
params.put("searchStationType",stationTypeEnum.getSearchStationType()); |
||||
params.put("label",label + String.format(stationTypeEnum.getLabel(),stationListR.getData().size())); |
||||
params.put("startTime",startTime); |
||||
params.put("endTime",endTime); |
||||
extraVO.setParams(params); |
||||
return extraVO; |
||||
} |
||||
|
||||
@Override |
||||
public R resolve(ModelFunctionReq req) { |
||||
logger.info("interactive:resolve","开始解析大模型函数,函数内容为:" + JSON.toJSONString(req)); |
||||
FunctionEntity function = functionService.getFunctionByCode(req.getFunctionName()); |
||||
TypeEnum typeEnum = TypeEnum.getTypeEnumByType(function.getType()); |
||||
if(Func.isEmpty(typeEnum)) { |
||||
throw new ServiceException("函数解析失败!"); |
||||
} |
||||
switch (typeEnum) { |
||||
// 页面跳转
|
||||
case JUMP: |
||||
String jumpExtra = jumpPageService.dealJumpTypeFunction(function, req.getFunctionArgs()); |
||||
Assert.isTrue(StringUtil.isNotBlank(jumpExtra) && Func.isNotEmpty(jumpExtra), () -> { |
||||
throw new ServiceException("解析" + function.getName() + "函数失败!"); |
||||
}); |
||||
return R.data(jumpExtra); |
||||
case PARAMS: |
||||
String paramExtra = paramsService.dealJumpTypeFunction(function, req.getFunctionArgs()); |
||||
return R.data(paramExtra); |
||||
default: |
||||
throw new ServiceException("函数解析失败!"); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public R ask(String question,String sessionId,String userId) { |
||||
Map<String,Object> params = new HashMap<>(); |
||||
params.put("id",sessionId); |
||||
params.put("userid", userId); |
||||
params.put("query",question); |
||||
params.put("stationids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); |
||||
params.put("projectids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).map(String::valueOf).toArray()); |
||||
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantAsk()) |
||||
.body(JSON.toJSONString(params)).execute(); |
||||
logger.info("interactive:ask","问答传参为:" + JSON.toJSONString(params) + "结果为:" + response.body()); |
||||
if(response.getStatus() != HttpServletResponse.SC_OK) { |
||||
log.error("远程调用大模型【发起问答】接口失败!"); |
||||
return R.fail("远程调用大模型【发起问答】接口失败!"); |
||||
} |
||||
this.addQuestionSessionId(sessionId); |
||||
return R.success("消息发送成功"); |
||||
} |
||||
|
||||
private void addQuestionSessionId(String sessionId) { |
||||
redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,sessionId); |
||||
} |
||||
|
||||
@Override |
||||
public R specialAsk(String sessionId, String userId, Map<String, Object> extra) { |
||||
Map<String,Object> params = new HashMap<>(); |
||||
params.put("id",sessionId); |
||||
params.put("userid", userId); |
||||
params.put("extra",extra); |
||||
params.put("stationids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); |
||||
params.put("projectids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).map(String::valueOf).toArray()); |
||||
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk()) |
||||
.body(JSON.toJSONString(params)).execute(); |
||||
if(response.getStatus() != HttpServletResponse.SC_OK) { |
||||
log.error("远程调用大模型【发起特殊问答】接口失败!"); |
||||
return R.fail("远程调用大模型【发起特殊问答】接口失败!"); |
||||
} |
||||
this.addQuestionSessionId(sessionId); |
||||
return R.success("消息发送成功"); |
||||
} |
||||
|
||||
@Override |
||||
public List hotQuestions() { |
||||
String url = fdpHost + bigModelInvokeUrl.getHotQuestion(); |
||||
return this.postCall(url,null,List.class); |
||||
} |
||||
|
||||
/** |
||||
* 远程调用http接口 |
||||
* @param url 接口url |
||||
* @param body 传参 |
||||
* @param resultT 结果解析对象 |
||||
* @return 结果 |
||||
* @param <T> 结果解析对象类型 |
||||
*/ |
||||
public <T> T postCall(String url,Map body,Class<T> resultT) { |
||||
HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); |
||||
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { |
||||
log.error("远程调用大模型接口" + url + "失败!"); |
||||
throw new ServiceException("远程调用大模型接口" + url + "失败!"); |
||||
}); |
||||
return JSONObject.parseObject(response.body(), resultT); |
||||
} |
||||
|
||||
@Override |
||||
public void updateVideo(Map<String, Object> request) { |
||||
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getUpdateVideo()) |
||||
.body(JSON.toJSONString(request)).execute(); |
||||
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { |
||||
throw new ServiceException("远程调用大模型【更新实时监控】接口失败!"); |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public Boolean updateCanvas(Map<String, Object> request) { |
||||
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getUpdateCanvas()) |
||||
.body(JSON.toJSONString(request)).execute(); |
||||
if (response.getStatus() == HttpServletResponse.SC_OK) { |
||||
return true; |
||||
} |
||||
log.error("远程调用大模型【更新实时画面】接口失败!"); |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void updateFault(Map<String, Object> request) { |
||||
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getUpdateFault()) |
||||
.body(JSON.toJSONString(request)).execute(); |
||||
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { |
||||
throw new ServiceException("远程调用大模型【更新故障列表】接口失败!"); |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public List<AnswerVO> getAnswerBySessionIds(String sessionIds) { |
||||
Map<String,Object> params = new HashMap<>(); |
||||
params.put("ids",Func.toStrList(",",sessionIds).toArray()); |
||||
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantStatus()) |
||||
.body(JSON.toJSONString(params)).execute(); |
||||
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { |
||||
throw new ServiceException("远程调用大模型【获取问题答案】接口失败!"); |
||||
}); |
||||
XxlJobLogger.log("接收到答案:"+JSON.toJSONString(response.body())); |
||||
List<AnswerVO> result = JSONArray.parseArray(response.body(), AnswerVO.class); |
||||
if(CollectionUtil.isNotEmpty(result)) { |
||||
logger.info("interactive:getAnswerBySessionIds","获取答案:" + response.body()); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
|
||||
|
||||
@Override |
||||
public Boolean authentication(String stationId, String userId, String func,String sessionId) { |
||||
// 站点鉴权
|
||||
if(StringUtil.isNotBlank(stationId)) { |
||||
authenticationService.stationAuthentication(stationId,userId); |
||||
} |
||||
// 菜单鉴权
|
||||
if(StringUtil.isNotBlank(func) && StringUtil.isNotBlank(userId)) { |
||||
authenticationService.menuAuthentication(userId,func); |
||||
} |
||||
// 遥控鉴权
|
||||
if(FuncRouteEnum.CONFIRM_YK.getFuncCode().equals(func)) { |
||||
authenticationService.remoteAuthentication(stationId,userId,sessionId); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public Boolean removeSessionId(String sessionId) { |
||||
// 调用大模型删除对话
|
||||
Map<String,Object> params = new HashMap<>(); |
||||
params.put("id",sessionId); |
||||
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAskAbort()) |
||||
.body(JSON.toJSONString(params)).execute(); |
||||
if(response.getStatus() != HttpServletResponse.SC_OK) { |
||||
log.error("远程调用大模型【删除对话】接口失败!"); |
||||
throw new ServiceException("远程调用大模型【删除对话】接口失败!"); |
||||
} |
||||
// 移除对应reids中问题标记
|
||||
redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,sessionId); |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 发起知识库问答 |
||||
*/ |
||||
@Override |
||||
public R knowledgeAsk(String question, String sessionId, String userId, String knowledge) { |
||||
Map<String,Object> params = new HashMap<>(); |
||||
params.put("id", sessionId); |
||||
params.put("userid", userId); |
||||
params.put("query", question); |
||||
params.put("knowledge", knowledge); |
||||
params.put("stationids", authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId) |
||||
.filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); |
||||
params.put("projectids", authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId) |
||||
.filter(Func::isNotEmpty).map(String::valueOf).toArray()); |
||||
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantKnowledgeAsk()) |
||||
.body(JSON.toJSONString(params)).execute(); |
||||
logger.info("interactive:knowledgeAsk", "知识库问答传参为:" + JSON.toJSONString(params) + " 结果为:" + response.body()); |
||||
if (response.getStatus() != HttpServletResponse.SC_OK) { |
||||
log.error("远程调用大模型【发起知识库问答】接口失败!"); |
||||
return R.fail("远程调用大模型【发起知识库问答】接口失败!"); |
||||
} |
||||
this.addQuestionSessionId(sessionId); |
||||
return R.success("消息发送成功"); |
||||
} |
||||
|
||||
/** |
||||
* 下发遥控指令 |
||||
* @param operate |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public R<Object> sendRemoteControl(ControlDTO operate) { |
||||
return remoteClient.sendCtrl(operate); |
||||
} |
||||
|
||||
/** |
||||
* 站点发电量 |
||||
* @param stationId |
||||
* @param startTime |
||||
* @param endTime |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public Double generation(String stationId, String startTime, String endTime) { |
||||
// 步骤1.查询站点
|
||||
R<StationEntity> station = stationClient.getStationByCode(stationId); |
||||
if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){ |
||||
return 0.0; |
||||
} |
||||
// 步骤2.查询填报发电量
|
||||
double fill = generateClient.stationGenerateByTime(stationId,startTime,endTime); |
||||
|
||||
// 步骤3.查询设备
|
||||
List<RideDeviceVo> devices = deviceClient.rideDevices(Collections.singletonList(station.getData().getRefDept())); |
||||
if(CollectionUtil.isEmpty(devices)){ |
||||
return fill; |
||||
} |
||||
// 步骤4.遍历设备查询发电量
|
||||
// 监控线程执行完后返回结果
|
||||
CountDownLatch countDownLatch = new CountDownLatch(devices.size()); |
||||
List<Double> deviceGenerate = new CopyOnWriteArrayList(); |
||||
for(RideDeviceVo device : devices){ |
||||
pool.submit(()->{ |
||||
deviceGenerate.add(this.periodTargetFloat(startTime,endTime,5,6,device.getNumber(),device.getRide(), HomePageConstant.HYDROPOWER_GENERATE_POWER)); |
||||
}); |
||||
countDownLatch.countDown(); |
||||
} |
||||
//所有模板数据获取完成后释放锁
|
||||
try { |
||||
countDownLatch.await(); |
||||
} catch (InterruptedException e) { |
||||
e.printStackTrace(); |
||||
Thread.currentThread().interrupt(); |
||||
} |
||||
return fill + deviceGenerate.stream().mapToDouble(Double::doubleValue).sum(); |
||||
} |
||||
|
||||
/*** |
||||
* 指标数据列表查询 |
||||
* @param startTime 开始时间 |
||||
* @param endTime 结束时间 |
||||
* @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 |
||||
* @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 |
||||
* @param deviceCode 设备编号 |
||||
* @param ride 配电比 |
||||
* @param signages 指标 |
||||
* @return |
||||
*/ |
||||
private Double periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Double ride,String signages) { |
||||
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); |
||||
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>(); |
||||
AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); |
||||
analyzeDataConditionPO.setFull(1); |
||||
po.setDeviceCode(deviceCode); |
||||
analyzeDataConditionPO.setSignages(signages); |
||||
analyzeDataConditionPO.setKeepFigures(2); |
||||
analyzeDataConditionPO.setAccessRules(accessRules); |
||||
analyzeDataConditionPO.setSaveTimeType(cycleType); |
||||
// 间隔
|
||||
analyzeDataConditionPO.setTimeInterval(1); |
||||
analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); |
||||
analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); |
||||
signboardConditions.add(analyzeDataConditionPO); |
||||
po.setSignboardConditions(signboardConditions); |
||||
R<List<AnalyzeDataConditionVO>> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); |
||||
if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { |
||||
return 0.0; |
||||
} |
||||
List<AnalyzeDataConditionVO> records = result.getData(); |
||||
if(CollectionUtil.isEmpty(records)){ |
||||
return 0.0; |
||||
} |
||||
AnalyzeDataConditionVO analyzeDataConditionVO = records.get(0); |
||||
if (ObjectUtil.isEmpty(analyzeDataConditionVO)) { |
||||
return 0.0; |
||||
} |
||||
List<AnalyseDataTaosVO> analyseDataTaosVOList = analyzeDataConditionVO.getList(); |
||||
if (CollectionUtil.isEmpty(analyseDataTaosVOList)) { |
||||
return 0.0; |
||||
} |
||||
AnalyseDataTaosVO analyseDataTaosVO = analyzeDataConditionVO.getList().get(0); |
||||
if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) { |
||||
return 0.0; |
||||
} |
||||
return Double.parseDouble(analyseDataTaosVO.getVal()) * ride; |
||||
} |
||||
} |
@ -1,46 +0,0 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service.impl; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.hnac.hzims.bigmodel.entity.FuncParamEntity; |
||||
import com.hnac.hzims.bigmodel.entity.FunctionEntity; |
||||
import com.hnac.hzims.bigmodel.function.service.IFuncParamService; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.tool.utils.StringUtil; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.util.Assert; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Optional; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/04/26 11:46 |
||||
*/ |
||||
@Service |
||||
@AllArgsConstructor |
||||
@Slf4j |
||||
@Deprecated |
||||
public class JumpPageServiceImpl implements IJumpPageService { |
||||
|
||||
private final IFuncParamService paramService; |
||||
private final JumpRouteJoinStrategy strategy; |
||||
|
||||
@Override |
||||
public String dealJumpTypeFunction(FunctionEntity function,Map<String,String> args) { |
||||
List<FuncParamEntity> params = paramService.getParamsByFuncId(function.getId()); |
||||
Optional<FuncParamEntity> paramOptional = params.stream().filter(p -> p.getIsRequire()).filter(p -> !args.containsKey(p.getAlias())).findAny(); |
||||
Assert.isTrue(!paramOptional.isPresent(), () -> { |
||||
throw new ServiceException("解析参数失败,缺少参数:" + paramOptional.get().getName()); |
||||
}); |
||||
// 跳转页面逻辑
|
||||
ExtraVO extraVO = strategy.resolve(function,args); |
||||
return JSON.toJSONString(extraVO); |
||||
} |
||||
} |
@ -1,145 +0,0 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service.impl; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hnac.hzims.bigmodel.entity.FunctionEntity; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; |
||||
import com.hnac.hzims.operational.station.entity.StationEntity; |
||||
import com.hnac.hzims.operational.station.feign.IStationClient; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.core.tool.utils.StringUtil; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.util.Assert; |
||||
|
||||
import java.util.*; |
||||
import java.util.stream.IntStream; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/04/30 11:38 |
||||
*/ |
||||
@Component |
||||
@RequiredArgsConstructor |
||||
@Deprecated |
||||
public class JumpRouteJoinStrategy { |
||||
|
||||
private final IStationClient stationClient; |
||||
|
||||
public static String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"}; |
||||
|
||||
/** |
||||
* 解析大模型传参 |
||||
* @param args 大模型传参 |
||||
* @return 跳转path所需要的参数 |
||||
*/ |
||||
public ExtraVO resolve(FunctionEntity function,Map<String,String> args) { |
||||
FuncRouteEnum routeEnum = FuncRouteEnum.getEnumByFuncCode(function.getCode()); |
||||
if(Func.isNotEmpty(routeEnum)) { |
||||
switch(routeEnum) { |
||||
case OPEN_CANVAS: |
||||
return this.getScadaExtra(args,function); |
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public ExtraVO getScadaExtra(Map<String,String> args,FunctionEntity function) { |
||||
// 跳转页面逻辑
|
||||
ExtraVO extraVO = new ExtraVO(); |
||||
extraVO.setImmediatelyJump(true); |
||||
extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFuncCode()); |
||||
Map<String, String> params = this.scadaResolve(args); |
||||
// 根据hz3000画面版本获取path
|
||||
Integer picResource = Integer.valueOf(params.get("picResource")); |
||||
JSONObject pathObject = JSONObject.parseObject(function.getPath()); |
||||
R<StationEntity> stationR = stationClient.getStationByCode(params.get("projectId")); |
||||
extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + params.get("name")); |
||||
Map<String,Object> extraParams = new HashMap<>(1); |
||||
extraParams.put("picResource",picResource); |
||||
extraVO.setParams(extraParams); |
||||
// 云组态
|
||||
if(picResource == 0) { |
||||
String scada = pathObject.getString("scada"); |
||||
extraVO.setRoute(this.replacePath(scada, params)); |
||||
extraVO.setRoute(scada); |
||||
} |
||||
// v3.0
|
||||
else if (picResource == 1) { |
||||
String v3 = pathObject.getString("v3"); |
||||
extraVO.setRoute(this.replacePath(v3, params)); |
||||
} |
||||
// v4.0
|
||||
else if (picResource == 2) { |
||||
String v4 = pathObject.getString("v4"); |
||||
// pic_name 去掉头部的/ 以及尾部的.js
|
||||
String context = params.get("context"); |
||||
context = this.removeHeadChars(context,"/"); |
||||
context = this.removeTailChars(context,".js"); |
||||
params.put("context",context); |
||||
extraVO.setRoute(this.replacePath(v4, params)); |
||||
} |
||||
else { |
||||
throw new ServiceException("解析出来的画面类型在云组态、v3、v4类型之外,无法解析路由"); |
||||
} |
||||
extraVO.setType(FunctionConstants.TypeEnum.JUMP.getType()); |
||||
return extraVO; |
||||
} |
||||
|
||||
/** |
||||
* 解析实时画面参数 |
||||
* @param args 大模型解析参数 |
||||
* @return 实时画面路径拼接所需参数 |
||||
*/ |
||||
public Map<String,String> scadaResolve(Map<String,String> args) { |
||||
String params = args.get("canvas_id"); |
||||
// 参数格式为:picResource^context^stationNum^projectId^taskId^name^id
|
||||
return this.resolve(params,SCADA_PARAMS_SOLVE); |
||||
} |
||||
|
||||
public Map<String,String> resolve(String paramsStr,String... keys) { |
||||
Map<String,String> result = new HashMap<>(); |
||||
List<String> params = Func.toStrList("\\^", paramsStr); |
||||
Assert.isTrue(params.size() == keys.length, () -> { |
||||
throw new ServiceException("大模型传参params长度错误,传参为:" + paramsStr); |
||||
}); |
||||
IntStream.iterate(0,index -> index + 1).limit(params.size()).forEach(index -> result.put(keys[index],params.get(index))); |
||||
return result; |
||||
} |
||||
|
||||
private String replacePath(String path,Map<String,String> params) { |
||||
Set<Map.Entry<String, String>> entries = params.entrySet(); |
||||
// 替换path中变量
|
||||
for (Map.Entry<String, String> entry : entries) { |
||||
String replaceVariables = "{" + entry.getKey() + "}"; |
||||
path = StringUtil.replace(path,replaceVariables,entry.getValue()); |
||||
} |
||||
return path; |
||||
} |
||||
|
||||
public String removeHeadChars(String str, String charsToRemove) { |
||||
if (str == null || charsToRemove == null || charsToRemove.isEmpty()) { |
||||
return str; |
||||
} |
||||
while (str.startsWith(charsToRemove)) { |
||||
str = str.substring(charsToRemove.length()); |
||||
} |
||||
return str; |
||||
} |
||||
|
||||
public String removeTailChars(String str, String charsToRemove) { |
||||
if (str == null || charsToRemove == null || charsToRemove.isEmpty()) { |
||||
return str; |
||||
} |
||||
while (str.endsWith(charsToRemove)) { |
||||
str = str.substring(0, str.length() - charsToRemove.length()); |
||||
} |
||||
return str; |
||||
} |
||||
} |
@ -0,0 +1,76 @@
|
||||
package com.hnac.hzims.bigmodel.maintenance.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.hnac.hzims.bigmodel.maintenance.entity.DatasourceEntity; |
||||
import com.hnac.hzims.bigmodel.maintenance.service.DataSourceService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.beans.factory.annotation.Qualifier; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/05 16:55 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/datasource") |
||||
@Api(value = "数据源管理",tags = "数据源管理") |
||||
public class DataSourceController { |
||||
|
||||
@Autowired |
||||
@Qualifier("dataSourceMaintenanceService") |
||||
private DataSourceService dataSourceService; |
||||
|
||||
@GetMapping("/listPage") |
||||
@ApiOperation(value = "分页查询") |
||||
@ApiOperationSupport(order = 1) |
||||
public R<IPage<DatasourceEntity>> listPage(Query query, DatasourceEntity req) { |
||||
return R.data(dataSourceService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); |
||||
} |
||||
|
||||
@GetMapping("/detail") |
||||
@ApiOperation(value = "查看详情") |
||||
@ApiOperationSupport(order = 2) |
||||
public R<DatasourceEntity> detail(@RequestParam @ApiParam("主键ID") Long id) { |
||||
return R.data(dataSourceService.getById(id)); |
||||
} |
||||
|
||||
@PostMapping("/save") |
||||
@ApiOperation(value = "保存数据源配置") |
||||
@ApiOperationSupport(order = 3) |
||||
public R save(@RequestBody DatasourceEntity req) { |
||||
return R.status(dataSourceService.save(req)); |
||||
} |
||||
|
||||
@DeleteMapping("/remove") |
||||
@ApiOperation(value = "删除数据源配置") |
||||
@ApiOperationSupport(order = 4) |
||||
public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { |
||||
return R.status(dataSourceService.removeByIds(Func.toLongList(",",ids))); |
||||
} |
||||
|
||||
@PutMapping("/update") |
||||
@ApiOperation(value = "编辑数据源配置") |
||||
@ApiOperationSupport(order = 5) |
||||
public R update(@RequestBody DatasourceEntity req) { |
||||
return R.status(dataSourceService.updateById(req)); |
||||
} |
||||
|
||||
@GetMapping("/list") |
||||
@ApiOperation(value = "列表查询") |
||||
@ApiOperationSupport(order = 1) |
||||
public R<List<DatasourceEntity>> list(DatasourceEntity req) { |
||||
return R.data(dataSourceService.list(Condition.getQueryWrapper(req).lambda())); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,56 @@
|
||||
package com.hnac.hzims.bigmodel.maintenance.controller; |
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.hnac.hzims.bigmodel.BigModelConstants; |
||||
import com.hnac.hzims.bigmodel.maintenance.service.TableColumnService; |
||||
import com.hnac.hzinfo.log.annotation.Business; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/04 09:28 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/table/info") |
||||
@Api(value = "数据库表、列信息查询管理",tags = "数据库表、列信息查询管理") |
||||
@Business(module = BigModelConstants.APP_NAME,value = "数据库表、列信息查询管理",ignore = false) |
||||
@AllArgsConstructor |
||||
public class TableColumnController { |
||||
|
||||
private final TableColumnService tableColumnService; |
||||
|
||||
@ApiOperation("获取数据库") |
||||
@ApiOperationSupport(order = 1) |
||||
@GetMapping("/getDatabase") |
||||
public R<List<Map<String,Object>>> getDatabase(@RequestParam @ApiParam(value = "数据源名") String datasource) { |
||||
return R.data(tableColumnService.getDatabase(datasource)); |
||||
} |
||||
|
||||
@ApiOperation("获取数据库表列表") |
||||
@ApiOperationSupport(order = 2) |
||||
@GetMapping("/getTables") |
||||
public R<List<Map<String,Object>>> getTables(@RequestParam @ApiParam(value = "数据源名") String datasource, |
||||
@RequestParam @ApiParam(value = "数据库名") String database) { |
||||
return R.data(tableColumnService.getTables(datasource,database)); |
||||
} |
||||
|
||||
@ApiOperation("获取数据库表列列表") |
||||
@ApiOperationSupport(order = 3) |
||||
@GetMapping("/getColumns") |
||||
public R<List<Map<String,Object>>> getColumns(String datasource, |
||||
@RequestParam @ApiParam(value = "数据源名") String database, |
||||
@RequestParam @ApiParam(value = "数据库表名") String tableName) { |
||||
return R.data(tableColumnService.getColumns(datasource,database,tableName)); |
||||
} |
||||
} |
@ -0,0 +1,61 @@
|
||||
package com.hnac.hzims.bigmodel.maintenance.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.hnac.hzims.bigmodel.BigModelConstants; |
||||
import com.hnac.hzims.bigmodel.maintenance.entity.TableInfoEntity; |
||||
import com.hnac.hzims.bigmodel.maintenance.service.TableInfoService; |
||||
import com.hnac.hzinfo.log.annotation.Business; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.validation.Valid; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/04 15:26 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/tableInfo") |
||||
@Api(value = "数据库信息管理",tags = "数据库信息管理") |
||||
@AllArgsConstructor |
||||
@Business(module = BigModelConstants.APP_NAME,value = "数据库信息管理",ignore = false) |
||||
public class TableInfoController { |
||||
|
||||
private final TableInfoService tableInfoService; |
||||
|
||||
@PostMapping("/save") |
||||
@ApiOperation("保存数据库信息") |
||||
@ApiOperationSupport(order = 1) |
||||
public R save(@RequestBody @Valid TableInfoEntity req) { |
||||
return R.data(tableInfoService.save(req)); |
||||
} |
||||
|
||||
@PostMapping("/update") |
||||
@ApiOperation("编辑数据库信息") |
||||
@ApiOperationSupport(order = 2) |
||||
public R update(@RequestBody TableInfoEntity req) { |
||||
return R.data(tableInfoService.updateById(req)); |
||||
} |
||||
|
||||
@GetMapping("/listPage") |
||||
@ApiOperation("数据库信息列表查询") |
||||
@ApiOperationSupport(order = 3) |
||||
public R<IPage<TableInfoEntity>> listPage(Query query, TableInfoEntity req) { |
||||
return R.data(tableInfoService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); |
||||
} |
||||
|
||||
@DeleteMapping("/removeByIds") |
||||
@ApiOperation("删除数据库信息") |
||||
@ApiOperationSupport(order = 4) |
||||
public R removeByIds(@RequestParam @ApiParam("id,按逗号分隔") String ids) { |
||||
return R.status(tableInfoService.removeByIds(Func.toLongList(",",ids))); |
||||
} |
||||
} |
@ -0,0 +1,66 @@
|
||||
package com.hnac.hzims.bigmodel.maintenance.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.hnac.hzims.bigmodel.maintenance.entity.TablePropertyEntity; |
||||
import com.hnac.hzims.bigmodel.maintenance.service.TablePropertyService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/05 15:19 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/table/property") |
||||
@Api(value = "表配置",tags = "表配置") |
||||
@AllArgsConstructor |
||||
public class TablePropertyController { |
||||
|
||||
private final TablePropertyService tablePropertyService; |
||||
|
||||
@GetMapping("/listPage") |
||||
@ApiOperation(value = "分页查询") |
||||
@ApiOperationSupport(order = 1) |
||||
public R<IPage<TablePropertyEntity>> listPage(Query query, TablePropertyEntity req) { |
||||
return R.data(tablePropertyService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); |
||||
} |
||||
|
||||
@GetMapping("/detail") |
||||
@ApiOperation(value = "查看详情") |
||||
@ApiOperationSupport(order = 2) |
||||
public R<TablePropertyEntity> detail(@RequestParam @ApiParam("主键ID") Long id) { |
||||
return R.data(tablePropertyService.getById(id)); |
||||
} |
||||
|
||||
@PostMapping("/save") |
||||
@ApiOperation(value = "保存表配置") |
||||
@ApiOperationSupport(order = 3) |
||||
public R save(@RequestBody TablePropertyEntity req) { |
||||
return R.status(tablePropertyService.save(req)); |
||||
} |
||||
|
||||
@DeleteMapping("/remove") |
||||
@ApiOperation(value = "删除表配置") |
||||
@ApiOperationSupport(order = 4) |
||||
public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { |
||||
return R.status(tablePropertyService.removeByIds(Func.toLongList(",",ids))); |
||||
} |
||||
|
||||
@PutMapping("/update") |
||||
@ApiOperation(value = "编辑表配置") |
||||
@ApiOperationSupport(order = 5) |
||||
public R update(@RequestBody TablePropertyEntity req) { |
||||
return R.status(tablePropertyService.updateById(req)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.hnac.hzims.bigmodel.maintenance.entity; |
||||
|
||||
import lombok.Data; |
||||
import org.springblade.core.tenant.mp.TenantEntity; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/04 15:45 |
||||
*/ |
||||
@Data |
||||
public class DataRecordEntity extends TenantEntity { |
||||
|
||||
private String tableId; |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,37 @@
|
||||
package com.hnac.hzims.bigmodel.maintenance.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.support.QueryField; |
||||
import org.springblade.core.mp.support.SqlCondition; |
||||
import org.springblade.core.tenant.mp.TenantEntity; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/05 14:45 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode |
||||
@TableName("HZIMS_DATASOURCE") |
||||
@ApiModel(value = "数据源配置",description = "数据源配置") |
||||
public class DatasourceEntity extends TenantEntity implements Serializable { |
||||
|
||||
@ApiModelProperty("数据源") |
||||
@QueryField(condition = SqlCondition.LIKE) |
||||
private String datasource; |
||||
|
||||
@ApiModelProperty("数据源名称") |
||||
@QueryField(condition = SqlCondition.LIKE) |
||||
private String datasourceName; |
||||
|
||||
@ApiModelProperty("数据库名称") |
||||
@QueryField(condition = SqlCondition.LIKE) |
||||
private String databaseName; |
||||
|
||||
} |
@ -0,0 +1,56 @@
|
||||
package com.hnac.hzims.bigmodel.maintenance.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.support.QueryField; |
||||
import org.springblade.core.mp.support.SqlCondition; |
||||
import org.springblade.core.tenant.mp.TenantEntity; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/04 14:59 |
||||
*/ |
||||
@Data |
||||
@TableName("mysql_table_info") |
||||
@EqualsAndHashCode |
||||
@ApiModel(value = "数据库信息",description = "数据库信息") |
||||
public class TableInfoEntity extends TenantEntity implements Serializable { |
||||
|
||||
@TableField("db_source") |
||||
@ApiModelProperty("数据源") |
||||
@NotBlank |
||||
@QueryField(condition = SqlCondition.LIKE) |
||||
private String datasource; |
||||
|
||||
@TableField("db_name") |
||||
@ApiModelProperty("数据库") |
||||
@NotBlank |
||||
@QueryField(condition = SqlCondition.EQUAL) |
||||
private String database; |
||||
|
||||
@ApiModelProperty("数据库表名") |
||||
@NotBlank |
||||
@QueryField(condition = SqlCondition.EQUAL) |
||||
private String tableName; |
||||
|
||||
@ApiModelProperty("数据库表描述信息") |
||||
@NotBlank |
||||
@QueryField(condition = SqlCondition.LIKE) |
||||
private String tableDesc; |
||||
|
||||
@ApiModelProperty("数据库表列信息") |
||||
@NotBlank |
||||
private String propDesc; |
||||
|
||||
@ApiModelProperty("举例") |
||||
@NotBlank |
||||
private String example; |
||||
|
||||
} |
@ -0,0 +1,49 @@
|
||||
package com.hnac.hzims.bigmodel.maintenance.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import org.springblade.core.mp.support.QueryField; |
||||
import org.springblade.core.mp.support.SqlCondition; |
||||
import org.springblade.core.tenant.mp.TenantEntity; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
import javax.validation.constraints.NotNull; |
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/05 14:49 |
||||
*/ |
||||
@ApiModel("数据库表配置") |
||||
@TableName("HZIMS_TABLE_PROPERTY") |
||||
@Data |
||||
public class TablePropertyEntity extends TenantEntity implements Serializable { |
||||
|
||||
@ApiModelProperty("数据源Id") |
||||
@QueryField(condition = SqlCondition.EQUAL) |
||||
@NotNull |
||||
private Long datasourceId; |
||||
|
||||
@ApiModelProperty("数据源名称") |
||||
@QueryField(condition = SqlCondition.LIKE) |
||||
@NotNull |
||||
private String datasourceName; |
||||
|
||||
@ApiModelProperty("数据库名") |
||||
@QueryField(condition = SqlCondition.LIKE) |
||||
@NotBlank |
||||
private String databaseName; |
||||
|
||||
@ApiModelProperty("数据表名") |
||||
@QueryField(condition = SqlCondition.LIKE) |
||||
@NotBlank |
||||
private String tableName; |
||||
|
||||
@ApiModelProperty("鉴权类型") |
||||
@QueryField(condition = SqlCondition.EQUAL) |
||||
@NotBlank |
||||
private String authType; |
||||
|
||||
} |
@ -0,0 +1,12 @@
|
||||
package com.hnac.hzims.bigmodel.maintenance.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.hnac.hzims.bigmodel.maintenance.entity.DatasourceEntity; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/05 15:05 |
||||
*/ |
||||
public interface DatasourceMapper extends BaseMapper<DatasourceEntity> { |
||||
|
||||
} |
@ -0,0 +1,12 @@
|
||||
package com.hnac.hzims.bigmodel.maintenance.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.hnac.hzims.bigmodel.maintenance.entity.TableInfoEntity; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/04 15:25 |
||||
*/ |
||||
public interface TableInfoMapper extends BaseMapper<TableInfoEntity> { |
||||
|
||||
} |
@ -0,0 +1,11 @@
|
||||
package com.hnac.hzims.bigmodel.maintenance.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.hnac.hzims.bigmodel.maintenance.entity.TablePropertyEntity; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/05 15:12 |
||||
*/ |
||||
public interface TablePropertyMapper extends BaseMapper<TablePropertyEntity> { |
||||
} |
@ -0,0 +1,19 @@
|
||||
package com.hnac.hzims.bigmodel.maintenance.service; |
||||
|
||||
import com.hnac.hzims.bigmodel.maintenance.entity.DatasourceEntity; |
||||
import com.hnac.hzims.bigmodel.maintenance.mapper.DatasourceMapper; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/05 15:06 |
||||
*/ |
||||
@Service("dataSourceMaintenanceService") |
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
public class DataSourceService extends BaseServiceImpl<DatasourceMapper, DatasourceEntity> { |
||||
|
||||
} |
@ -0,0 +1,37 @@
|
||||
package com.hnac.hzims.bigmodel.maintenance.service; |
||||
|
||||
import com.hnac.hzims.bigmodel.business.service.DataSourceService; |
||||
import lombok.RequiredArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/04 09:29 |
||||
*/ |
||||
@Service |
||||
@RequiredArgsConstructor |
||||
@Slf4j |
||||
public class TableColumnService { |
||||
|
||||
private final DataSourceService dataSourceService; |
||||
|
||||
public List<Map<String,Object>> getDatabase(String datasource) { |
||||
String sql = "select distinct `table_schema` as tableName from `information_schema`.`tables` where `table_schema` <> 'information_schema';"; |
||||
return dataSourceService.queryListOnSpecificDataSource(sql,datasource); |
||||
} |
||||
|
||||
public List<Map<String, Object>> getTables(String datasource,String database) { |
||||
String sql = "select distinct `table_name` as tableName from `information_schema`.`tables` where `table_schema` = '" + database + "';"; |
||||
return dataSourceService.queryListOnSpecificDataSource(sql,datasource); |
||||
} |
||||
|
||||
public List<Map<String, Object>> getColumns(String datasource,String database,String tableName) { |
||||
String sql = "select distinct `column_name` as columnName,`column_comment` as columnComment from `information_schema`.`COLUMNS` where `TABLE_SCHEMA` = '" + database + "' and `TABLE_NAME` = '" + tableName + "';"; |
||||
return dataSourceService.queryListOnSpecificDataSource(sql,datasource); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.hnac.hzims.bigmodel.maintenance.service; |
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS; |
||||
import com.hnac.hzims.bigmodel.maintenance.entity.TableInfoEntity; |
||||
import com.hnac.hzims.bigmodel.maintenance.mapper.TableInfoMapper; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/04 15:23 |
||||
*/ |
||||
@Service |
||||
@AllArgsConstructor |
||||
@Slf4j |
||||
@DS("hznlm") |
||||
public class TableInfoService extends BaseServiceImpl<TableInfoMapper, TableInfoEntity> { |
||||
|
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.hnac.hzims.bigmodel.maintenance.service; |
||||
|
||||
import com.hnac.hzims.bigmodel.maintenance.entity.TablePropertyEntity; |
||||
import com.hnac.hzims.bigmodel.maintenance.mapper.TablePropertyMapper; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/05 15:11 |
||||
*/ |
||||
@Service |
||||
@AllArgsConstructor |
||||
@Slf4j |
||||
public class TablePropertyService extends BaseServiceImpl<TablePropertyMapper, TablePropertyEntity> { |
||||
|
||||
} |
@ -0,0 +1,101 @@
|
||||
package com.hnac.hzims.bigmodel.question.dto; |
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.SessionContentVO; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/10 10:22 |
||||
* @Describe: 接收前端发送消息 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode |
||||
public class MessageDTO implements Serializable { |
||||
|
||||
/** |
||||
* 消息类型 0-心跳消息 1-问题 |
||||
*/ |
||||
private String type; |
||||
|
||||
/** |
||||
* 前端提出问题 |
||||
*/ |
||||
private String context; |
||||
|
||||
/** |
||||
* 前端传参附带参数 |
||||
*/ |
||||
private SessionContentVO content; |
||||
|
||||
/** |
||||
* 是否发起特殊问答 |
||||
*/ |
||||
private Boolean isSpecial; |
||||
|
||||
/** |
||||
* 发起问题用户ID |
||||
*/ |
||||
private String userId; |
||||
|
||||
/** |
||||
* 知识库 |
||||
*/ |
||||
private String knowledge; |
||||
|
||||
/** |
||||
* 会话ID |
||||
*/ |
||||
private String chatId; |
||||
|
||||
/** |
||||
* 大模型函数 |
||||
*/ |
||||
private String func; |
||||
|
||||
/** |
||||
* 特殊问题参数 |
||||
*/ |
||||
private Map<String,Object> extra; |
||||
|
||||
/** |
||||
* 是否允许大模型查询数据,默认为1 |
||||
*/ |
||||
@JSONField(name = "enable_record") |
||||
private int enableRecord = 1; |
||||
|
||||
/** |
||||
* 是否允许大模型发送指令,默认为1 |
||||
*/ |
||||
@JSONField(name = "enable_yk") |
||||
private int enableControl = 1; |
||||
|
||||
/** |
||||
* 是否允许大模型打开视频,默认为1 |
||||
*/ |
||||
@JSONField(name = "enable_video") |
||||
private int enableVideo = 1; |
||||
|
||||
/** |
||||
* 是否允许大模型打开画面,默认为1 |
||||
*/ |
||||
@JSONField(name = "enable_canvas") |
||||
private int enableCanvas = 1; |
||||
|
||||
/** |
||||
* 是否允许大模型诊断故障,默认为1 |
||||
*/ |
||||
@JSONField(name = "enable_fault") |
||||
private int enableFault = 1; |
||||
|
||||
/** |
||||
* 大模型默认的意图理解方式,可以为"default","yk"... |
||||
*/ |
||||
@JSONField(name = "default") |
||||
private String defaultMode; |
||||
|
||||
} |
@ -0,0 +1,76 @@
|
||||
package com.hnac.hzims.bigmodel.question.dto; |
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/10 10:27 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode |
||||
public class QuestionDTO implements Serializable { |
||||
|
||||
/** |
||||
* 随机ID,同一个用户的对话使用统一的ID |
||||
*/ |
||||
@JSONField(name = "chat_id") |
||||
private String chatId; |
||||
|
||||
/** |
||||
* 用户ID,同一个随机ID只能对应一个用户ID |
||||
*/ |
||||
@JSONField(name = "user_id") |
||||
private String userId; |
||||
|
||||
/** |
||||
* 用户的问题 |
||||
*/ |
||||
private String query; |
||||
|
||||
/** |
||||
* 特殊提问内容 |
||||
*/ |
||||
private Map<String, Object> extra; |
||||
|
||||
/** |
||||
* 是否允许大模型查询数据,默认为 1 |
||||
*/ |
||||
@JSONField(name = "enable_record") |
||||
private int enableRecord = 1; |
||||
|
||||
/** |
||||
* 是否允许大模型发送指令,默认为 1 |
||||
*/ |
||||
@JSONField(name = "enable_yk") |
||||
private int enableControl = 1; |
||||
|
||||
/** |
||||
* 是否允许大模型打开视频,默认为 1 |
||||
*/ |
||||
@JSONField(name = "enable_video") |
||||
private int enableVideo = 1; |
||||
|
||||
/** |
||||
* 是否允许大模型打开画面,默认为 1 |
||||
*/ |
||||
@JSONField(name = "enable_canvas") |
||||
private int enableCanvas = 1; |
||||
|
||||
/** |
||||
* 是否允许大模型诊断故障,默认为 1 |
||||
*/ |
||||
@JSONField(name = "enable_fault") |
||||
private int enableFault = 1; |
||||
|
||||
/** |
||||
* 大模型默认的意图理解方式,可以为"default","yk"... |
||||
*/ |
||||
@JSONField(name = "default") |
||||
private String defaultMode; |
||||
|
||||
} |
@ -0,0 +1,122 @@
|
||||
package com.hnac.hzims.bigmodel.question.service; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; |
||||
import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IResolveService; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.ScadaSelectionVO; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.VideoSelectionVO; |
||||
import com.hnac.hzims.bigmodel.question.dto.MessageDTO; |
||||
import com.hnac.hzims.bigmodel.question.dto.QuestionDTO; |
||||
import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; |
||||
import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.tool.utils.BeanUtil; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.core.tool.utils.SpringUtil; |
||||
import org.springblade.core.tool.utils.StringUtil; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.web.socket.TextMessage; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/10 11:03 |
||||
*/ |
||||
@Service |
||||
@AllArgsConstructor |
||||
public class QuestionHandlerService { |
||||
|
||||
private final IHznlmInvokeService hznlmInvokeService; |
||||
|
||||
/** |
||||
* 处理用户发起问题 |
||||
* @param messageDTO 接收前端消息内容体 |
||||
*/ |
||||
public void handleMessage(MessageDTO messageDTO) { |
||||
// 将message转换为question
|
||||
QuestionDTO question = BeanUtil.copy(messageDTO,QuestionDTO.class); |
||||
question.setQuery(messageDTO.getContext()); |
||||
// 普通问答
|
||||
if(Func.isEmpty(messageDTO.getIsSpecial()) || !messageDTO.getIsSpecial()) { |
||||
if (StringUtil.isNotBlank(messageDTO.getKnowledge())) { |
||||
hznlmInvokeService.knowledgeAsk(question); |
||||
} else { |
||||
hznlmInvokeService.ask(question); |
||||
} |
||||
} else { |
||||
FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode((String) messageDTO.getExtra().get("func")); |
||||
switch (funcEnum) { |
||||
case CHOOSE_STATION: |
||||
case CHOOSE_YC: |
||||
case CHOOSE_FAULT: |
||||
case CHOOSE_YK: |
||||
hznlmInvokeService.specialAsk(question); |
||||
break; |
||||
case CHOOSE_VIDEO: |
||||
this.handleVideoChoose(messageDTO); |
||||
break; |
||||
case CHOOSE_CANVAS: |
||||
this.handleScadaChoose(messageDTO); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void handleVideoChoose(MessageDTO messageDTO) { |
||||
InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); |
||||
try { |
||||
VideoSelectionVO selection = (VideoSelectionVO) messageDTO.getExtra().get("data"); |
||||
IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_VIDEO.getFunc()); |
||||
String videoId = selection.getItemId(); |
||||
ExtraVO videoExtras = resolveService.resolve(videoId); |
||||
AnswerVO answerVO = new AnswerVO(); |
||||
answerVO.setSessionId(messageDTO.getChatId()); |
||||
answerVO.setQuery(selection.getItemName()); |
||||
answerVO.setRunning(0); |
||||
answerVO.setStatus(0); |
||||
answerVO.setAnswer("已成功打开"+selection.getItemName()+"视频"); |
||||
answerVO.setExtras(new Object[]{JSON.toJSONString(videoExtras)}); |
||||
TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); |
||||
wsService.sendMessage(messageDTO.getChatId(),textMessage); |
||||
} |
||||
catch (Exception e) { |
||||
AnswerVO answerVO = new AnswerVO(); |
||||
answerVO.setRunning(0); |
||||
answerVO.setStatus(-2); |
||||
answerVO.setAnswer("视频解析失败!"); |
||||
TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); |
||||
wsService.sendMessage(messageDTO.getChatId(),textMessage); |
||||
} |
||||
} |
||||
|
||||
private void handleScadaChoose(MessageDTO messageDTO) { |
||||
InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); |
||||
try { |
||||
ScadaSelectionVO selection = (ScadaSelectionVO) messageDTO.getExtra().get("data"); |
||||
IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_CANVAS.getFunc()); |
||||
ExtraVO scadaExtra = resolveService.resolve(selection.getItemId()); |
||||
AnswerVO answerVO = new AnswerVO(); |
||||
answerVO.setSessionId(messageDTO.getChatId()); |
||||
answerVO.setRunning(0); |
||||
answerVO.setStatus(0); |
||||
answerVO.setQuery(selection.getItemName()); |
||||
answerVO.setAnswer("已成功打开"+selection.getItemName()+"实时画面"); |
||||
answerVO.setExtras(new Object[]{JSON.toJSONString(scadaExtra)}); |
||||
TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); |
||||
wsService.sendMessage(messageDTO.getChatId(),textMessage); |
||||
} |
||||
catch (Exception e) { |
||||
AnswerVO answerVO = new AnswerVO(); |
||||
answerVO.setRunning(0); |
||||
answerVO.setStatus(-2); |
||||
answerVO.setAnswer("实时画面解析失败!"); |
||||
TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); |
||||
wsService.sendMessage(messageDTO.getChatId(),textMessage); |
||||
} |
||||
} |
||||
} |
@ -1,201 +0,0 @@
|
||||
package com.hnac.hzims.bigmodel.schedule; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; |
||||
import com.hnac.hzims.bigmodel.interactive.service.impl.ExtraResolveStrategyService; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.UpdateStationVO; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.UpdateUsualVO; |
||||
import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; |
||||
import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; |
||||
import com.hnac.hzims.operational.station.entity.StationEntity; |
||||
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; |
||||
import com.hnac.hzims.operational.station.feign.IStationClient; |
||||
import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; |
||||
import com.hnac.hzinfo.sdk.core.response.Result; |
||||
import com.hnac.hzinfo.sdk.v5.project.ProjectClient; |
||||
import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO; |
||||
import com.hnac.hzinfo.sdk.v5.scada.ScadaClient; |
||||
import com.hnac.hzinfo.sdk.v5.scada.vo.CanvasVO; |
||||
import com.xxl.job.core.biz.model.ReturnT; |
||||
import com.xxl.job.core.handler.annotation.XxlJob; |
||||
import com.xxl.job.core.log.XxlJobLogger; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.CollectionUtil; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.core.tool.utils.ObjectUtil; |
||||
import org.springblade.core.tool.utils.StringUtil; |
||||
import org.springframework.data.redis.core.RedisTemplate; |
||||
import org.springframework.scheduling.annotation.Scheduled; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.socket.TextMessage; |
||||
import org.springframework.web.socket.WebSocketSession; |
||||
|
||||
import java.util.*; |
||||
import java.util.concurrent.CompletableFuture; |
||||
import java.util.concurrent.ThreadPoolExecutor; |
||||
import java.util.stream.Collectors; |
||||
|
||||
import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.*; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/04/28 16:18 |
||||
*/ |
||||
@Component |
||||
@AllArgsConstructor |
||||
@Deprecated |
||||
public class InteractiveSchedule { |
||||
|
||||
private final InteractiveWsService wsService; |
||||
|
||||
private final IInteractiveService interactiveService; |
||||
|
||||
private final ThreadPoolExecutor getAnswerPoolExecutor; |
||||
|
||||
private final RedisTemplate redisTemplate; |
||||
|
||||
private final IStationVideoTypeClient videoClient; |
||||
|
||||
private final ProjectClient projectClient; |
||||
|
||||
private final ScadaClient scadaClient; |
||||
|
||||
private final IStationClient stationClient; |
||||
|
||||
private final ExtraResolveStrategyService extraResolveStrategyService; |
||||
|
||||
// @XxlJob(GET_INTERACTIVE_RESULT)
|
||||
public ReturnT getInteractiveResult(String params) { |
||||
List<String> sessionIds = redisTemplate.opsForList().range(HZIMS_BIGMODEL_ASK_KEY, 0, -1); |
||||
if(CollectionUtil.isEmpty(sessionIds)){ |
||||
XxlJobLogger.log("问题都已经回答完毕!"); |
||||
return ReturnT.SUCCESS; |
||||
} |
||||
List<AnswerVO> answerList = interactiveService.getAnswerBySessionIds(String.join(",", sessionIds)); |
||||
answerList.stream().parallel().forEach(answerVO -> CompletableFuture.runAsync(() -> { |
||||
// 如果已经获取到答案 则删除缓存
|
||||
if(answerVO.getRunning() == 0) { |
||||
redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId()); |
||||
} |
||||
Object[] extras = answerVO.getExtras(); |
||||
if(ObjectUtil.isNotEmpty(answerVO.getExtras()) && extras.length > 0){ |
||||
try { |
||||
List<String> extraList = Arrays.stream(extras).map(Object::toString).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); |
||||
answerVO.setExtras(extraList.toArray(new String[extraList.size()])); |
||||
} |
||||
catch(Exception e) { |
||||
e.printStackTrace(); |
||||
AnswerVO.error(answerVO); |
||||
answerVO.setAnswer("非常抱歉,系统在处理您的请求时遇到了问题。请稍后再试或联系我们的客服团队。"); |
||||
} |
||||
} |
||||
if(sessionIds.contains(answerVO.getSessionId())){ |
||||
WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); |
||||
TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); |
||||
if(Func.isNotEmpty(session)) { |
||||
wsService.sendMessage(session,message); |
||||
} |
||||
} |
||||
}, getAnswerPoolExecutor)); |
||||
return ReturnT.SUCCESS; |
||||
} |
||||
|
||||
@XxlJob(SYNCHRONOUS_VIDEO_INSTRUCT) |
||||
public ReturnT synchronousVideoInstruct(String params) { |
||||
Map<String,Object> request = new HashMap<>(2); |
||||
// 获取站点列表
|
||||
R<List<StationEntity>> stationsR = stationClient.list(new StationEntity()); |
||||
if(!stationsR.isSuccess() || CollectionUtil.isEmpty(stationsR.getData())) { |
||||
XxlJobLogger.log("获取站点列表失败!"); |
||||
return ReturnT.FAIL; |
||||
} |
||||
List<UpdateStationVO> updateStationList = stationsR.getData().stream().map(station -> { |
||||
UpdateStationVO stationVO = new UpdateStationVO(); |
||||
stationVO.setId(station.getCode()); |
||||
stationVO.setName(station.getName()); |
||||
return stationVO; |
||||
}).collect(Collectors.toList()); |
||||
request.put("stations", updateStationList); |
||||
// 获取视频列表
|
||||
R<List<StationVideoTypeEntity>> videoListR = videoClient.list(new StationVideoTypeEntity()); |
||||
if(!videoListR.isSuccess() || CollectionUtil.isEmpty(videoListR.getData())) { |
||||
XxlJobLogger.log("获取视频列表失败!"); |
||||
return ReturnT.FAIL; |
||||
} |
||||
List<UpdateUsualVO> updateUsualList = videoListR.getData().stream().map(video -> { |
||||
UpdateUsualVO usualVO = new UpdateUsualVO(); |
||||
usualVO.setStationId(video.getStationId()); |
||||
usualVO.setId(String.valueOf(video.getId())); |
||||
usualVO.setName(video.getName()); |
||||
return usualVO; |
||||
}).collect(Collectors.toList()); |
||||
request.put("videos", updateUsualList); |
||||
// 同步指令
|
||||
interactiveService.updateVideo(request); |
||||
return ReturnT.SUCCESS; |
||||
} |
||||
|
||||
@XxlJob(SYNCHRONOUS_SCADA_INSTRUCT) |
||||
public ReturnT synchronousScadaInstruct(String params) { |
||||
// 查询项目数据
|
||||
Result<List<ProjectVO>> projects = projectClient.getProjectByAppId(); |
||||
if(!projects.isSuccess() || CollectionUtil.isEmpty(projects.getData())){ |
||||
return ReturnT.SUCCESS; |
||||
} |
||||
// 请求fdp同步实时画面方法参数定义
|
||||
Map<String,Object> param = new HashMap<>(2); |
||||
List<UpdateStationVO> stations = projects.getData().stream().map(station -> { |
||||
UpdateStationVO updateStation = new UpdateStationVO(); |
||||
updateStation.setId(station.getId()); |
||||
updateStation.setName(station.getName()); |
||||
return updateStation; |
||||
}).collect(Collectors.toList()); |
||||
param.put("stations", stations); |
||||
// 查询画面信息
|
||||
Result<List<CanvasVO>> canvas = scadaClient.getCanvasList(projects.getData().stream().map(ProjectVO::getId).collect(Collectors.toList())); |
||||
if(!canvas.isSuccess() || CollectionUtil.isEmpty(canvas.getData())) { |
||||
return ReturnT.SUCCESS; |
||||
} |
||||
List<UpdateUsualVO> updateUsuals = canvas.getData().stream().map(canva -> { |
||||
UpdateUsualVO usualVO = new UpdateUsualVO(); |
||||
usualVO.setStationId(canva.getProjectId()); |
||||
usualVO.setName(canva.getName()); |
||||
// 画面id =
|
||||
String id = Optional.of(canva.getPicSource()).map(String::valueOf).orElse("") + "^" + |
||||
Optional.ofNullable(canva.getContext()).orElse("") + "^" + |
||||
Optional.ofNullable(canva.getStationNum()).orElse("") + "^" + |
||||
Optional.ofNullable(canva.getProjectId()).orElse("") + "^" + |
||||
Optional.ofNullable(canva.getTaskId()).map(String::valueOf).orElse("") + "^" + |
||||
Optional.ofNullable(canva.getName()).orElse("") + "^" + |
||||
Optional.ofNullable(canva.getId()).map(String::valueOf).orElse("") + "^"; |
||||
usualVO.setId(id); |
||||
return usualVO; |
||||
}).collect(Collectors.toList()); |
||||
param.put("canvases", updateUsuals); |
||||
Boolean status = interactiveService.updateCanvas(param); |
||||
return ReturnT.SUCCESS; |
||||
} |
||||
|
||||
@XxlJob(SYNCHRONOUS_FAULT_INSTRUCT) |
||||
public ReturnT synchronousFaultInstruct(String params) { |
||||
Map<String,Object> request = new HashMap<>(2); |
||||
// 获取站点列表
|
||||
R<List<StationEntity>> stationsR = stationClient.list(new StationEntity()); |
||||
if(!stationsR.isSuccess() || CollectionUtil.isEmpty(stationsR.getData())) { |
||||
XxlJobLogger.log("获取站点列表失败!"); |
||||
return ReturnT.FAIL; |
||||
} |
||||
List<UpdateStationVO> updateStationList = stationsR.getData().stream().map(station -> { |
||||
UpdateStationVO stationVO = new UpdateStationVO(); |
||||
stationVO.setId(station.getCode()); |
||||
stationVO.setName(station.getName()); |
||||
return stationVO; |
||||
}).collect(Collectors.toList()); |
||||
request.put("stations", updateStationList); |
||||
interactiveService.updateFault(request); |
||||
return ReturnT.SUCCESS; |
||||
} |
||||
} |
@ -0,0 +1,65 @@
|
||||
CREATE TABLE IF NOT EXISTS `HZIMS_TABLE_PROPERTY` ( |
||||
`ID` bigint(20) NOT NULL COMMENT '主键ID', |
||||
`DATASOURCE_ID` BIGINT(50) NOT NULL COMMENT '数据源Id', |
||||
`DATASOURCE_NAME` varchar(50) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据源名', |
||||
`DATABASE_NAME` varchar(50) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据库名', |
||||
`TABLE_NAME` varchar(100) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据表名', |
||||
`AUTH_TYPE` varchar(20) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '鉴权类型', |
||||
`TENANT_ID` varchar(12) CHARACTER SET utf8 DEFAULT NULL COMMENT '租户ID', |
||||
`STATUS` bigint(1) DEFAULT NULL COMMENT '状态', |
||||
`CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', |
||||
`CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', |
||||
`CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', |
||||
`UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', |
||||
`UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', |
||||
`IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', |
||||
PRIMARY KEY (`ID`) USING BTREE |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据库表配置'; |
||||
|
||||
CREATE TABLE IF NOT EXISTS `HZIMS_TABLE_PROPERTY` ( |
||||
`ID` bigint(20) NOT NULL COMMENT '主键ID', |
||||
`DATASOURCE_NAME` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '数据源名', |
||||
`DATABASE_NAME` varchar(50) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据库名', |
||||
`STATUS` bigint(1) DEFAULT NULL COMMENT '状态', |
||||
`CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', |
||||
`CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', |
||||
`CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', |
||||
`UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', |
||||
`UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', |
||||
`IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', |
||||
PRIMARY KEY (`ID`) USING BTREE |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据库表配置'; |
||||
|
||||
CREATE TABLE IF NOT EXISTS `hzims_whitelist` ( |
||||
`ID` bigint(20) NOT NULL COMMENT '主键ID', |
||||
`USER_ID` bigint(20) NOT NULL COMMENT '主键ID', |
||||
`ACCOUNT` varchar(255) COLLATE utf8mb4_bin NOT NULL COMMENT '用户登录账号', |
||||
`TENANT_ID` varchar(12) CHARACTER SET utf8 DEFAULT NULL COMMENT '租户ID', |
||||
`STATUS` bigint(1) DEFAULT NULL COMMENT '状态', |
||||
`CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', |
||||
`CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', |
||||
`CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', |
||||
`UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', |
||||
`UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', |
||||
`IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', |
||||
`IS_REQUIRE` tinyint(2) DEFAULT NULL COMMENT '是否必须', |
||||
PRIMARY KEY (`ID`) USING BTREE |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='模型函数参数'; |
||||
|
||||
CREATE TABLE IF NOT EXISTS `HZIMS_DATASOURCE` ( |
||||
`ID` bigint(20) NOT NULL COMMENT '主键ID', |
||||
`DATASOURCE` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '数据源', |
||||
`DATASOURCE_NAME` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '数据源名', |
||||
`DATABASE_NAME` varchar(50) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据库名', |
||||
`TENANT_ID` varchar(12) CHARACTER SET utf8 DEFAULT NULL COMMENT '租户ID', |
||||
`STATUS` bigint(1) DEFAULT NULL COMMENT '状态', |
||||
`CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', |
||||
`CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', |
||||
`CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', |
||||
`UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', |
||||
`UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', |
||||
`IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', |
||||
`IS_REQUIRE` tinyint(2) DEFAULT NULL COMMENT '是否必须', |
||||
PRIMARY KEY (`ID`) USING BTREE |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='模型函数参数'; |
||||
|
Loading…
Reference in new issue