Blame view

src/main/java/com/huaheng/api/wcs/service/stationInfo/StationInfoServiceImpl.java 1.7 KB
pengcheng authored
1
2
3
4
5
6
7
8
9
10
11
12
13
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;
14
15
16
17
18
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
pengcheng authored
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
@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、实体转换
42
43
44
45
        Map<String , List> map =new HashMap<>();
        List list = new ArrayList();
        list.add(station);
        map.put("port",list);
pengcheng authored
46
47
48
49

        //3、发送数据
        String param="wcs";
        String url=addressService.selectAddress(param)+"StationInfo";
50
        String JsonParam = JSON.toJSONString(map);
pengcheng authored
51
52
53
54
55
56
57
58
59
        String result = HttpUtils.bodypost(url, JsonParam);
        if(StringUtils.isEmpty(result)){
            throw new ServiceException("接口地址错误");
        }
        AjaxResult ajaxResult = JSON.parseObject(result, AjaxResult.class);
        return ajaxResult;

    }
}