AcsGetPointService.java
3.24 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
package com.huaheng.api.acs.service;
import com.alibaba.fastjson.JSON;
import com.huaheng.api.acs.domain.AcsPointStatus;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.http.OkHttpUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.address.service.AddressService;
import com.huaheng.pc.config.location.domain.AcsLocationStatus;
import com.huaheng.pc.config.location.service.AcsLocationStatusService;
import com.huaheng.pc.config.zone.domain.Zone;
import com.huaheng.pc.config.zone.service.ZoneService;
import com.huaheng.pc.task.agvTask.service.AgvTaskService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* 长沙agv交互接口
*/
@Service
public class AcsGetPointService {
private static final Logger logger = LoggerFactory.getLogger(AcsGetPointService.class);
@Resource
private AgvTaskService agvTaskService;
@Resource
private AddressService addressService;
@Resource
private ZoneService zoneService;
@Resource
private AcsLocationStatusService acsLocationStatusService;
public void autoGetAcsPointAll() {
autoGetAcsPoint("CX", 2);
autoGetAcsPoint("DX", 2);
autoGetAcsPoint("AX", 2);
}
public void autoGetAcsPoint(String zoneCode, Integer layer) {
try {
Zone zone = zoneService.getZoneByCode(zoneCode);
String url = addressService.selectAddress("AGV", QuantityConstant.WAREHOUSECODE, zone.getArea(), layer) + "PlaceholderTask";
String JsonParam = "";
String result = OkHttpUtils.sendPost(url,"");
if (StringUtils.isEmpty(result)) {
throw new ServiceException("ACS接口地址错误或服务器连接不到或返回为空");
}
AjaxResult ajaxResultACS = JSON.parseObject(result, AjaxResult.class);
if (!ajaxResultACS.state) {
} else {
List<AcsPointStatus> acsPointStatusList = (List<AcsPointStatus>) ajaxResultACS.getData();
if (acsPointStatusList == null) {
return;
}
String jsonString = JSON.toJSONString(acsPointStatusList);
List<AcsPointStatus> findlist = JSON.parseArray(jsonString, AcsPointStatus.class);
if (findlist != null && findlist.size() > 0) {
List<AcsLocationStatus> list = acsLocationStatusService.getAcsLocationStatusByZoneCode(zoneCode);
for (AcsLocationStatus acsLocationStatus : list) {
for (AcsPointStatus acsPointStatus : findlist) {
if (acsLocationStatus.getCode().equals(acsPointStatus.getStationCode())) {
acsLocationStatus.setAcsStatus(acsPointStatus.getPlaceholder() == true ? 1 : 2);
}
}
}
acsLocationStatusService.updateBatchById(list);
}
}
} catch (Exception e) {
}
return;
}
}