17 changed files with 561 additions and 201 deletions
@ -0,0 +1,49 @@ |
|||
package org.nl.acs.agv.rest; |
|||
|
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import net.sf.json.JSONObject; |
|||
import org.nl.acs.agv.server.AgvService; |
|||
import org.nl.annotation.Log; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @author zhangjiangwei |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/api/agv/xg") |
|||
@RequiredArgsConstructor |
|||
@Api(tags = "仙工AGV") |
|||
@Slf4j |
|||
public class XGAGVController { |
|||
|
|||
private final AgvService agvService; |
|||
|
|||
@PostMapping("/controlDoor") |
|||
@Log("仙工AGV控制门开关") |
|||
@ApiOperation("仙工AGV控制门开关") |
|||
public ResponseEntity<JSONObject> xgAGVControlDoorSwitch(@RequestBody JSONObject requestParam) { |
|||
return new ResponseEntity<>(agvService.xgAGVControlDoorSwitch(requestParam), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/doorStateList") |
|||
@Log("仙工AGV查询门状态") |
|||
@ApiOperation("仙工AGV查询门状态") |
|||
public ResponseEntity<JSONObject> xgAGVQueryDoorStatus(@RequestBody JSONObject requestParam) { |
|||
return new ResponseEntity<>(agvService.xgAGVQueryDoorStatus(requestParam), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/waitPointRequest") |
|||
@Log("仙工AGV请求取放货") |
|||
@ApiOperation("仙工AGV请求取放货") |
|||
public ResponseEntity<JSONObject> xgAGVWaitPointRequest(@RequestBody JSONObject requestParam) { |
|||
return new ResponseEntity<>(agvService.xgAGVWaitPointRequest(requestParam), HttpStatus.OK); |
|||
} |
|||
} |
@ -0,0 +1,136 @@ |
|||
package org.nl.acs.agv.server; |
|||
|
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import net.sf.json.JSONArray; |
|||
import net.sf.json.JSONObject; |
|||
import org.nl.acs.ext.wms.service.AcsToWmsService; |
|||
import org.nl.acs.ext.wms.service.impl.AcsToWmsZDServiceImpl; |
|||
import org.nl.acs.instruction.service.InstructionService; |
|||
import org.nl.acs.log.service.LogServer; |
|||
import org.nl.acs.opc.DeviceAppService; |
|||
import org.nl.exception.BadRequestException; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* @author: geng by |
|||
* @createDate: 2022/12/5 |
|||
*/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class AgvWaitUtil { |
|||
private final DeviceAppService deviceAppService; |
|||
private final AcsToWmsZDServiceImpl acsToWmsZDService; |
|||
private final InstructionService instructionService; |
|||
private final AcsToWmsService acsToWmsService; |
|||
@Autowired |
|||
LogServer logServer; |
|||
|
|||
//取货前等待
|
|||
public JSONObject waitInGet(String startDeviceCode) { |
|||
log.info("仙工AGV请求取货,设备号 - {}", startDeviceCode); |
|||
|
|||
JSONObject requestWMSParam = new JSONObject(); |
|||
requestWMSParam.put("StartStationCode", startDeviceCode); |
|||
JSONObject responseBody = acsToWmsService.gccQueryStationState(requestWMSParam); |
|||
|
|||
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) { |
|||
JSONArray data = responseBody.optJSONArray("data"); |
|||
for (int i = 0; i < data.size(); i++) { |
|||
JSONObject datum = data.getJSONObject(i); |
|||
if (startDeviceCode.equals(datum.optString("Station_Code")) |
|||
&& datum.optBoolean("IsHasGoods")) { |
|||
JSONObject map = new JSONObject(); |
|||
map.put("status", 200); |
|||
map.put("message", "允许取货!"); |
|||
log.info("允许仙工AGV取货,设备号 - {}", startDeviceCode); |
|||
return map; |
|||
} |
|||
} |
|||
} |
|||
|
|||
throw new BadRequestException("请求失败!"); |
|||
} |
|||
|
|||
//取货完成等待
|
|||
public JSONObject waitOutGet(String startDeviceCode) { |
|||
log.info("仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode); |
|||
|
|||
JSONObject requestWMSParam = new JSONObject(); |
|||
requestWMSParam.put("StartStationCode", startDeviceCode); |
|||
JSONObject responseBody = acsToWmsService.gccQueryStationState(requestWMSParam); |
|||
|
|||
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) { |
|||
JSONArray data = responseBody.optJSONArray("data"); |
|||
for (int i = 0; i < data.size(); i++) { |
|||
JSONObject datum = data.getJSONObject(i); |
|||
if (startDeviceCode.equals(datum.optString("Station_Code")) |
|||
&& !datum.optBoolean("IsHasGoods", true)) { |
|||
JSONObject map = new JSONObject(); |
|||
map.put("status", 200); |
|||
map.put("message", "允许离开!"); |
|||
log.info("允许仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode); |
|||
return map; |
|||
} |
|||
} |
|||
} |
|||
|
|||
throw new BadRequestException("请求失败!"); |
|||
} |
|||
|
|||
//放货前等待
|
|||
public JSONObject waitInPut(String endDeviceCode) { |
|||
log.info("仙工AGV请求放货,设备号 - {}", endDeviceCode); |
|||
|
|||
JSONObject requestWMSParam = new JSONObject(); |
|||
requestWMSParam.put("EndStationCode", endDeviceCode); |
|||
JSONObject responseBody = acsToWmsService.gccQueryStationState(requestWMSParam); |
|||
|
|||
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) { |
|||
JSONArray data = responseBody.optJSONArray("data"); |
|||
for (int i = 0; i < data.size(); i++) { |
|||
JSONObject datum = data.getJSONObject(i); |
|||
if (endDeviceCode.equals(datum.optString("Station_Code")) |
|||
&& !datum.optBoolean("IsHasGoods", true)) { |
|||
JSONObject map = new JSONObject(); |
|||
map.put("status", 200); |
|||
map.put("message", "允许放货!"); |
|||
log.info("允许仙工AGV放货,设备号 - {}", endDeviceCode); |
|||
return map; |
|||
} |
|||
} |
|||
} |
|||
|
|||
throw new BadRequestException("请求失败!"); |
|||
} |
|||
|
|||
|
|||
//放货完成等待
|
|||
public JSONObject waitOutPut(String endDeviceCode) { |
|||
log.info("仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode); |
|||
|
|||
JSONObject requestWMSParam = new JSONObject(); |
|||
requestWMSParam.put("EndStationCode", endDeviceCode); |
|||
JSONObject responseBody = acsToWmsService.gccQueryStationState(requestWMSParam); |
|||
|
|||
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) { |
|||
JSONArray data = responseBody.optJSONArray("data"); |
|||
for (int i = 0; i < data.size(); i++) { |
|||
JSONObject datum = data.getJSONObject(i); |
|||
if (endDeviceCode.equals(datum.optString("Station_Code")) |
|||
&& datum.optBoolean("IsHasGoods")) { |
|||
JSONObject map = new JSONObject(); |
|||
map.put("status", 200); |
|||
map.put("message", "允许离开!"); |
|||
log.info("允许仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode); |
|||
return map; |
|||
} |
|||
} |
|||
} |
|||
|
|||
throw new BadRequestException("请求失败!"); |
|||
} |
|||
} |
Loading…
Reference in new issue