|
1
2
3
|
package com.huaheng.api.wcs.service.taskInfo;
import com.alibaba.fastjson.JSON;
|
|
4
|
import com.alibaba.fastjson.JSONObject;
|
|
5
|
import com.huaheng.api.wcs.domain.WcsTask;
|
|
6
|
import com.huaheng.common.constant.HttpConstant;
|
|
7
|
import com.huaheng.common.constant.QuantityConstant;
|
|
8
9
10
|
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.http.HttpUtils;
|
|
11
|
import com.huaheng.common.utils.restful.RestUtil;
|
|
12
13
14
|
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.address.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
|
|
15
|
import org.springframework.http.ResponseEntity;
|
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import org.springframework.stereotype.Service;
@Service
public class TaskInfoServiceImpl implements TaskInfoService {
@Autowired
private AddressService addressService;
/**
* 任务信息查询
* 1、判断非空字段
* 2、实体转换
* 3、发送数据
*
* @param id
* @return
*/
@Override
|
|
34
|
public AjaxResult taskInfo(String id, String warehouseCode, String area) {
|
|
35
36
37
38
39
40
41
42
43
44
45
|
//1、判断非空字段
if(id == null){
return AjaxResult.error("任务号为空");
}
//2、实体转换
WcsTask wcsTask =new WcsTask();
wcsTask.setTaskNo(id.toString());
//3、发送数据
|
|
46
|
String url = addressService.selectAddress(QuantityConstant.ADDRESS_WCS_TASK_INFO, warehouseCode, area);
|
|
47
48
49
50
51
|
String jsonParam = JSON.toJSONString(wcsTask);
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");
|
|
52
|
if (!HttpConstant.isSuccess(Integer.parseInt(code))) {
|
|
53
54
55
56
|
return AjaxResult.error(msg);
}
} else {
throw new ServiceException("接口地址错误或返回为空");
|
|
57
|
}
|
|
58
59
|
String data = result.getBody().getString("data");
AjaxResult ajaxResult = JSON.parseObject(data, AjaxResult.class);
|
|
60
61
62
|
return ajaxResult;
}
}
|