opt:优化,增加查看小车状态报表接口
This commit is contained in:
@@ -720,6 +720,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
String status_name = this.status == 1 ? "关机" : this.status == 2 ? "工作中" : this.status == 3 ? "交通管制" : this.status == 4 ? "任务等待" : this.status == 5 ? "充电中" : this.status == 6 ? "故障中" : this.status == 7 ? "电量低" : "正常";
|
||||
//agv状态
|
||||
jo.put("status_name", status_name);
|
||||
jo.put("status", this.getStatus());
|
||||
//任务号
|
||||
jo.put("task_code", ObjectUtil.isEmpty(instruction) ? "0" : instruction.getTask_code());
|
||||
//异常
|
||||
|
||||
@@ -43,6 +43,30 @@ public class WmsToAcsController {
|
||||
return new ResponseEntity<>(wmstoacsService.crateTask(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getCarStatus")
|
||||
@Log(value = "获取小车状态")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> getCarStatus( HttpServletRequest request) {
|
||||
log.info("获取小车状态ip:{},端口号:{},地址:{}", request.getRemoteAddr(),request.getRemotePort(),request.getRemoteHost());
|
||||
return new ResponseEntity<>(wmstoacsService.getCarStatus(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/suspend")
|
||||
@Log(value = "停止")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> suspend(@RequestBody String whereJson, HttpServletRequest request) {
|
||||
log.info("wms下发任务的ip:{},端口号:{},地址:{}", request.getRemoteAddr(),request.getRemotePort(),request.getRemoteHost());
|
||||
return new ResponseEntity<>(wmstoacsService.suspend(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/start")
|
||||
@Log(value = "启动")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> start(@RequestBody String whereJson, HttpServletRequest request) {
|
||||
log.info("wms下发任务的ip:{},端口号:{},地址:{}", request.getRemoteAddr(),request.getRemotePort(),request.getRemoteHost());
|
||||
return new ResponseEntity<>(wmstoacsService.start(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/cancelTask")
|
||||
@Log(value = "WMS取消任务")
|
||||
@SaIgnore
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package org.nl.acs.ext.wms.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GetCarStatusResponse {
|
||||
|
||||
/**
|
||||
* 请求号
|
||||
*/
|
||||
private String requestNo;
|
||||
|
||||
/**
|
||||
* 响应时间
|
||||
*/
|
||||
private Object responseDate;
|
||||
|
||||
/**
|
||||
* 结果 200成功
|
||||
*/
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
|
||||
private Map<String, String> parameters = new HashMap();
|
||||
|
||||
private Integer status = 0;
|
||||
private JSONArray errArr = new JSONArray();
|
||||
|
||||
|
||||
|
||||
public Integer getstatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Map<String, String> getParameters() {
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
public void setParameters(Map<String, String> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public Object getParameter(String key) {
|
||||
return this.parameters.get(key);
|
||||
}
|
||||
|
||||
public void putParameter(String key, String object) {
|
||||
this.parameters.put(key, object);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -25,6 +25,34 @@ public interface WmsToAcsService {
|
||||
*/
|
||||
CreateTaskResponse crateTask(List<CreateTaskRequest> reqs);
|
||||
|
||||
/**
|
||||
* 创建任务
|
||||
*
|
||||
* @param reqs
|
||||
* @return
|
||||
*/
|
||||
GetCarStatusResponse getCarStatus();
|
||||
|
||||
|
||||
/**
|
||||
* 创建任务
|
||||
*
|
||||
* @param reqs
|
||||
* @return
|
||||
*/
|
||||
JSONObject suspend(String param);
|
||||
|
||||
|
||||
/**
|
||||
* 创建任务
|
||||
*
|
||||
* @param reqs
|
||||
* @return
|
||||
*/
|
||||
JSONObject start(String param);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 更新任务点位状态
|
||||
*
|
||||
|
||||
@@ -18,9 +18,11 @@ import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.ext.wms.data.*;
|
||||
|
||||
import org.nl.acs.ext.wms.service.GetCarStatusResponse;
|
||||
import org.nl.acs.ext.wms.service.WmsToAcsService;
|
||||
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.enums.InstructionStatusEnum;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.storage_cell.domain.StorageCell;
|
||||
@@ -38,6 +40,7 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -402,6 +405,61 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetCarStatusResponse getCarStatus() {
|
||||
GetCarStatusResponse response = new GetCarStatusResponse();
|
||||
List<Device> agvDevices = deviceAppService.findAllDevice().stream().filter(a -> "agv_ndc_two".equals(a.getDevice_type())).collect(Collectors.toList());
|
||||
List<Instruction> instructions = instructionService.queryAll(new HashMap()).stream().filter(a -> InstructionStatusEnum.BUSY.getIndex().equals(a.getInstruction_status())).collect(Collectors.toList());
|
||||
List<JSONObject> jsonObjectList = new ArrayList<>();
|
||||
|
||||
for (Device device : agvDevices) {
|
||||
JSONObject car = new JSONObject();
|
||||
car.put("device_code", device.getDevice_code() );
|
||||
car.put("device_name", device.getDevice_code() + "号AGV");
|
||||
boolean isWorking = false;
|
||||
for (Instruction instruction : instructions) {
|
||||
if (device.getDevice_code().equals(instruction.getCarno())) {
|
||||
isWorking = true;
|
||||
car.put("start_point", instruction.getStart_point_code());
|
||||
car.put("end_point", instruction.getNext_point_code());
|
||||
car.put("vehicle_code", instruction.getVehicle_code());
|
||||
|
||||
}
|
||||
}
|
||||
if (!isWorking) {
|
||||
|
||||
car.put("start_point", "");
|
||||
car.put("end_point", "");
|
||||
car.put("vehicle_code", "");
|
||||
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) {
|
||||
AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver();
|
||||
car.put("electricity", agvNdcTwoDeviceDriver.getDeviceStatusName().get("electricity"));
|
||||
car.put("status_name", agvNdcTwoDeviceDriver.getDeviceStatusName().get("status_name"));
|
||||
car.put("fault", agvNdcTwoDeviceDriver.getDeviceStatusName().get("fault"));
|
||||
car.put("status", agvNdcTwoDeviceDriver.getDeviceStatusName().get("status"));
|
||||
}
|
||||
jsonObjectList.add(car);
|
||||
|
||||
}
|
||||
response.setResponseDate(jsonObjectList);
|
||||
response.setStatus(200);
|
||||
response.setCode(200);
|
||||
response.setMessage("success");
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject suspend(String param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject start(String param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> updateTask(String whereJson) {
|
||||
JSONArray datas = JSONArray.parseArray(whereJson);
|
||||
|
||||
Reference in New Issue
Block a user