更新叠盘

This commit is contained in:
2022-11-11 19:31:07 +08:00
parent de0580808b
commit 6d626cc14b
3 changed files with 115 additions and 25 deletions

View File

@@ -19,7 +19,10 @@ import org.nl.acs.auto.initial.ApplicationAutoInitial;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.impl.DeviceServiceImpl;
import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.empty_vehicle_stacking_position.EmptyVehicleStackingPositionDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_smart_plc_test.HailiangSmartplcTestDeviceDriver;
import org.nl.acs.device_driver.basedriver.haokai_auto_conveyor.HaoKaiAutoConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.paint_conveyor.PaintConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.instruction.service.InstructionService;
@@ -68,7 +71,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
DeviceAppService deviceAppService;
@Autowired
NDCAgvService ndcAgvService;
@Autowired
@Autowired
ParamService paramService;
@Autowired
RouteLineService routeLineService;
@@ -291,7 +294,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
dto.setStart_parent_code(task.getStart_parent_code());
dto.setNext_parent_code(task.getNext_parent_code());
if(ObjectUtil.isNotEmpty(task.getTask_type())){
if (ObjectUtil.isNotEmpty(task.getTask_type())) {
dto.setInstruction_type(task.getTask_type());
}
@@ -302,23 +305,24 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
CargoLiftConveyorDeviceDriver cargoLiftConveyorDeviceDriver;
HaoKaiAutoConveyorDeviceDriver haoKaiAutoConveyorDeviceDriver;
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver;
EmptyVehicleStackingPositionDeviceDriver emptyVehicleStackingPositionDeviceDriver;
//输送线相关需要给任务字段进行赋值,通过任务来判断输送线当前执行到哪一步
if (startdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver) {
cargoLiftConveyorDeviceDriver = (CargoLiftConveyorDeviceDriver) startdevice.getDeviceDriver();
if (nextdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver){
if (nextdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) {
standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) nextdevice.getDeviceDriver();
standardCoveyorControlWithScannerDeviceDriver.writing(1,1);
standardCoveyorControlWithScannerDeviceDriver.writing(1, 1);
String address = standardCoveyorControlWithScannerDeviceDriver.getExtraValue().get("address").toString();
if (StrUtil.isEmpty(address)){
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置电气调度号!");
if (StrUtil.isEmpty(address)) {
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置电气调度号!");
}
String door = standardCoveyorControlWithScannerDeviceDriver.getExtraValue().get("door").toString();
if (StrUtil.isEmpty(door)){
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置门!");
if (StrUtil.isEmpty(door)) {
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置门!");
}
String floor = standardCoveyorControlWithScannerDeviceDriver.getExtraValue().get("floor").toString();
if (StrUtil.isEmpty(floor)){
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置楼层!");
if (StrUtil.isEmpty(floor)) {
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置楼层!");
}
cargoLiftConveyorDeviceDriver.writing(1, 0);
cargoLiftConveyorDeviceDriver.writing(1, 1);
@@ -330,20 +334,20 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
}
if (startdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) {
standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) startdevice.getDeviceDriver();
if (nextdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver){
if (nextdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver) {
cargoLiftConveyorDeviceDriver = (CargoLiftConveyorDeviceDriver) nextdevice.getDeviceDriver();
cargoLiftConveyorDeviceDriver.writing(1,1);
cargoLiftConveyorDeviceDriver.writing(1, 1);
String address = cargoLiftConveyorDeviceDriver.getExtraValue().get("address").toString();
if (StrUtil.isEmpty(address)){
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置电气调度号!");
if (StrUtil.isEmpty(address)) {
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置电气调度号!");
}
String door = cargoLiftConveyorDeviceDriver.getExtraValue().get("door").toString();
if (StrUtil.isEmpty(door)){
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置门!");
if (StrUtil.isEmpty(door)) {
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置门!");
}
String floor = cargoLiftConveyorDeviceDriver.getExtraValue().get("floor").toString();
if (StrUtil.isEmpty(floor)){
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置楼层!");
if (StrUtil.isEmpty(floor)) {
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置楼层!");
}
cargoLiftConveyorDeviceDriver.writing(1, 0);
standardCoveyorControlWithScannerDeviceDriver.writing(1, 1);
@@ -368,20 +372,47 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
RouteLineDto routeLineDto = shortPathsList.get(i);
String route_device = routeLineDto.getDevice_code();
String route_next_device = routeLineDto.getNext_device_code();
if (route_device.equals(dto.getStart_device_code()) && route_next_device.equals(dto.getNext_device_code())){
if (route_device.equals(dto.getStart_device_code()) && route_next_device.equals(dto.getNext_device_code())) {
route = routeLineDto;
break;
}
}
if (ObjectUtil.isEmpty(route)){
if (ObjectUtil.isEmpty(route)) {
throw new BadRequestException("未查询到相关路由!");
}
if (startdevice.getDeviceDriver() instanceof EmptyVehicleStackingPositionDeviceDriver) {
emptyVehicleStackingPositionDeviceDriver = (EmptyVehicleStackingPositionDeviceDriver) startdevice.getDeviceDriver();
//已经生成指令得取空托盘数量
Integer emptyNum = taskService.queryStartNum(dto.getStart_device_code());
//当前任务取得空托盘数量
Integer now_need_emptypallet_num = Integer.parseInt(taskService.findByCode(dto.getTask_code()).getEmptypallet_num());
//当前叠盘架有空托盘数量
int now_number = emptyVehicleStackingPositionDeviceDriver.getNumber();
int i = now_number - now_need_emptypallet_num - emptyNum + 1;
dto.setStart_device_code(start_device_code + "." + i);
dto.setStart_parent_code(start_device_code + "." + i);
dto.setStart_point_code(start_device_code + "." + i);
}
if (nextdevice.getDeviceDriver() instanceof EmptyVehicleStackingPositionDeviceDriver) {
emptyVehicleStackingPositionDeviceDriver = (EmptyVehicleStackingPositionDeviceDriver) startdevice.getDeviceDriver();
//已经生成指令得放空托盘数量
Integer emptyNum = taskService.queryEndNum(dto.getStart_device_code());
//当前任务放空托盘数量
Integer now_need_emptypallet_num = Integer.parseInt(taskService.findByCode(dto.getTask_code()).getEmptypallet_num());
//当前叠盘架有空托盘数量
int now_number = emptyVehicleStackingPositionDeviceDriver.getNumber();
int i = now_number + emptyNum + 1;
dto.setNext_device_code(next_device_code + "." + i);
dto.setNext_parent_code(next_device_code + "." + i);
dto.setNext_point_code(next_device_code + "." + i);
}
if (StrUtil.equals(route.getType(), "1")) {
ZheDaAgvService zheDaAgvService = SpringContextHolder.getBean(ZheDaAgvService.class);
HttpResponse result = zheDaAgvService.sendAgvInstToAgv(dto);
if (!ObjectUtils.isEmpty(result)) {
if (!ObjectUtils.isEmpty(result)) {
JSONObject jo = JSON.parseObject(result.body());
if(jo.getInteger("status") != 200){
if (jo.getInteger("status") != 200) {
dto.setSend_status("2");
} else {
dto.setSend_status("1");
@@ -900,11 +931,28 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
if (entity == null) {
throw new BadRequestException("被删除或无权限,操作失败!");
}
String start_device_code = entity.getStart_device_code();
String next_device_code = entity.getNext_device_code();
if (StrUtil.contains(start_device_code, ".")) {
String[] point = start_device_code.split("\\.");
start_device_code = point[0];
entity.setStart_device_code(start_device_code);
} else {
start_device_code = start_device_code;
}
if (StrUtil.contains(next_device_code, ".")) {
String[] point = next_device_code.split("\\.");
next_device_code = point[0];
entity.setNext_device_code(next_device_code);
} else {
next_device_code = next_device_code;
}
TaskDto task = taskService.findByCodeFromCache(entity.getTask_code());
if (StrUtil.isEmpty(entity.getRoute_plan_code())) {
entity.setRoute_plan_code(task.getRoute_plan_code());
}
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(entity.getStart_device_code(), entity.getNext_device_code(), entity.getRoute_plan_code());
if (ObjectUtils.isEmpty(shortPathsList)) {
throw new Exception(entity.getStart_device_code() + "->" + entity.getNext_device_code() + "路由不通");
@@ -916,12 +964,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
RouteLineDto routeLineDto = shortPathsList.get(i);
String route_device = routeLineDto.getDevice_code();
String route_next_device = routeLineDto.getNext_device_code();
if (route_device.equals(entity.getStart_device_code()) && route_next_device.equals(entity.getNext_device_code())){
if (route_device.equals(entity.getStart_device_code()) && route_next_device.equals(entity.getNext_device_code())) {
route = routeLineDto;
break;
}
}
if (ObjectUtil.isEmpty(route)){
if (ObjectUtil.isEmpty(route)) {
throw new BadRequestException("未查询到相关路由!");
}
if (StrUtil.equals(route.getType(), "1")) {

View File

@@ -260,4 +260,21 @@ public interface TaskService {
*/
Integer querySameDestinationTask(String code);
/**
* 查询叠盘位起点未执行完任务得数量叠盘数量
*
* @param code
* @return
*/
Integer queryStartNum(String code);
/**
* 查询叠盘位起点未执行完任务得数量叠盘数量
*
* @param code
* @return
*/
Integer queryEndNum(String code);
}

View File

@@ -1201,7 +1201,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
num++;
}
}
return num;
}
@@ -1215,4 +1214,30 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return null;
}
@Override
public Integer queryStartNum(String code) {
int num = 0;
Iterator<TaskDto> iterator = tasks.iterator();
while (iterator.hasNext()) {
TaskDto task = iterator.next();
if (task.getStart_device_code().equals(code) && task.getTask_status().equals("1")) {
num = num + Integer.parseInt(task.getEmptypallet_num());
}
}
return num;
}
@Override
public Integer queryEndNum(String code) {
int num = 0;
Iterator<TaskDto> iterator = tasks.iterator();
while (iterator.hasNext()) {
TaskDto task = iterator.next();
if (task.getNext_device_code().equals(code) && task.getTask_status().equals("1")) {
num = num + Integer.parseInt(task.getEmptypallet_num());
}
}
return num;
}
}