AcsServiceImpl.java
4.17 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.acs.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.common.constant.HttpConstant;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.restful.RestUtil;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.address.service.AddressService;
import com.huaheng.pc.task.agvTask.domain.AgvTask;
import com.huaheng.pc.task.agvTask.service.AgvTaskService;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @ClassName AcsServiceImpl
* @Description TODO
* @Author youjie
* @Date 2019/12/2615:38
*/
@Service
public class AcsServiceImpl implements AcsService {
@Resource
private AgvTaskService agvTaskService;
@Resource
private AddressService addressService;
@Override
public AjaxResult createAGVTask(AgvTask agvTask) {
String url = addressService.selectAddress(QuantityConstant.ADDRESS_AGV_TASK_ASSIGN);
String jsonParam = JSON.toJSONString(agvTask);
String warehouseCode = agvTask.getWarehouseCode();
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");
if (Integer.parseInt(code) != HttpConstant.OK) {
return AjaxResult.error(msg);
}
} else {
throw new ServiceException("接口地址错误或返回为空");
}
return AjaxResult.success("创建AGV任务成功");
}
@Override
public AjaxResult cancelAGVTask(AgvTask agvTask) {
String url = addressService.selectAddress(QuantityConstant.ADDRESS_AGV_TASK_CANCEL);
String jsonParam = JSON.toJSONString(agvTask);
String warehouseCode = agvTask.getWarehouseCode();
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");
if (Integer.parseInt(code) != HttpConstant.OK) {
return AjaxResult.error(msg);
}
} else {
throw new ServiceException("接口地址错误或返回为空");
}
return AjaxResult.success("取消AGV任务成功");
}
@Override
public AjaxResult updateAGVTask(AgvTask agvTask) {
String url = addressService.selectAddress(QuantityConstant.ADDRESS_AGV_TASK_UPDATE);
String jsonParam = JSON.toJSONString(agvTask);
String warehouseCode = agvTask.getWarehouseCode();
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");
if (Integer.parseInt(code) != HttpConstant.OK) {
return AjaxResult.error(msg);
}
} else {
throw new ServiceException("接口地址错误或返回为空");
}
return AjaxResult.success("更新AGV任务成功");
}
@Override
public AjaxResult notifyAGVTask(String taskNo, String carNo, int status, String updateBy) {
AgvTask agvTask = agvTaskService.getById(taskNo);
if(agvTask == null) {
return AjaxResult.error("没有找到对应AGV任务,任务号为" + taskNo);
}
agvTask.setStatus(status);
agvTask.setCarNo(carNo);
agvTask.setLastUpdatedBy(updateBy);
boolean result = agvTaskService.updateById(agvTask);
if(!result) {
return AjaxResult.error("更新任务信息失败 ");
}
return AjaxResult.success("更新任务信息成功");
}
}