|
|
@ -1,23 +1,36 @@ |
|
|
|
package com.hnac.hzims.bigmodel.interactive.service.impl; |
|
|
|
package com.hnac.hzims.bigmodel.interactive.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; |
|
|
|
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; |
|
|
|
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; |
|
|
|
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; |
|
|
|
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.constants.StationSelectionVO; |
|
|
|
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; |
|
|
|
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.AllArgsConstructor; |
|
|
|
|
|
|
|
import lombok.Data; |
|
|
|
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Optional; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @Author: huangxing |
|
|
|
* @Author: huangxing |
|
|
|
* @Date: 2024/05/08 16:19 |
|
|
|
* @Date: 2024/05/08 16:19 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
@Service |
|
|
|
|
|
|
|
@AllArgsConstructor |
|
|
|
public class ExtraResolveStrategyService { |
|
|
|
public class ExtraResolveStrategyService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IStationClient stationClient; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 解析DFP返回extra |
|
|
|
* 解析DFP返回extra |
|
|
|
* @param extraStr DFP返回extra |
|
|
|
* @param extraStr DFP返回extra |
|
|
@ -31,6 +44,8 @@ public class ExtraResolveStrategyService { |
|
|
|
switch (funcRouteEnum) { |
|
|
|
switch (funcRouteEnum) { |
|
|
|
case DIAGNOSE: |
|
|
|
case DIAGNOSE: |
|
|
|
return this.resolveDiagnose(extra); |
|
|
|
return this.resolveDiagnose(extra); |
|
|
|
|
|
|
|
case CHOOSE_STATION: |
|
|
|
|
|
|
|
return this.resolveChooseStation(extra); |
|
|
|
default: |
|
|
|
default: |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -48,4 +63,31 @@ public class ExtraResolveStrategyService { |
|
|
|
result.setType(FunctionConstants.TypeEnum.LINK.getType()); |
|
|
|
result.setType(FunctionConstants.TypeEnum.LINK.getType()); |
|
|
|
return result; |
|
|
|
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.setSpecial(true); |
|
|
|
|
|
|
|
result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|