java110
2023-06-13 ae42d2da37fe9d161e7058b51367b95f24c3d97a
service-common/src/main/java/com/java110/common/charge/factory/kehang/KeHangChargeMachineFactoryAdapt.java
@@ -4,11 +4,10 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.java110.common.charge.IChargeFactoryAdapt;
import com.java110.common.charge.factory.dingding.DingdingChargeUtils;
import com.java110.dto.chargeMachine.ChargeMachineDto;
import com.java110.dto.chargeMachineOrder.NotifyChargeOrderDto;
import com.java110.dto.chargeMachineOrder.NotifyChargePortDto;
import com.java110.dto.chargeMachinePort.ChargeMachinePortDto;
import com.java110.dto.chargeMachine.NotifyChargeOrderDto;
import com.java110.dto.chargeMachine.NotifyChargePortDto;
import com.java110.dto.chargeMachine.ChargeMachinePortDto;
import com.java110.vo.ResultVo;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
@@ -30,7 +29,7 @@
        body.put("chargeId", orderId);
        String paramOut = null;
        try {
            paramOut = DingdingChargeUtils.execute("net.equip.charge.slow.ru", body.toJSONString(), HttpMethod.GET);
            paramOut = KeHangChargeUtils.execute("net.equip.charge.slow.run", body.toJSONString(), HttpMethod.GET);
        } catch (Exception e) {
            throw new IllegalArgumentException(e.getMessage());
        }
@@ -50,7 +49,7 @@
        body.put("port", chargeMachinePortDto.getPortCode());
        String paramOut = null;
        try {
            paramOut = DingdingChargeUtils.execute("net.equip.charge.slow.run.stop", body.toJSONString(), HttpMethod.GET);
            paramOut = KeHangChargeUtils.execute("net.equip.charge.slow.run.stop", body.toJSONString(), HttpMethod.GET);
        } catch (Exception e) {
            throw new IllegalArgumentException(e.getMessage());
        }
@@ -69,7 +68,7 @@
        body.put("equipCd", chargeMachineDto.getMachineCode());
        String paramOut = null;
        try {
            paramOut = DingdingChargeUtils.execute("net.equip.charge.slow.port.query", body.toJSONString(), HttpMethod.GET);
            paramOut = KeHangChargeUtils.execute("net.equip.charge.slow.port.query", body.toJSONString(), HttpMethod.GET);
        } catch (Exception e) {
            throw new IllegalArgumentException(e.getMessage());
        }
@@ -100,6 +99,39 @@
    }
    @Override
    public void queryChargeMachineState(ChargeMachineDto chargeMachineDto) {
        JSONObject body = new JSONObject();
        body.put("equipCd", chargeMachineDto.getMachineCode());
        String paramOut = null;
        try {
            paramOut = KeHangChargeUtils.execute("net.equip.online.query", body.toJSONString(), HttpMethod.GET);
        } catch (Exception e) {
            throw new IllegalArgumentException(e.getMessage());
        }
        JSONObject paramObj = JSONObject.parseObject(paramOut);
        if (paramObj.getIntValue("code") != 1) {
            throw new IllegalArgumentException(paramObj.getString("msg"));
        }
        JSONObject data = paramObj.getJSONObject("data");
        if(data.getBoolean("online")){
            chargeMachineDto.setState(ChargeMachineDto.STATE_ONLINE);
            chargeMachineDto.setStateName("在线");
            return ;
        }
        chargeMachineDto.setState(ChargeMachineDto.STATE_OFFLINE);
        chargeMachineDto.setStateName("离线");
    }
    @Override
    public void workHeartbeat(ChargeMachineDto chargeMachineDto, String bodyParam) {
    }
    @Override
    public List<NotifyChargePortDto> getChargeHeartBeatParam(NotifyChargeOrderDto notifyChargeOrderDto) {
        return null;
    }