AcsGetPointService.java
2.92 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
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.task.agvTask.service.AgvTaskService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
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 AcsLocationStatusService acsLocationStatusService;
public void autoGetAcsPointAll() {
autoGetAcsPoint("3",2);
autoGetAcsPoint("4",2);
}
@Transactional(rollbackFor = Exception.class)
public void autoGetAcsPoint(String area,Integer layer) {
String url = addressService.selectAddress("AGV", QuantityConstant.WAREHOUSECODE, area, layer) + "PlaceholderTask";
String JsonParam="";
String result = OkHttpUtils.bodypost(url, JsonParam, "", "获取AGV占位");
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.getAcsLocationStatusByArea(area);
for (AcsLocationStatus acsLocationStatus:list){
for (AcsPointStatus acsPointStatus:findlist){
if(acsLocationStatus.getCode().equals(acsPointStatus.getStationCode())){
acsLocationStatus.setAcsStatus(acsPointStatus.getPlaceholder()==true?1:2);
}
}
}
acsLocationStatusService.updateBatchById(list);
}
}
return;
}
}