haungxing
9 months ago
6 changed files with 83 additions and 1 deletions
@ -0,0 +1,20 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.constants; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Getter; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/05/08 16:49 |
||||
*/ |
||||
@AllArgsConstructor |
||||
public enum ExtraTypeEnum { |
||||
/**打开页面**/ |
||||
OPEN_PAGE("1"), |
||||
/**链接**/ |
||||
LINK("2") |
||||
; |
||||
@Getter |
||||
private final String type; |
||||
|
||||
} |
@ -0,0 +1,51 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service.impl; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.ExtraTypeEnum; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; |
||||
import org.springblade.core.tool.utils.StringUtil; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.Map; |
||||
import java.util.Optional; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/05/08 16:19 |
||||
*/ |
||||
@Service |
||||
public class ExtraResolveStrategyService { |
||||
|
||||
/** |
||||
* 解析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)) { |
||||
FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(functionCode); |
||||
switch (funcRouteEnum) { |
||||
case DIAGNOSE: |
||||
return this.resolveDiagnose(extra); |
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); |
||||
} |
||||
|
||||
private ExtraVO resolveDiagnose(Map<String,Object> extra) { |
||||
ExtraVO result = new ExtraVO(); |
||||
JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); |
||||
String faultId = data.getString("fault_id"); |
||||
String faultName = data.getString("fault_name"); |
||||
result.setLabel(faultName); |
||||
// TODO 拼接诊断链接
|
||||
result.setType(ExtraTypeEnum.LINK.getType()); |
||||
return result; |
||||
} |
||||
} |
Loading…
Reference in new issue