|
1
2
3
4
|
package com.huaheng.api.wcs.service.stationInfo;
import com.alibaba.fastjson.JSON;
|
|
5
|
import com.alibaba.fastjson.JSONObject;
|
|
6
|
import com.huaheng.api.wcs.domain.WcsTask;
|
|
7
|
import com.huaheng.common.constant.HttpConstant;
|
|
8
|
import com.huaheng.common.constant.QuantityConstant;
|
|
9
10
11
|
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.http.HttpUtils;
|
|
12
|
import com.huaheng.common.utils.restful.RestUtil;
|
|
13
14
15
|
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.address.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
|
|
16
|
import org.springframework.http.ResponseEntity;
|
|
17
18
|
import org.springframework.stereotype.Service;
|
|
19
20
21
22
23
|
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
|
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
@Service
public class StationInfoServiceImpl implements StationInfoService {
@Autowired
private AddressService addressService;
/**
* 站台信息查询
* 1、判断非空字段
* 2、实体转换
* 3、发送数据
* @param station
* @return
*/
@Override
|
|
39
|
public AjaxResult StationInfo(String station, String warehouseCode, String area) {
|
|
40
41
42
43
44
45
46
|
//1、判断非空字段
if(StringUtils.isEmpty(station)){
return AjaxResult.error("站台为空");
}
//2、实体转换
|
|
47
48
49
50
|
Map<String , List> map =new HashMap<>();
List list = new ArrayList();
list.add(station);
map.put("port",list);
|
|
51
52
|
//3、发送数据
|
|
53
54
|
String url = addressService.selectAddress(QuantityConstant.ADDRESS_WCS_STATION_INFOS,
warehouseCode, area);
|
|
55
56
57
58
59
|
String jsonParam = JSON.toJSONString(map);
ResponseEntity<JSONObject> result = RestUtil.request_post(url, warehouseCode, jsonParam);
if (result != null && result.getBody() != null) {
String code = result.getBody().getString("code");
String msg = result.getBody().getString("msg");
|
|
60
|
if (!HttpConstant.isSuccess(Integer.parseInt(code))) {
|
|
61
62
63
64
|
return AjaxResult.error(msg);
}
} else {
throw new ServiceException("接口地址错误或返回为空");
|
|
65
|
}
|
|
66
67
|
String data = result.getBody().getString("data");
AjaxResult ajaxResult = JSON.parseObject(data, AjaxResult.class);
|
|
68
69
70
71
|
return ajaxResult;
}
}
|