haungxing
5 months ago
42 changed files with 735 additions and 1350 deletions
@ -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,35 @@
|
||||
package com.hnac.hzims.bigmodel.business.feign; |
||||
|
||||
import com.hnac.hzims.bigmodel.business.dto.ControlDeviceAuthDTO; |
||||
import org.springblade.core.tool.api.R; |
||||
|
||||
/** |
||||
* @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); |
||||
} |
@ -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,51 @@
|
||||
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.List; |
||||
import java.util.Optional; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/07/09 09:31 |
||||
*/ |
||||
@Component |
||||
@AllArgsConstructor |
||||
@Slf4j |
||||
public class AuthClient implements IAuthClient { |
||||
|
||||
private final AuthenticationService authenticationService; |
||||
|
||||
@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("鉴权成功"); |
||||
} |
||||
|
||||
@Override |
||||
public R stationAuth(String userId, String stationId) { |
||||
return R.status(authenticationService.stationAuthentication(stationId,userId)); |
||||
} |
||||
|
||||
@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); |
||||
} |
||||
} |
@ -1,34 +0,0 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.controller; |
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.validation.annotation.Validated; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/05/29 09:22 |
||||
*/ |
||||
@RequestMapping("/analyse/data") |
||||
@AllArgsConstructor |
||||
@Api(value = "数据查询管理",tags = "数据查询管理") |
||||
@RestController |
||||
@Deprecated |
||||
public class AnalyseDataController { |
||||
|
||||
private final IAnalyseDataService analyseDataService; |
||||
|
||||
@GetMapping("/getHistoryData") |
||||
@ApiOperation("获取历史数据") |
||||
@ApiOperationSupport(order = 1) |
||||
public R getHistoryData(@Validated HistoryDataSearchVO searchVO) { |
||||
return R.data(analyseDataService.getHistoryData(searchVO)); |
||||
} |
||||
} |
@ -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,15 +0,0 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service; |
||||
|
||||
import com.hnac.hzims.bigmodel.entity.FunctionEntity; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/05/09 08:50 |
||||
*/ |
||||
@Deprecated |
||||
public interface IParamsService { |
||||
String dealJumpTypeFunction(FunctionEntity function, Map<String,String> args); |
||||
|
||||
} |
@ -1,259 +0,0 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service.impl; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.SearchTypeEnum; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.*; |
||||
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; |
||||
import com.hnac.hzims.operational.station.feign.IStationClient; |
||||
import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; |
||||
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; |
||||
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; |
||||
import com.xxl.job.core.log.XxlJobLogger; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.*; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.time.format.DateTimeFormatter; |
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/05/08 16:19 |
||||
*/ |
||||
@Service |
||||
@AllArgsConstructor |
||||
@Deprecated |
||||
public class ExtraResolveStrategyService { |
||||
|
||||
public static final String PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss.SSS"; |
||||
|
||||
public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN_DATETIME); |
||||
|
||||
private final IStationClient stationClient; |
||||
private final IStationVideoTypeClient videoTypeClient; |
||||
private final JumpRouteJoinStrategy jumpRouteJoinStrategy; |
||||
private final DeviceClient deviceClient; |
||||
private final IAnalyseDataService analyseDataService; |
||||
|
||||
/** |
||||
* 解析DFP返回extra |
||||
* @param extraStr DFP返回extra |
||||
* @return 与前端交互extra |
||||
*/ |
||||
public ExtraVO resolve(String extraStr) { |
||||
JSONObject extra = JSONObject.parseObject(extraStr); |
||||
String functionCode = Optional.ofNullable(extra.get("func")).map(String::valueOf).orElse(""); |
||||
if(StringUtil.isNotBlank(functionCode)) { |
||||
XxlJobLogger.log("函数编号为:" + functionCode); |
||||
FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(functionCode); |
||||
if(Func.isNotEmpty(funcRouteEnum)) { |
||||
switch (funcRouteEnum) { |
||||
case DIAGNOSE: |
||||
return this.resolveDiagnose(extra); |
||||
case CHOOSE_VIDEO: |
||||
case CHOOSE_CANVAS: |
||||
case CHOOSE_STATION: |
||||
case CHOOSE_FAULT: |
||||
case CHOOSE_YC: |
||||
case CHOOSE_YK: |
||||
return this.resolveChooseSelection(extra,funcRouteEnum); |
||||
case CONFIRM_YK: |
||||
return this.resolveConfirmRemote(extra); |
||||
case SHOW_PARAM: |
||||
return this.resolveShowParam(extra); |
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
else if(extra.containsKey("extra")){ |
||||
return extra.getObject("extra",ExtraVO.class); |
||||
} |
||||
return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); |
||||
} |
||||
|
||||
private ExtraVO resolveChooseSelection(JSONObject extra,FuncRouteEnum funcRouteEnum) { |
||||
ExtraVO result = new ExtraVO(); |
||||
JSONArray selections = JSONArray.parseArray(JSON.toJSONString(extra.get("data"))); |
||||
result.setFunc(funcRouteEnum.getFuncCode()); |
||||
result.setSpecial(true); |
||||
result.setSelection(selections); |
||||
result.setType(funcRouteEnum.getType().getType()); |
||||
return result; |
||||
} |
||||
|
||||
// private ExtraVO resolveChooseYc(JSONObject extra) {
|
||||
// ExtraVO result = new ExtraVO();
|
||||
// JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")));
|
||||
// if(data.containsKey("yks")) {
|
||||
//
|
||||
//
|
||||
// List<AttrSelectionVO> attrs = JSONArray.parseArray(JSON.toJSONString(data.get("yks")), AttrSelectionVO.class);
|
||||
// result.setSelection(attrs);
|
||||
// }
|
||||
// result.setFuncCode(FuncRouteEnum.CHOOSE_YC.getFuncCode());
|
||||
// result.setSpecial(true);
|
||||
// result.setType(FuncRouteEnum.CHOOSE_YC.getType().getType());
|
||||
// return result;
|
||||
// }
|
||||
|
||||
private ExtraVO resolveShowParam(Map<String,Object> extra) { |
||||
DataVO data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")),DataVO.class); |
||||
if(Func.isNotEmpty(data)) { |
||||
if(Func.isNotEmpty(data.getReal())) { |
||||
if(Func.isNotEmpty(data.getReal().getTime()) && StringUtil.isNotBlank(data.getReal().getTime())) { |
||||
RealDataVO real = data.getReal(); |
||||
Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME); |
||||
real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME)); |
||||
} |
||||
} |
||||
if(Func.isNotEmpty(data.getItem()) && StringUtil.isNotBlank(data.getMethod())) { |
||||
if(SearchTypeEnum.HISTORY.getSearchType().equals(data.getType()) && Func.isNotEmpty(data.getItem())) { |
||||
DataItemVO item = data.getItem(); |
||||
HistoryDataSearchVO searchVO = new HistoryDataSearchVO(); |
||||
searchVO.setDataType(data.getDataType()); |
||||
searchVO.setAttrName(item.getAttrName()); |
||||
searchVO.setDeviceCode(item.getDeviceId()); |
||||
searchVO.setDeviceName(item.getDeviceName()); |
||||
searchVO.setStationName(item.getProjectName()); |
||||
searchVO.setMethod(data.getMethod()); |
||||
searchVO.setSignage(item.getSignage()); |
||||
searchVO.setStartTime(data.getStartTime()); |
||||
searchVO.setEndTime(data.getEndTime()); |
||||
return analyseDataService.getHistoryData(searchVO); |
||||
} |
||||
} |
||||
} |
||||
ExtraVO result = new ExtraVO(); |
||||
result.setFunc(FuncRouteEnum.SHOW_PARAM.getFuncCode()); |
||||
result.setType(FuncRouteEnum.SHOW_PARAM.getType().getType()); |
||||
Map<String,Object> param = new HashMap(1); |
||||
param.put("data", data); |
||||
result.setParams(param); |
||||
return result; |
||||
} |
||||
|
||||
@Deprecated |
||||
private ExtraVO resolveConfirmRemote(Map<String,Object> extra) { |
||||
ExtraVO result = new ExtraVO(); |
||||
RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(extra.get("data")), RemoteParamVO.class); |
||||
result.setFunc(FuncRouteEnum.CONFIRM_YK.getFuncCode()); |
||||
result.setType(FuncRouteEnum.CONFIRM_YK.getType().getType()); |
||||
R<DeviceInstanceFuncVO> funcVOR = deviceClient.getFuncById(remoteParam.getFuncId()); |
||||
if(funcVOR.isSuccess()) { |
||||
Map<String,Object> param = new HashMap(); |
||||
param.put("control",funcVOR.getData()); |
||||
param.put("deviceName",remoteParam.getDeviceName()); |
||||
param.put("projectName",remoteParam.getProjectName()); |
||||
param.put("deviceCode",remoteParam.getDeviceId()); |
||||
param.put("value",remoteParam.getValue()); |
||||
result.setParams(param); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
// private ExtraVO resolveChooseFault(Map<String,Object> extra) {
|
||||
// ExtraVO result = new ExtraVO();
|
||||
// JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")));
|
||||
// if(data.containsKey("faults")) {
|
||||
// List<FaultSelectionVO> faults = JSONArray.parseArray(JSON.toJSONString(data.get("faults")), FaultSelectionVO.class);
|
||||
// result.setSelection(faults);
|
||||
// }
|
||||
// result.setFuncCode(FuncRouteEnum.CHOOSE_FAULT.getFuncCode());
|
||||
// result.setSpecial(true);
|
||||
// result.setType(FunctionConstants.TypeEnum.CHOOSE.getType());
|
||||
// return result;
|
||||
// }
|
||||
|
||||
private ExtraVO resolveDiagnose(Map<String,Object> extra) { |
||||
ExtraVO result = new ExtraVO(); |
||||
JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); |
||||
Map<String,Object> params = new HashMap<>(5); |
||||
params.put("faultId",data.getString("fault_id")); |
||||
params.put("name",data.getString("fault_name")); |
||||
params.put("station",data.getString("station_id")); |
||||
params.put("fdpDeviceName",data.getString("device_name")); |
||||
params.put("fdpOrd",data.getString("ord")); |
||||
result.setParams(params); |
||||
result.setFunc(FuncRouteEnum.DIAGNOSE.getFuncCode()); |
||||
result.setType(FunctionConstants.TypeEnum.PARAMS.getType()); |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @param extra |
||||
* @return |
||||
*/ |
||||
// private ExtraVO resolveChooseStation(Map<String,Object> extra) {
|
||||
// ExtraVO result = new ExtraVO();
|
||||
// JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")));
|
||||
// if(data.containsKey("stations")) {
|
||||
// List<String> stations = JSONArray.parseArray(JSON.toJSONString(data.get("stations")), String.class);
|
||||
// List<StationSelectionVO> selectionList = stations.stream().map(stationId -> {
|
||||
// StationSelectionVO selectionVO = new StationSelectionVO();
|
||||
// R<StationEntity> stationR = stationClient.getStationByCode(stationId);
|
||||
// if (stationR.isSuccess() && Func.isNotEmpty(stationR.getData())) {
|
||||
// selectionVO.setId(stationId);
|
||||
// selectionVO.setName(stationR.getData().getName());
|
||||
// }
|
||||
// return selectionVO;
|
||||
// }).collect(Collectors.toList());
|
||||
// result.setSelection(selectionList);
|
||||
// result.setFuncCode(FuncRouteEnum.CHOOSE_STATION.getFuncCode());
|
||||
// result.setSpecial(true);
|
||||
// result.setType(FunctionConstants.TypeEnum.CHOOSE.getType());
|
||||
// }
|
||||
// result.setType(FunctionConstants.TypeEnum.CHOOSE.getType());
|
||||
// return result;
|
||||
// }
|
||||
|
||||
private ExtraVO resolveChooseVideo(Map<String,Object> extra) { |
||||
ExtraVO result = new ExtraVO(); |
||||
JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); |
||||
if(data.containsKey("videos")) { |
||||
List<JSONObject> videoIds = JSONArray.parseArray(JSON.toJSONString(data.get("videos")), JSONObject.class); |
||||
List<VideoSelectionVO> selections = videoIds.stream().map(video -> { |
||||
R<StationVideoTypeEntity> videoR = videoTypeClient.getById(Long.valueOf(video.getString("id"))); |
||||
VideoSelectionVO selectionVO = new VideoSelectionVO(); |
||||
if (videoR.isSuccess() && Func.isNotEmpty(videoR.getData())) { |
||||
selectionVO.setId(video.getString("id")); |
||||
selectionVO.setName(videoR.getData().getName()); |
||||
} |
||||
return selectionVO; |
||||
}).collect(Collectors.toList()); |
||||
result.setFunc(FuncRouteEnum.CHOOSE_VIDEO.getFuncCode()); |
||||
result.setSpecial(true); |
||||
result.setSelection(selections); |
||||
} |
||||
result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); |
||||
return result; |
||||
} |
||||
|
||||
private ExtraVO resolveChooseScada(Map<String,Object> extra) { |
||||
ExtraVO result = new ExtraVO(); |
||||
JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); |
||||
if(data.containsKey("canvases")) { |
||||
List<JSONObject> canvases = JSONArray.parseArray(JSON.toJSONString(data.get("canvases")), JSONObject.class); |
||||
List<ScadaSelectionVO> selections = canvases.stream().map(canvas -> { |
||||
ScadaSelectionVO selectionVO = new ScadaSelectionVO(); |
||||
Map<String, String> resolve = jumpRouteJoinStrategy.resolve(canvas.getString("id"), JumpRouteJoinStrategy.SCADA_PARAMS_SOLVE); |
||||
selectionVO.setId(canvas.getString("id")); |
||||
selectionVO.setName(resolve.get("name")); |
||||
return selectionVO; |
||||
}).collect(Collectors.toList()); |
||||
result.setFunc(FuncRouteEnum.CHOOSE_CANVAS.getFuncCode()); |
||||
result.setSpecial(true); |
||||
result.setSelection(selections); |
||||
} |
||||
result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); |
||||
return result; |
||||
} |
||||
} |
@ -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,36 +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.interactive.service.IParamsService; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.util.Assert; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Optional; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/05/09 08:51 |
||||
*/ |
||||
@Service |
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
@Deprecated |
||||
public class ParamsServiceImpl implements IParamsService { |
||||
|
||||
private final ParamStrategy strategy; |
||||
|
||||
@Override |
||||
public String dealJumpTypeFunction(FunctionEntity function, Map<String, String> args) { |
||||
// 跳转页面逻辑
|
||||
ExtraVO extraVO = strategy.resolve(function,args); |
||||
return JSON.toJSONString(extraVO); |
||||
} |
||||
} |
@ -0,0 +1,67 @@
|
||||
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.*; |
||||
|
||||
/** |
||||
* @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)); |
||||
} |
||||
|
||||
} |
@ -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,33 @@
|
||||
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 datasourceName; |
||||
|
||||
@ApiModelProperty("数据库名称") |
||||
@QueryField(condition = SqlCondition.LIKE) |
||||
private String databaseName; |
||||
|
||||
} |
@ -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,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,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> { |
||||
|
||||
} |
@ -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,31 @@
|
||||
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='数据库表配置'; |
Loading…
Reference in new issue