Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java
zhongwei
yang_shj 6 months ago
parent
commit
41aafa07a8
  1. 16
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java
  2. 5
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java
  3. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java
  4. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java
  5. 22
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java
  6. 11
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java
  7. 7
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java
  8. 1
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java
  9. 19
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java
  10. 1
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java
  11. 3
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java
  12. 3
      hzims-service/message/src/main/java/com/hnac/hzims/message/web/MsgWsRecordHistoryController.java

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

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

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

@ -12,12 +12,13 @@ import java.util.Optional;
*/
@AllArgsConstructor
public enum FuncRouteEnum {
OPEN_SCADA("open_scada","打开实时画面"),
OPEN_CANVAS("open_canvas","打开实时画面"),
OPEN_VIDEO("open_video","打开视频监控"),
DIAGNOSE("diagnose","智能诊断"),
CHOOSE_STATION("choose_station","选择站点"),
CHOOSE_VIDEO("choose_video","选择视频"),
CHOOSE_CANVAS("choose_canvas","选择画面"),
CHOOSE_FAULT("choose_fault","选择故障"),
;
@Getter
private String funcCode;
@ -26,7 +27,7 @@ public enum FuncRouteEnum {
public static FuncRouteEnum getEnumByFuncCode(String funcCode) {
Optional<FuncRouteEnum> FuncRoute = Arrays.stream(FuncRouteEnum.class.getEnumConstants()).filter(e -> funcCode.equals(e.getFuncCode())).findFirst();
return FuncRoute.get();
return FuncRoute.orElse(null);
}
}

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

@ -48,8 +48,8 @@ public class InteractiveController {
@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 funcCode) {
return R.status(interactiveService.authentication(stationId,userId,funcCode));
@RequestParam(required = false) @ApiParam("菜单ID") String func) {
return R.status(interactiveService.authentication(stationId,userId,func));
}
@ApiOperation("获取问答sessionId")

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

@ -30,7 +30,7 @@ public interface IInteractiveService {
List<AnswerVO> getAnswerBySessionIds(String sessionIds);
Boolean authentication(String stationId, String userId, String funcCode);
Boolean authentication(String stationId, String userId, String func);
Boolean removeSessionId(String sessionId);
}

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

@ -5,10 +5,7 @@ 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.vo.ScadaSelectionVO;
import com.hnac.hzims.bigmodel.interactive.vo.StationSelectionVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.bigmodel.interactive.vo.VideoSelectionVO;
import com.hnac.hzims.bigmodel.interactive.vo.*;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
@ -50,6 +47,7 @@ public class ExtraResolveStrategyService {
if(StringUtil.isNotBlank(functionCode)) {
XxlJobLogger.log("函数编号为:" + functionCode);
FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(functionCode);
if(Func.isNotEmpty(funcRouteEnum)) {
switch (funcRouteEnum) {
case DIAGNOSE:
return this.resolveDiagnose(extra);
@ -59,13 +57,29 @@ public class ExtraResolveStrategyService {
return this.resolveChooseVideo(extra);
case CHOOSE_CANVAS:
return this.resolveChooseScada(extra);
case CHOOSE_FAULT:
return this.resolveChooseFault(extra);
default:
break;
}
}
}
return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class);
}
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")));

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

@ -73,6 +73,9 @@ public class InteractiveServiceImpl implements IInteractiveService {
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:
@ -194,7 +197,7 @@ public class InteractiveServiceImpl implements IInteractiveService {
}
@Override
public Boolean authentication(String stationId, String userId, String funcCode) {
public Boolean authentication(String stationId, String userId, String func) {
// 站点鉴权
if(StringUtil.isNotBlank(stationId)) {
List<String> stations = this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId)
@ -204,9 +207,9 @@ public class InteractiveServiceImpl implements IInteractiveService {
});
}
// 菜单鉴权
if(StringUtil.isNotBlank(funcCode) && StringUtil.isNotBlank(userId)) {
FunctionEntity function = functionService.getFunctionByCode(funcCode);
if(Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) {
if(StringUtil.isNotBlank(func) && StringUtil.isNotBlank(userId)) {
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("人员菜单鉴权失败!");

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

@ -40,7 +40,7 @@ public class JumpRouteJoinStrategy {
FuncRouteEnum routeEnum = FuncRouteEnum.getEnumByFuncCode(function.getCode());
if(Func.isNotEmpty(routeEnum)) {
switch(routeEnum) {
case OPEN_SCADA:
case OPEN_CANVAS:
return this.getScadaExtra(args,function);
default:
break;
@ -53,13 +53,16 @@ public class JumpRouteJoinStrategy {
// 跳转页面逻辑
ExtraVO extraVO = new ExtraVO();
extraVO.setImmediatelyJump(true);
extraVO.setFuncCode(FuncRouteEnum.OPEN_SCADA.getFuncCode());
extraVO.setFuncCode(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");

1
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java

@ -194,7 +194,6 @@ public class InteractiveSchedule {
}
@XxlJob(SYNCHRONOUS_FAULT_INSTRUCT)
//@Scheduled(cron = "0/10 * * * * ?")
public ReturnT synchronousFaultInstruct(String params) {
Map<String,Object> request = new HashMap<>(2);
// 获取站点列表

19
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java

@ -90,6 +90,9 @@ public class InteractiveHandler extends TextWebSocketHandler {
case CHOOSE_CANVAS:
this.handleScadaChoose(messageContext,sessionId);
break;
case CHOOSE_FAULT:
this.handleFaultChoose(messageContext,sessionId);
break;
default:
break;
}
@ -147,7 +150,7 @@ public class InteractiveHandler extends TextWebSocketHandler {
Map<String,String> param = new HashMap<>(1);
param.put("canvas_id",selection.getId());
IFunctionService functionService = SpringUtil.getBean(IFunctionService.class);
FunctionEntity function = functionService.getFunctionByCode("open_scada");
FunctionEntity function = functionService.getFunctionByCode(FuncRouteEnum.OPEN_CANVAS.getFuncCode());
ExtraVO scadaExtra = strategy.getScadaExtra(param, function);
AnswerVO answerVO = new AnswerVO();
answerVO.setSessionId(sessionId);
@ -168,4 +171,18 @@ public class InteractiveHandler extends TextWebSocketHandler {
wsService.sendMessage(sessionId,textMessage);
}
}
private void handleFaultChoose(JSONObject messageContext,String sessionId) {
IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class);
String userId = messageContext.getString("userId");
String funcCode = messageContext.getString("funcCode");
FaultSelectionVO selectionVO = messageContext.getObject("selection",FaultSelectionVO.class);
JSONObject data = new JSONObject();
data.put("id",selectionVO.getId());
data.put("name",selectionVO.getName());
Map<String, Object> extra = new HashMap<>(2);
extra.put("func",funcCode);
extra.put("data",data);
interactiveService.specialAsk(sessionId,userId,extra);
}
}

1
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java

@ -129,6 +129,7 @@ public class RobotServiceImpl extends BaseServiceImpl<RobotMapper, RobotEntity>
Optional<DeviceInstanceAttrVO> attrOptional = paramDeviceAttrR.getData().stream().filter(deviceAttr -> k.getValue().getN().equals(deviceAttr.getName())).findFirst();
data.setModelClassifyId(attrOptional.get().getModelClassifyId());
data.setModelClassifyName(attrOptional.get().getModelClassifyName());
data.setUnits(attrOptional.get().getUnits());
return data;
})).collect(Collectors.toList());
return result.stream().collect(Collectors.groupingBy(RobotRealDataVO::getModelClassifyName));

3
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java

@ -49,4 +49,7 @@ public class RobotRealDataVO implements Serializable {
@ApiModelProperty("启停状态")
private Integer state;
@ApiModelProperty("单位")
private String units;
}

3
hzims-service/message/src/main/java/com/hnac/hzims/message/web/MsgWsRecordHistoryController.java

@ -1,4 +1,4 @@
package com.hnac.hzims.message.controller;
package com.hnac.hzims.message.web;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
* @author xiashandong
* @created 2021-06-28 16:45
**/
@Deprecated
@RestController
@AllArgsConstructor
@RequestMapping("/msg/ws/record/history")

Loading…
Cancel
Save