TaskAssignServiceImpl.java
3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package com.huaheng.api.wcs.service.taskAssignService;
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 com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 任务下发接口ServiceImpl层
* @author ricard
* @date 2019/10/11
*
*/
@Service
public class TaskAssignServiceImpl implements TaskAssignService {
@Autowired
private AddressService addressService;
public static String platform = "wms";
//wms下发任务给wcs
/**
* 1、判断taskHeader是否为空
* 2、判断必填字段是否满足
* 3、转换实体
* 4、发送数据
*
* @param taskHeader
* @return
*/
@Override
@Transactional
public AjaxResult wcsTaskAssign(TaskHeader taskHeader) {
//1、判断taskHeader是否为空
if(taskHeader == null){
throw new ServiceException("wms任务为空");
}
//2、判断必填字段是否满足
if(taskHeader.getId() == null){
throw new ServiceException("wms任务号Id为空");
}
if(taskHeader.getTaskType() == null){
throw new ServiceException("wms任务类型为空");
}
if(StringUtils.isEmpty(taskHeader.getContainerCode())){
throw new ServiceException("wms任务中容器为空");
}
// if(StringUtils.isEmpty(taskHeader.getStation())){
// throw new ServiceException("wms站台为空");
// }
//入库性质的任务源库位不能为空
if(taskHeader.getTaskType()==100 || taskHeader.getTaskType()==200
|| taskHeader.getTaskType()==500 || taskHeader.getTaskType()==800) {
if (taskHeader.getFromLocation() == null) {
throw new ServiceException("源库位为空");
}
}
// 出库性质的任务目的库位不能为空
if(taskHeader.getTaskType()==300 || taskHeader.getTaskType()==400
|| taskHeader.getTaskType()==600 || taskHeader.getTaskType()==700
|| taskHeader.getTaskType()==800 || taskHeader.getTaskType()==900)
{
if (taskHeader.getToLocation() == null) {
throw new ServiceException("目的库位为空");
}
}
//3、转换实体,初始化wcs任务实体
WcsTask wcsTask = new WcsTask();
wcsTask.setTaskNo(taskHeader.getId().toString());
wcsTask.setTaskType(taskHeader.getTaskType().toString());
// wcsTask.setStation(taskHeader.getStation);
wcsTask.setPalletNo(taskHeader.getContainerCode());
wcsTask.setFromLocationCode(taskHeader.getFromLocation());
wcsTask.setToLocationCode(taskHeader.getToLocation());
wcsTask.setPlatform(platform);
//4、发送数据
String param="wcs";
String url=addressService.selectAddress(param)+"TaskAssign";
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;
}
}