add: 增加堆垛机驱动选择策略,优化堆垛机和输送机驱动

This commit is contained in:
yanps
2023-11-24 17:00:43 +08:00
parent 28c02b328c
commit c7ed465eab
10 changed files with 254 additions and 68 deletions

View File

@@ -17,6 +17,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@RestController
@@ -82,4 +83,13 @@ public class CustomPolicyController {
customPolicyService.updateOn(id,is_on);
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/getStrategy")
@Log("自定义策略列表")
@ApiOperation("自定义策略列表")
public ResponseEntity<Object> updateOn(){
List<Map> list = customPolicyService.findDeviceStrategyOption();
return new ResponseEntity<>(list,HttpStatus.OK);
}
}

View File

@@ -8,6 +8,7 @@ import org.nl.acs.custompolicy.server.dto.CustomPolicyDTO;
import org.nl.acs.custompolicy.server.vo.CustomPolicyPlantVO;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
/**
@@ -32,4 +33,5 @@ public interface CustomPolicyService extends CommonService<CustomPolicy> {
DeviceStrategy findByCode(String var1);
List<Map> findDeviceStrategyOption();
}

View File

@@ -159,16 +159,19 @@ public class CustomPolicyServiceImpl extends CommonServiceImpl<CustomPolicyMappe
return i;
}
public Map<String, String> findDeviceStrategyOption() {
public List<Map> findDeviceStrategyOption() {
List<DeviceStrategy> strategys = this.findAllDeviceStrategy();
Map<String, String> map = new HashMap();
List<Map> strings = new ArrayList<>();
Iterator var3 = strategys.iterator();
while(var3.hasNext()) {
DeviceStrategy strategy = (DeviceStrategy)var3.next();
map.put(strategy.getCode(), strategy.getName());
map.put("code",strategy.getCode());
map.put("name",strategy.getName());
strings.add(map);
}
return map;
return strings;
}
}

View File

@@ -852,6 +852,9 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
String opc_server_id = parentForm.getString("opc_id");
String opc_plc_id = parentForm.getString("plc_id");
String address = form.getString("address");
String form_x = form.getString("x");
String form_z = form.getString("z");
String form_y = form.getString("y");
String input_material = parentForm.getString("input_material");
String device_type = parentForm.getString("device_type");
String driver_code = parentForm.getString("driver_code");

View File

@@ -4,11 +4,15 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device.domain.DeviceExtra;
import org.nl.acs.device.enums.DeviceType;
import org.nl.acs.device.service.DeviceExtraService;
import org.nl.acs.device.service.impl.DeviceExtraServiceImpl;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.basedriver.belt_conveyor.BeltConveyorDeviceDriver;
@@ -49,7 +53,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
@Autowired
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class);
@Autowired
DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class);
//心跳
Integer heartbeat = 0;
@@ -425,9 +430,18 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
String next_device_code = instruction.getNext_device_code();
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
if (StrUtil.equals(nextDevice.getDevice_type(), DeviceType.conveyor.name())) {
map.put("to_z", nextDevice.getZ());
map.put("to_x", nextDevice.getX());
map.put("to_y", nextDevice.getY());
List<DeviceExtra> list = deviceExtraService.list(Wrappers.lambdaQuery(DeviceExtra.class).eq(DeviceExtra::getDevice_code, next_device_code));
for (DeviceExtra deviceExtra : list) {
if("x".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())){
map.put("to_x", deviceExtra.getExtra_value());
}
if("z".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())){
map.put("to_z", deviceExtra.getExtra_value());
}
if("y".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())){
map.put("to_y", deviceExtra.getExtra_value());
}
}
}
if (StrUtil.equals(nextDevice.getDevice_type(), DeviceType.storage.name())) {
map.put("to_z", inst.getTo_z());
@@ -609,9 +623,18 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
map.put("to_task", inst.getInstruction_code());
if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name())) {
map.put("to_z", startDevice.getZ());
map.put("to_x", startDevice.getX());
map.put("to_y", startDevice.getY());
List<DeviceExtra> list = deviceExtraService.list(Wrappers.lambdaQuery(DeviceExtra.class).eq(DeviceExtra::getDevice_code, start_device_code));
for (DeviceExtra deviceExtra : list) {
if("x".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())){
map.put("to_x", deviceExtra.getExtra_value());
}
if("z".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())){
map.put("to_z", deviceExtra.getExtra_value());
}
if("y".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())){
map.put("to_y", deviceExtra.getExtra_value());
}
}
}
if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.storage.name())) {
map.put("to_z", inst.getFrom_z());

View File

@@ -202,6 +202,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
wrapper.eq(StringUtils.isNotBlank(status),InstructionMybatis::getInstruction_status,status);
wrapper.and(StringUtils.isNotBlank(point_code),instructionMybatis -> instructionMybatis.like(InstructionMybatis::getStart_point_code,point_code).or().like(InstructionMybatis::getNext_point_code,point_code));
wrapper.eq(StringUtils.isNotBlank(instruction_type),InstructionMybatis::getInstruction_type,instruction_type);
wrapper.le(InstructionMybatis::getInstruction_status,1);
if (!StrUtil.isEmpty(is_over)) {
if (StrUtil.equals(is_over, "1")) {
wrapper.ge(InstructionMybatis::getInstruction_status, InstructionStatusEnum.FINISHED.getIndex());

View File

@@ -27,6 +27,7 @@ import org.nl.acs.device_driver.RequestMethodEnum;
import org.nl.acs.ext.wms.data.one.feedBackTaskStatus.FeedBackTaskStatusRequest;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.domain.InstructionMybatis;
import org.nl.acs.instruction.enums.InstructionStatusEnum;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.InstructionDto;
@@ -322,6 +323,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
wrapper.lt(Task::getTask_status,TaskStatusEnum.FINISHED.getIndex());
}
}
wrapper.le(Task::getTask_status,1);
IPage<Task> taskPage = taskMapper.selectPage(queryPage,wrapper);
final JSONObject json = (JSONObject) JSON.toJSON(ConvertUtil.convertPage(taskPage, TaskDto.class));
return json;