StationInfoServiceImpl.java 1.54 KB
package com.huaheng.api.wcs.service.stationInfo;


import com.alibaba.fastjson.JSON;
import com.huaheng.api.wcs.domain.WcsTask;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.http.HttpUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.address.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StationInfoServiceImpl implements StationInfoService {

    @Autowired
    private AddressService addressService;

    /**
     * 站台信息查询
     * 1、判断非空字段
     * 2、实体转换
     * 3、发送数据
     * @param station
     * @return
     */
    @Override
    public AjaxResult StationInfo(String station) {

        //1、判断非空字段
        if(StringUtils.isEmpty(station)){
            return AjaxResult.error("站台为空");
        }

        //2、实体转换
        WcsTask wcsTask =new WcsTask();
        wcsTask.setStation(station);

        //3、发送数据
        String param="wcs";
        String url=addressService.selectAddress(param)+"StationInfo";
        String JsonParam = JSON.toJSONString(wcsTask);
        String result = HttpUtils.bodypost(url, JsonParam);
        if(StringUtils.isEmpty(result)){
            throw new ServiceException("接口地址错误");
        }
        AjaxResult ajaxResult = JSON.parseObject(result, AjaxResult.class);
        return ajaxResult;

    }
}