更新
This commit is contained in:
@@ -10,7 +10,7 @@ import org.nl.acs.agv.server.AgvService;
|
||||
import org.nl.acs.agv.server.dto.AgvDto;
|
||||
import org.nl.acs.config.AcsConfig;
|
||||
import org.nl.acs.config.server.AcsConfigService;
|
||||
import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
import org.nl.acs.device_driver.autodoor.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
|
||||
@@ -12,8 +12,8 @@ import org.nl.acs.agv.server.MagicAgvService;
|
||||
import org.nl.acs.agv.server.dto.AgvDto;
|
||||
import org.nl.acs.config.AcsConfig;
|
||||
import org.nl.acs.config.server.AcsConfigService;
|
||||
import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.autodoor.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_storage.StandardStorageDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.nl.acs.config.AcsConfig;
|
||||
import org.nl.acs.config.server.AcsConfigService;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device.service.impl.DeviceServiceImpl;
|
||||
import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
import org.nl.acs.device_driver.autodoor.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
|
||||
@@ -12,17 +12,15 @@ import org.nl.acs.agv.server.XianGongAgvService;
|
||||
import org.nl.acs.agv.server.dto.AgvDto;
|
||||
import org.nl.acs.config.AcsConfig;
|
||||
import org.nl.acs.config.server.AcsConfigService;
|
||||
import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.autodoor.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceType;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -41,7 +41,11 @@ public enum DriverTypeEnum {
|
||||
|
||||
TRAFFIC_LIGHT(34, "traffic_light", "标准版-交通灯-欧姆龙plc", "alarmLamp"),
|
||||
|
||||
STANDARD_RGV(35, "standard_rgv", "标准版-RGV", "rgv");
|
||||
STANDARD_RGV(35, "standard_rgv", "标准版-RGV", "rgv"),
|
||||
|
||||
MODBUS_AUTODOOR(36, "modbus_autodoor", "modbus-自动门", "autodoor"),
|
||||
|
||||
MODBUS_INSPECT_SITE(37, "modbus_inspect_site", "modbus-检测站点", "station");
|
||||
|
||||
//驱动索引
|
||||
private int index;
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.nl.acs.device_driver.ScannerDeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
import org.nl.acs.device_driver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_scanner.StandardScannerDeviceDriver;
|
||||
import org.nl.acs.opc.Device;
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package org.nl.acs.device_driver.autodoor.modbus_autodoor;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class ItemProtocol {
|
||||
public static String item_heartbeat = "heartbeat";
|
||||
public static String item_mode = "mode";
|
||||
public static String item_action = "action";
|
||||
public static String item_error = "error";
|
||||
public static String item_to_command = "to_command";
|
||||
|
||||
|
||||
private final ModbusAutodoorDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(ModbusAutodoorDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getHeartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
public int getAction() {
|
||||
return this.getOpcIntegerValue(item_action);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getToCommand() {
|
||||
return this.getOpcIntegerValue(item_to_command);
|
||||
}
|
||||
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "30002"));
|
||||
list.add(new ItemDto(item_mode, "工作状态", "30004", Boolean.TRUE));
|
||||
list.add(new ItemDto(item_action, "动作信号", "30006"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "30008"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_to_command, "作业命令", "40002", Boolean.TRUE));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package org.nl.acs.device_driver.autodoor.modbus_autodoor;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceType;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自动门驱动定义
|
||||
*/
|
||||
@Service
|
||||
public class ModbusAutodoorDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "modbus_autodoor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "modbus-自动门";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "modbus-自动门";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new ModbusAutodoorDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return ModbusAutodoorDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList<>();
|
||||
types.add(DeviceType.conveyor);
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return getReadableItemDtos2();
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos2() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "30002"));
|
||||
list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "30004", Boolean.TRUE));
|
||||
list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "30006"));
|
||||
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "30008"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package org.nl.acs.device_driver.autodoor.modbus_autodoor;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.utils.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 自动门驱动
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class ModbusAutodoorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
@Autowired
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
@Autowired
|
||||
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
|
||||
@Autowired
|
||||
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
|
||||
@Autowired
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
String container;
|
||||
String container_type_desc;
|
||||
String last_container_type_desc;
|
||||
String last_container;
|
||||
//放货准备锁
|
||||
String putReadyLock = null;
|
||||
//有货标记
|
||||
protected boolean has_goods_tag = false;
|
||||
String devicecode;
|
||||
int mode = 0;
|
||||
int action = 0;
|
||||
int error = 0;
|
||||
Boolean iserror = false;
|
||||
|
||||
int move = 0;
|
||||
int task = 0;
|
||||
int last_action = 0;
|
||||
int last_mode = 0;
|
||||
int last_error = 0;
|
||||
int last_move = 0;
|
||||
int last_task = 0;
|
||||
|
||||
boolean hasVehicle = false;
|
||||
boolean isReady = false;
|
||||
protected int instruction_num = 0;
|
||||
protected int instruction_num_truth = 0;
|
||||
protected boolean hasGoods = false;
|
||||
boolean isFold = false;
|
||||
private String assemble_check_tag;
|
||||
private Boolean sampleMode0;
|
||||
private Boolean sampleMode3;
|
||||
private Integer sampleError;
|
||||
private Boolean sampleOnline;
|
||||
protected String displayMessage = null;
|
||||
public int display_message_time_out = 30000;
|
||||
public Date display_message_time;
|
||||
protected String current_stage_instruction_message;
|
||||
protected String last_stage_instruction_message;
|
||||
Integer heartbeat_tag;
|
||||
private Date instruction_require_time = new Date();
|
||||
private Date instruction_finished_time = new Date();
|
||||
|
||||
private int instruction_require_time_out;
|
||||
boolean requireSucess = false;
|
||||
|
||||
private int instruction_finished_time_out;
|
||||
|
||||
int branchProtocol = 0;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
mode = this.itemProtocol.getMode();
|
||||
action = this.itemProtocol.getAction();
|
||||
error = this.itemProtocol.getError();
|
||||
if (mode != last_mode) {
|
||||
}
|
||||
if (action != last_action) {
|
||||
}
|
||||
if (error != last_error) {
|
||||
//this.execute_log.setContainer("");
|
||||
}
|
||||
last_action = action;
|
||||
last_mode = mode;
|
||||
last_error = error;
|
||||
//message = StringFormatUtl.format("设备报警:{}", new Object[]{});
|
||||
|
||||
// String manual_create_task = this.getDevice().getExtraValue().get("manual_create_task").toString();
|
||||
|
||||
}
|
||||
|
||||
public synchronized String getStatus() {
|
||||
JSONObject jo = new JSONObject();
|
||||
|
||||
if (action == 1) {
|
||||
jo.put("name", this.getDevice().getDevice_code());
|
||||
jo.put("status", "OPEN");
|
||||
|
||||
} else if (action == 2) {
|
||||
jo.put("name", this.getDevice().getDevice_code());
|
||||
jo.put("status", "CLOSE");
|
||||
|
||||
} else {
|
||||
jo.put("name", this.getDevice().getDevice_code());
|
||||
jo.put("status", "ERROR");
|
||||
}
|
||||
return jo.toString();
|
||||
}
|
||||
|
||||
|
||||
public void writeing(int command) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_command;
|
||||
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
log.info("下发PLC信号:{},{}", to_command, command);
|
||||
System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command);
|
||||
|
||||
}
|
||||
|
||||
public synchronized void OpenOrClose(String type) {
|
||||
|
||||
//开门
|
||||
if ("1".equals(type)) {
|
||||
writeing(1);
|
||||
} else {
|
||||
writeing(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.acs.device_driver.standard_autodoor;
|
||||
package org.nl.acs.device_driver.autodoor.standard_autodoor;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.acs.device_driver.standard_autodoor;
|
||||
package org.nl.acs.device_driver.autodoor.standard_autodoor;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.acs.device_driver.standard_autodoor;
|
||||
package org.nl.acs.device_driver.autodoor.standard_autodoor;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
@@ -0,0 +1,106 @@
|
||||
package org.nl.acs.device_driver.inspect_site.modbus_inspect_site;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class ItemProtocol {
|
||||
|
||||
public static String item_heartbeat = "heartbeat";
|
||||
public static String item_mode = "mode";
|
||||
public static String item_move = "move";
|
||||
public static String item_action = "action";
|
||||
public static String item_error = "error";
|
||||
public static String item_task = "task";
|
||||
public static String item_to_command = "to_command";
|
||||
public static String item_to_target = "to_target";
|
||||
public static String item_to_task = "to_task";
|
||||
|
||||
private ModbusInspectSiteDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(ModbusInspectSiteDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getHeartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
public int getMove() {
|
||||
return this.getOpcIntegerValue(item_move);
|
||||
}
|
||||
|
||||
public int getAction() {
|
||||
return this.getOpcIntegerValue(item_action);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getTask() {
|
||||
return this.getOpcIntegerValue(item_task);
|
||||
}
|
||||
|
||||
public int getToCommand() {
|
||||
return this.getOpcIntegerValue(item_to_command);
|
||||
}
|
||||
|
||||
public int getToTarget() {
|
||||
return this.getOpcIntegerValue(item_to_target);
|
||||
}
|
||||
|
||||
public int getToTask() {
|
||||
return this.getOpcIntegerValue(item_to_task);
|
||||
}
|
||||
|
||||
//是否有货
|
||||
public int hasGoods(int move) {
|
||||
return move;
|
||||
}
|
||||
|
||||
Boolean isonline;
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "30002"));
|
||||
list.add(new ItemDto(item_mode, "工作状态", "30004", Boolean.TRUE));
|
||||
list.add(new ItemDto(item_move, "光电开关信号", "30006"));
|
||||
list.add(new ItemDto(item_action, "取放信号", "30008"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "30010"));
|
||||
list.add(new ItemDto(item_task, "任务号", "30012"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_to_command, "作业命令", "40002", Boolean.TRUE));
|
||||
list.add(new ItemDto(item_to_target, "目标站", "40004"));
|
||||
list.add(new ItemDto(item_to_task, "任务号", "40008"));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.nl.acs.device_driver.inspect_site.modbus_inspect_site;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceType;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 检测站点驱动定义
|
||||
* 说明:该站点为普通带光电检测站点
|
||||
*/
|
||||
@Service
|
||||
public class ModbusInspectSiteDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "modbus_inspect_site";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "modbus-检测站点";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "modbus-检测站点";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new ModbusInspectSiteDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return ModbusInspectSiteDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList<>();
|
||||
types.add(DeviceType.conveyor);
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return getReadableItemDtos2();
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos2() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "30002"));
|
||||
list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "30004", Boolean.TRUE));
|
||||
list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "30006"));
|
||||
list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "30008"));
|
||||
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "30010"));
|
||||
list.add(new ItemDto(ItemProtocol.item_task, "任务号", "30014"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,455 @@
|
||||
package org.nl.acs.device_driver.inspect_site.modbus_inspect_site;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.opc.WcsConfig;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.utils.SpringContextHolder;
|
||||
import org.nl.wql.core.bean.WQLObject;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 检测站点驱动
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class ModbusInspectSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
@Autowired
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
@Autowired
|
||||
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
|
||||
@Autowired
|
||||
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
|
||||
@Autowired
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
@Autowired
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
|
||||
String container;
|
||||
String container_type_desc;
|
||||
String last_container_type_desc;
|
||||
String last_container;
|
||||
//放货准备锁
|
||||
String putReadyLock = null;
|
||||
//有货标记
|
||||
protected boolean has_goods_tag = false;
|
||||
|
||||
int mode = 0;
|
||||
int error = 0;
|
||||
int move = 0;
|
||||
int task = 0;
|
||||
int last_mode = 0;
|
||||
int last_error = 0;
|
||||
int last_move = 0;
|
||||
int last_task = 0;
|
||||
Boolean isonline = true;
|
||||
int hasGoods = 0;
|
||||
String message = null;
|
||||
Boolean iserror = false;
|
||||
|
||||
|
||||
boolean hasVehicle = false;
|
||||
boolean isReady = false;
|
||||
protected int instruction_num = 0;
|
||||
protected int instruction_num_truth = 0;
|
||||
boolean isFold = false;
|
||||
private String assemble_check_tag;
|
||||
|
||||
protected String current_stage_instruction_message;
|
||||
protected String last_stage_instruction_message;
|
||||
Integer heartbeat_tag;
|
||||
private Date instruction_require_time = new Date();
|
||||
private Date instruction_finished_time = new Date();
|
||||
|
||||
private int instruction_require_time_out;
|
||||
boolean requireSucess = false;
|
||||
|
||||
private int instruction_finished_time_out;
|
||||
|
||||
int branchProtocol = 0;
|
||||
//备注
|
||||
String remark;
|
||||
//数量
|
||||
String qty;
|
||||
//物料
|
||||
String material;
|
||||
//批次
|
||||
String batch;
|
||||
//当前指令
|
||||
Instruction inst = null;
|
||||
//上次指令
|
||||
Instruction last_inst = null;
|
||||
|
||||
//触摸屏手动触发任务
|
||||
private Boolean is_has_task = false;
|
||||
|
||||
//申请搬运任务
|
||||
private Boolean apply_handling = false;
|
||||
//申请物料
|
||||
private Boolean apply_material = false;
|
||||
|
||||
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
||||
int flag;
|
||||
|
||||
String device_code;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
String message = null;
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
error = this.itemProtocol.getError();
|
||||
move = this.itemProtocol.getMove();
|
||||
task = this.itemProtocol.getTask();
|
||||
hasGoods = this.itemProtocol.getMove();
|
||||
|
||||
if (mode != last_mode) {
|
||||
this.setRequireSucess(false);
|
||||
logServer.deviceItemValue(this.device_code,"mode" ,String.valueOf(mode));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号mode:" + last_mode + "->" + mode);
|
||||
}
|
||||
if (move != last_move) {
|
||||
logServer.deviceItemValue(this.device_code,"move" ,String.valueOf(move));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号move:" + last_move + "->" + move);
|
||||
}
|
||||
if (error != last_error) {
|
||||
logServer.deviceItemValue(this.device_code,"error" ,String.valueOf(error));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号error:" + last_error + "->" + error);
|
||||
}
|
||||
if (task != last_task) {
|
||||
logServer.deviceItemValue(this.device_code,"task",String.valueOf(task));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号task:" + last_task + "->" + task);
|
||||
}
|
||||
|
||||
if (this.getApply_handling()) {
|
||||
String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString();
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
Device link_device = appService.findDeviceByCode(link_device_code);
|
||||
ModbusInspectSiteDeviceDriver standardInspectSiteDevicedriver;
|
||||
if (link_device.getDeviceDriver() instanceof ModbusInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDevicedriver = (ModbusInspectSiteDeviceDriver) link_device.getDeviceDriver();
|
||||
// if(standardInspectSiteDevicedriver.getMode() != 2){
|
||||
// log.debug("设备未待机");
|
||||
// return;
|
||||
// }
|
||||
// if(standardInspectSiteDevicedriver.getMove() != 0){
|
||||
// log.debug("设备不满足放货条件");
|
||||
// return;
|
||||
// }
|
||||
|
||||
//如果目标设备申请叫料 则允许生成任务
|
||||
if (standardInspectSiteDevicedriver.getApply_material()) {
|
||||
TaskDto dto = new TaskDto();
|
||||
String now = DateUtil.now();
|
||||
dto.setTask_id(IdUtil.simpleUUID());
|
||||
dto.setCreate_by(this.getDevice().getDevice_code());
|
||||
dto.setUpdate_by(this.getDevice().getDevice_code());
|
||||
dto.setStart_point_code(this.getDevice().getDevice_code());
|
||||
|
||||
String taskcode = CodeUtil.getNewCode("TASK_NO");
|
||||
dto.setTask_code("-" + taskcode);
|
||||
dto.setTask_status("0");
|
||||
dto.setPriority("101");
|
||||
// RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code());
|
||||
// String next_device_codecode = jo.getNext_device_code();
|
||||
// if(StrUtil.isEmpty(next_device_codecode)){
|
||||
// throw new RuntimeException("该设备未找到对应路由");
|
||||
// }
|
||||
dto.setNext_point_code(this.getDeviceCode());
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
|
||||
wo.insert(json);
|
||||
standardInspectSiteDevicedriver.setApply_material(false);
|
||||
}
|
||||
}
|
||||
this.setApply_handling(false);
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.itemProtocol.getIsonline()) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
message = "信号量同步异常";
|
||||
//未联机
|
||||
} else if (mode == 0) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
message = "未联机";
|
||||
//有报警
|
||||
} else if (error != 0) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
message = "有报警";
|
||||
//无报警
|
||||
} else {
|
||||
this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
message = "";
|
||||
Instruction instruction = null;
|
||||
List toInstructions;
|
||||
switch (mode) {
|
||||
case 1:
|
||||
log.debug("设备运转模式:等待工作");
|
||||
return;
|
||||
case 2:
|
||||
//申请任务
|
||||
// if (this.getApply_handling()) {
|
||||
// String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString();
|
||||
// DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
// Device link_device = appService.findDeviceByCode(link_device_code);
|
||||
// StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver;
|
||||
// if(link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
// standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) link_device.getDeviceDriver();
|
||||
// if(standardInspectSiteDevicedriver.getMode() != 2){
|
||||
// log.debug("设备未待机");
|
||||
// return;
|
||||
// }
|
||||
// if(standardInspectSiteDevicedriver.getMove() != 0){
|
||||
// log.debug("设备不满足放货条件");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// //如果目标设备申请叫料 则允许生成任务
|
||||
// if(standardInspectSiteDevicedriver.getApply_material()){
|
||||
// TaskDto dto = new TaskDto();
|
||||
// String now = DateUtil.now();
|
||||
// dto.setTask_id(IdUtil.simpleUUID());
|
||||
// dto.setCreate_by(this.getDevice().getDevice_code());
|
||||
// dto.setUpdate_by(this.getDevice().getDevice_code());
|
||||
// dto.setStart_point_code(this.getDevice().getDevice_code());
|
||||
//
|
||||
// String taskcode = CodeGenerateUtil.getNewCode("TASK_NO");
|
||||
// dto.setTask_code("-"+taskcode);
|
||||
// dto.setTask_status("0");
|
||||
// dto.setPriority("101");
|
||||
// RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code());
|
||||
// String next_device_codecode = jo.getNext_device_code();
|
||||
// if(StrUtil.isEmpty(next_device_codecode)){
|
||||
// throw new RuntimeException("该设备未找到对应路由");
|
||||
// }
|
||||
// dto.setNext_point_code(next_device_codecode);
|
||||
// dto.setUpdate_time(now);
|
||||
// dto.setCreate_time(now);
|
||||
//
|
||||
// WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
// JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
|
||||
// wo.insert(json);
|
||||
// standardInspectSiteDevicedriver.setApply_material(false);
|
||||
// }
|
||||
// }
|
||||
// this.setApply_handling(false);
|
||||
// }
|
||||
|
||||
if (material.length() > 0 && qty.length() > 0 && !requireSucess) {
|
||||
this.instruction_require(container);
|
||||
}
|
||||
}
|
||||
|
||||
switch (flag) {
|
||||
//取货完成
|
||||
case 1:
|
||||
writing(2);
|
||||
return;
|
||||
//放货完成
|
||||
case 2:
|
||||
writing(3);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
last_mode = mode;
|
||||
last_error = error;
|
||||
last_move = move;
|
||||
last_task = task;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean exe_error() {
|
||||
if (this.error == 0) {
|
||||
return true;
|
||||
} else {
|
||||
log.debug("设备报警");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void thingToNothing() {
|
||||
log.debug("从有货到无货 清理数据");
|
||||
this.set_last_container(container, container_type_desc);
|
||||
}
|
||||
|
||||
public void set_last_container(String barcode, String type_desc) {
|
||||
this.set_last_container(barcode);
|
||||
this.set_last_container_type_desc(type_desc);
|
||||
}
|
||||
|
||||
public void set_last_container(String barcode) {
|
||||
}
|
||||
|
||||
public void set_last_container_type_desc(String type) {
|
||||
}
|
||||
|
||||
public boolean exe_business() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void executing(Instruction instruction) {
|
||||
this.executing(1, instruction, "");
|
||||
}
|
||||
|
||||
public void executing(int command, Instruction instruction, String appendMessage) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_command;
|
||||
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_target;
|
||||
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_task;
|
||||
if (appendMessage == null) {
|
||||
appendMessage = "";
|
||||
}
|
||||
if (instruction != null) {
|
||||
instruction_num = Integer.parseInt(instruction.getInstruction_code());
|
||||
}
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, 1);
|
||||
itemMap.put(to_task, instruction_num);
|
||||
ReadUtil.write(itemMap, server);
|
||||
|
||||
}
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
ReadUtil.write(itemMap, server);
|
||||
}
|
||||
|
||||
public void writing(int command) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_command;
|
||||
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
|
||||
}
|
||||
|
||||
public void writing(int type, int command) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_command;
|
||||
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_target;
|
||||
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_task;
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
if (type == 1) {
|
||||
itemMap.put(to_command, command);
|
||||
} else if (type == 2) {
|
||||
itemMap.put(to_target, command);
|
||||
|
||||
} else if (type == 3) {
|
||||
itemMap.put(to_task, command);
|
||||
}
|
||||
ReadUtil.write(itemMap, server);
|
||||
|
||||
}
|
||||
|
||||
public boolean instruction_require(String container_code) {
|
||||
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求指令
|
||||
*
|
||||
* @param container_code
|
||||
* @param container_type
|
||||
*/
|
||||
public synchronized boolean instruction_require(String container_code, String container_type) {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
return false;
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
TaskDto dto = new TaskDto();
|
||||
String now = DateUtil.now();
|
||||
dto.setTask_id(IdUtil.simpleUUID());
|
||||
dto.setCreate_by(this.getDevice().getDevice_code());
|
||||
dto.setUpdate_by(this.getDevice().getDevice_code());
|
||||
dto.setStart_point_code(this.getDevice().getDevice_code());
|
||||
dto.setVehicle_code(container_code);
|
||||
dto.setVehicle_type(container_type);
|
||||
|
||||
String taskcode = CodeUtil.getNewCode("TASK_NO");
|
||||
dto.setTask_code("-" + taskcode);
|
||||
dto.setTask_status("0");
|
||||
dto.setPriority("101");
|
||||
RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code());
|
||||
String next_device_codecode = jo.getNext_device_code();
|
||||
if (StrUtil.isEmpty(next_device_codecode)) {
|
||||
throw new RuntimeException("该设备未找到对应路由");
|
||||
}
|
||||
dto.setNext_point_code(next_device_codecode);
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
|
||||
wo.insert(json);
|
||||
requireSucess = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.acs.device_driver.standard_inspect_site;
|
||||
package org.nl.acs.device_driver.inspect_site.standard_inspect_site;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.acs.device_driver.standard_inspect_site;
|
||||
package org.nl.acs.device_driver.inspect_site.standard_inspect_site;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.acs.device_driver.standard_inspect_site;
|
||||
package org.nl.acs.device_driver.inspect_site.standard_inspect_site;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
@@ -135,7 +135,7 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
|
||||
public void writing(int command) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + org.nl.acs.device_driver.standard_inspect_site.ItemProtocol.item_to_command;
|
||||
+ "." + org.nl.acs.device_driver.inspect_site.standard_inspect_site.ItemProtocol.item_to_command;
|
||||
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
|
||||
@@ -9,7 +9,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.config.AcsConfig;
|
||||
import org.nl.acs.config.server.AcsConfigService;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
import org.nl.acs.device_driver.autodoor.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_conveyor_monitor.StandardCoveyorMonitorDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_scanner.StandardScannerDeviceDriver;
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device.service.impl.DeviceServiceImpl;
|
||||
import org.nl.acs.device_driver.lamp_three_color.LampThreecolorDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.opc.Device;
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device.service.StorageCellService;
|
||||
import org.nl.acs.device.service.dto.DeviceAssignedDto;
|
||||
import org.nl.acs.device.service.impl.DeviceServiceImpl;
|
||||
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
@@ -29,7 +29,6 @@ import org.nl.acs.instruction.service.dto.InstructionDto;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.opc.DeviceType;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.task.service.TaskFeedbackService;
|
||||
|
||||
@@ -8,13 +8,13 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
import org.nl.acs.device_driver.autodoor.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_conveyor_control.StandardCoveyorControlDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_conveyor_control_with_plcscanner.StandardCoveyorControlWithPlcScannerDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_conveyor_monitor.StandardCoveyorMonitorDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_rgv.StandardRGVDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_scanner.StandardScannerDeviceDriver;
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.nl.acs.config.AcsConfig;
|
||||
import org.nl.acs.config.server.AcsConfigService;
|
||||
import org.nl.acs.device_driver.lamp_three_color.LampThreecolorDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
|
||||
@@ -95,6 +95,8 @@ import manipulator_inspect_site_NDC from '@/views/acs/device/driver/manipulator_
|
||||
import standard_manipulator_stacking_site from '@/views/acs/device/driver/standard_manipulator_stacking_site'
|
||||
import standard_photoelectric_inspect_site from '@/views/acs/device/driver/standard_photoelectric_inspect_site'
|
||||
import electric_fence from '@/views/acs/device/driver/electric_fence'
|
||||
import modbus_autodoor from '@/views/acs/device/driver/modbus_autodoor'
|
||||
import modbus_inspect_site from '@/views/acs/device/driver/modbus_inspect_site'
|
||||
|
||||
export default {
|
||||
name: 'DeviceConfig',
|
||||
@@ -103,7 +105,7 @@ export default {
|
||||
lamp_three_color, standard_storage, special_ordinary_site, standard_scanner, standard_conveyor_control_with_scanner,
|
||||
standard_conveyor_control_with_plcscanner, standard_conveyor_control, standard_conveyor_monitor, weighing_site, machines_site, non_line_manipulator_inspect_site,
|
||||
non_line_inspect_site, manipulator_inspect_site_NDC, standard_manipulator_stacking_site,
|
||||
standard_photoelectric_inspect_site, electric_fence },
|
||||
standard_photoelectric_inspect_site, electric_fence, modbus_autodoor, modbus_inspect_site },
|
||||
dicts: ['device_type'],
|
||||
mixins: [crud],
|
||||
data() {
|
||||
|
||||
352
acs/qd/src/views/acs/device/driver/modbus_autodoor.vue
Normal file
352
acs/qd/src/views/acs/device/driver/modbus_autodoor.vue
Normal file
@@ -0,0 +1,352 @@
|
||||
<template>
|
||||
<!--自动门-->
|
||||
<div>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">设备协议:</span>
|
||||
</div>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
OpcServer:
|
||||
<el-select
|
||||
v-model="opc_id"
|
||||
placeholder="无"
|
||||
clearable
|
||||
@change="changeOpc"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dataOpcservers"
|
||||
:key="item.opc_id"
|
||||
:label="item.opc_name"
|
||||
:value="item.opc_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
PLC:
|
||||
<el-select
|
||||
v-model="plc_id"
|
||||
placeholder="无"
|
||||
clearable
|
||||
@change="changePlc"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dataOpcPlcs"
|
||||
:key="item.plc_id"
|
||||
:label="item.plc_name"
|
||||
:value="item.plc_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">输送系统:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="电气调度号" label-width="150px">
|
||||
<el-switch v-model="form.OPCServer" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">PLC读取字段:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-table
|
||||
v-loading="false"
|
||||
:data="data1"
|
||||
:max-height="550"
|
||||
size="small"
|
||||
style="width: 100%;margin-bottom: 15px"
|
||||
>
|
||||
|
||||
<el-table-column prop="name" label="用途" />
|
||||
<el-table-column prop="code" label="别名要求" />
|
||||
<el-table-column prop="db" label="DB块">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-model="data1[scope.$index].db"
|
||||
size="mini"
|
||||
class="edit-input"
|
||||
@input="finishReadEdit(data1[scope.$index])"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="dbr_value">
|
||||
<template slot="header">
|
||||
<el-link type="primary" :underline="false" @click.native="test_read1()">测试读</el-link>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="data1[scope.$index].dbr_value" size="mini" class="edit-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">PLC写入字段:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-table
|
||||
v-loading="false"
|
||||
:data="data2"
|
||||
:max-height="550"
|
||||
size="small"
|
||||
style="width: 100%;margin-bottom: 15px"
|
||||
>
|
||||
|
||||
<el-table-column prop="name" label="用途" />
|
||||
<el-table-column prop="code" label="别名要求" />
|
||||
<el-table-column prop="db" label="DB块">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-model="data2[scope.$index].db"
|
||||
size="mini"
|
||||
class="edit-input"
|
||||
@input="finishWriteEdit(data2[scope.$index])"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="dbw_value">
|
||||
<template slot="header">
|
||||
<el-link type="primary" :underline="false" @click.native="test_write1()">测试写</el-link>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="data2[scope.$index].dbw_value" size="mini" class="edit-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span" />
|
||||
<el-button
|
||||
:loading="false"
|
||||
icon="el-icon-check"
|
||||
size="mini"
|
||||
style="float: right; padding: 6px 9px"
|
||||
type="primary"
|
||||
@click="doSubmit"
|
||||
>保存
|
||||
</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
queryDriverConfig,
|
||||
updateConfig,
|
||||
testRead,
|
||||
testwrite
|
||||
} from '@/api/acs/device/driverConfig'
|
||||
import { selectOpcList } from '@/api/acs/device/opc'
|
||||
import { selectPlcList } from '@/api/acs/device/opcPlc'
|
||||
import { selectListByOpcID } from '@/api/acs/device/opcPlc'
|
||||
|
||||
import crud from '@/mixins/crud'
|
||||
|
||||
export default {
|
||||
name: 'StandardAutodoor',
|
||||
mixins: [crud],
|
||||
props: {
|
||||
parentForm: {
|
||||
type: Object,
|
||||
require: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
device_code: '',
|
||||
device_id: '',
|
||||
plc_id: '',
|
||||
plc_code: '',
|
||||
opc_id: '',
|
||||
opc_code: '',
|
||||
configLoading: false,
|
||||
dataOpcservers: [],
|
||||
dataOpcPlcs: [],
|
||||
data1: [],
|
||||
data2: [],
|
||||
form: {
|
||||
inspect_in_stocck: true,
|
||||
ignore_pickup_check: true,
|
||||
ignore_release_check: true,
|
||||
apply_task: true,
|
||||
manual_create_task: true,
|
||||
is_pickup: true,
|
||||
is_release: true
|
||||
},
|
||||
rules: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$nextTick(() => {
|
||||
// 从父表单获取设备编码
|
||||
this.device_id = this.$props.parentForm.device_id
|
||||
this.device_code = this.$props.parentForm.device_code
|
||||
queryDriverConfig(this.device_id, this.$props.parentForm.driver_code).then(data => {
|
||||
// 给表单赋值,并且属性不能为空
|
||||
if (data.form) {
|
||||
const arr = Object.keys(data.form)
|
||||
// 不为空
|
||||
if (arr.length > 0) {
|
||||
this.form = data.form
|
||||
}
|
||||
}
|
||||
|
||||
// 给表单赋值,并且属性不能为空
|
||||
if (data.parentForm) {
|
||||
const arr = Object.keys(data.parentForm)
|
||||
// 不为空
|
||||
if (arr.length > 0) {
|
||||
this.opc_code = data.parentForm.opc_code
|
||||
this.plc_code = data.parentForm.plc_code
|
||||
}
|
||||
}
|
||||
this.data1 = data.rs
|
||||
this.data2 = data.ws
|
||||
this.sliceItem()
|
||||
})
|
||||
selectPlcList().then(data => {
|
||||
this.dataOpcPlcs = data
|
||||
this.plc_id = this.$props.parentForm.opc_plc_id
|
||||
})
|
||||
selectOpcList().then(data => {
|
||||
this.dataOpcservers = data
|
||||
this.opc_id = this.$props.parentForm.opc_server_id
|
||||
})
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
changeOpc(val) {
|
||||
this.dataOpcservers.forEach(item => {
|
||||
if (item.opc_id === val) {
|
||||
this.opc_code = item.opc_code
|
||||
}
|
||||
})
|
||||
selectListByOpcID(val).then(data => {
|
||||
this.dataOpcPlcs = data
|
||||
this.plc_id = ''
|
||||
this.plc_code = ''
|
||||
if (this.dataOpcPlcs && this.dataOpcPlcs.length > 0) {
|
||||
this.plc_id = this.dataOpcPlcs[0].plc_id
|
||||
this.plc_code = this.dataOpcPlcs[0].plc_code
|
||||
}
|
||||
this.sliceItem()
|
||||
})
|
||||
},
|
||||
finishReadEdit(data) {
|
||||
// 编辑的是code列,并且值包含mode
|
||||
if (data.code.indexOf('mode') !== -1) {
|
||||
const dbValue = data.db
|
||||
// .之前的字符串
|
||||
const beforeStr = dbValue.match(/(\S*)\./)[1]
|
||||
// .之后的字符串
|
||||
const afterStr = dbValue.match(/\.(\S*)/)[1]
|
||||
// 取最后数字
|
||||
const endNumber = afterStr.substring(1)
|
||||
// 最后为非数字
|
||||
if (isNaN(parseInt(endNumber))) {
|
||||
return
|
||||
}
|
||||
for (const val in this.data1) {
|
||||
if (this.data1[val].code.indexOf('action') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 1)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('error') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
changePlc(val) {
|
||||
this.dataOpcPlcs.forEach(item => {
|
||||
if (item.plc_id === val) {
|
||||
this.plc_code = item.plc_code
|
||||
this.sliceItem()
|
||||
return
|
||||
}
|
||||
})
|
||||
},
|
||||
test_read1() {
|
||||
testRead(this.data1, this.opc_id).then(data => {
|
||||
this.data1 = data
|
||||
this.notify('操作成功!', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
test_write1() {
|
||||
testwrite(this.data2, this.opc_id).then(data => {
|
||||
this.notify('操作成功!', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
doSubmit() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.configLoading = true
|
||||
// 根据驱动类型判断是否为路由设备
|
||||
const parentForm = this.parentForm
|
||||
parentForm.is_route = true
|
||||
parentForm.plc_id = this.plc_id
|
||||
parentForm.opc_id = this.opc_id
|
||||
updateConfig(parentForm, this.form, this.data1, this.data2).then(res => {
|
||||
this.notify('保存成功', 'success')
|
||||
this.configLoading = false
|
||||
}).catch(err => {
|
||||
this.configLoading = false
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
sliceItem() { // 拼接DB的Item值
|
||||
this.data1.forEach(item => {
|
||||
const str = item.code
|
||||
// 是否包含.
|
||||
if (str.search('.') !== -1) {
|
||||
// 截取最后一位
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
|
||||
} else {
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
|
||||
}
|
||||
})
|
||||
this.data2.forEach(item => {
|
||||
const str = item.code
|
||||
// 是否包含.
|
||||
if (str.search('.') !== -1) {
|
||||
// 截取最后一位
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
|
||||
} else {
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
490
acs/qd/src/views/acs/device/driver/modbus_inspect_site.vue
Normal file
490
acs/qd/src/views/acs/device/driver/modbus_inspect_site.vue
Normal file
@@ -0,0 +1,490 @@
|
||||
<template>
|
||||
<!--检测站点-->
|
||||
<div>
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">设备协议:</span>
|
||||
</div>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
OpcServer:
|
||||
<el-select
|
||||
v-model="opc_id"
|
||||
placeholder="无"
|
||||
clearable
|
||||
@change="changeOpc"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dataOpcservers"
|
||||
:key="item.opc_id"
|
||||
:label="item.opc_name"
|
||||
:value="item.opc_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
PLC:
|
||||
<el-select
|
||||
v-model="plc_id"
|
||||
placeholder="无"
|
||||
clearable
|
||||
@change="changePlc"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dataOpcPlcs"
|
||||
:key="item.plc_id"
|
||||
:label="item.plc_name"
|
||||
:value="item.plc_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">输送系统:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="电气调度号" label-width="150px">
|
||||
<el-input v-model="form.OPCServer" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">指令相关:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="检验有货">
|
||||
<el-switch v-model="form.inspect_in_stocck" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="忽视取货校验" label-width="150px">
|
||||
<el-switch v-model="form.ignore_pickup_check" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="忽视放货校验" label-width="150px">
|
||||
<el-switch v-model="form.ignore_release_check" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="呼叫">
|
||||
<el-switch v-model="form.apply_task" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="响应" label-width="150px">
|
||||
<el-switch v-model="form.manual_create_task" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="关联设备" prop="device_code">
|
||||
<el-select
|
||||
v-model="form.link_device_code"
|
||||
filterable
|
||||
multiple
|
||||
placeholder="请选择"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in deviceList"
|
||||
:key="item.device_code"
|
||||
:label="item.device_name"
|
||||
:value="item.device_code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="关联三色灯" prop="device_code" label-width="100px">
|
||||
<el-select
|
||||
v-model="form.link_three_lamp"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="请选择"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in deviceList"
|
||||
:key="item.device_code"
|
||||
:label="item.device_name"
|
||||
:value="item.device_code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="是否输入物料" label-width="150px">
|
||||
<el-switch v-model="form.input_material" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">AGV相关:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="取货">
|
||||
<el-switch v-model="form.is_pickup" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="放货">
|
||||
<el-switch v-model="form.is_release" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">PLC读取字段:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-table
|
||||
v-loading="false"
|
||||
:data="data1"
|
||||
:max-height="550"
|
||||
size="small"
|
||||
style="width: 100%;margin-bottom: 15px"
|
||||
>
|
||||
|
||||
<el-table-column prop="name" label="用途" />
|
||||
<el-table-column prop="code" label="别名要求" />
|
||||
<el-table-column prop="db" label="DB块">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-model="data1[scope.$index].db"
|
||||
size="mini"
|
||||
class="edit-input"
|
||||
@input="finishReadEdit(data1[scope.$index])"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="dbr_value">
|
||||
<template slot="header">
|
||||
<el-link type="primary" :underline="false" @click.native="test_read1()">测试读</el-link>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="data1[scope.$index].dbr_value" size="mini" class="edit-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">PLC写入字段:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-table
|
||||
v-loading="false"
|
||||
:data="data2"
|
||||
:max-height="550"
|
||||
size="small"
|
||||
style="width: 100%;margin-bottom: 15px"
|
||||
>
|
||||
|
||||
<el-table-column prop="name" label="用途" />
|
||||
<el-table-column prop="code" label="别名要求" />
|
||||
<el-table-column prop="db" label="DB块">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-model="data2[scope.$index].db"
|
||||
size="mini"
|
||||
class="edit-input"
|
||||
@input="finishWriteEdit(data2[scope.$index])"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="dbw_value">
|
||||
<template slot="header">
|
||||
<el-link type="primary" :underline="false" @click.native="test_write1()">测试写</el-link>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="data2[scope.$index].dbw_value" size="mini" class="edit-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span" />
|
||||
<el-button
|
||||
:loading="false"
|
||||
icon="el-icon-check"
|
||||
size="mini"
|
||||
style="float: right; padding: 6px 9px"
|
||||
type="primary"
|
||||
@click="doSubmit"
|
||||
>保存
|
||||
</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
queryDriverConfig,
|
||||
updateConfig,
|
||||
testRead,
|
||||
testwrite
|
||||
} from '@/api/acs/device/driverConfig'
|
||||
import { selectOpcList } from '@/api/acs/device/opc'
|
||||
import { selectPlcList } from '@/api/acs/device/opcPlc'
|
||||
import { selectListByOpcID } from '@/api/acs/device/opcPlc'
|
||||
|
||||
import crud from '@/mixins/crud'
|
||||
import deviceCrud from '@/api/acs/device/device'
|
||||
|
||||
export default {
|
||||
name: 'StandardInspectSite',
|
||||
mixins: [crud],
|
||||
props: {
|
||||
parentForm: {
|
||||
type: Object,
|
||||
require: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
device_code: '',
|
||||
device_id: '',
|
||||
plc_id: '',
|
||||
plc_code: '',
|
||||
opc_id: '',
|
||||
opc_code: '',
|
||||
configLoading: false,
|
||||
dataOpcservers: [],
|
||||
dataOpcPlcs: [],
|
||||
deviceList: [],
|
||||
data1: [],
|
||||
data2: [],
|
||||
form: {
|
||||
inspect_in_stocck: true,
|
||||
ignore_pickup_check: true,
|
||||
ignore_release_check: true,
|
||||
apply_task: true,
|
||||
link_three_lamp: '',
|
||||
manual_create_task: true,
|
||||
is_pickup: true,
|
||||
is_release: true,
|
||||
link_device_code: []
|
||||
},
|
||||
rules: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$nextTick(() => {
|
||||
// 从父表单获取设备编码
|
||||
this.device_id = this.$props.parentForm.device_id
|
||||
this.device_code = this.$props.parentForm.device_code
|
||||
queryDriverConfig(this.device_id, this.$props.parentForm.driver_code).then(data => {
|
||||
// 给表单赋值,并且属性不能为空
|
||||
if (data.form) {
|
||||
const arr = Object.keys(data.form)
|
||||
// 不为空
|
||||
if (arr.length > 0) {
|
||||
this.form = data.form
|
||||
}
|
||||
}
|
||||
|
||||
// 给表单赋值,并且属性不能为空
|
||||
if (data.parentForm) {
|
||||
const arr = Object.keys(data.parentForm)
|
||||
// 不为空
|
||||
if (arr.length > 0) {
|
||||
this.opc_code = data.parentForm.opc_code
|
||||
this.plc_code = data.parentForm.plc_code
|
||||
}
|
||||
}
|
||||
this.data1 = data.rs
|
||||
this.data2 = data.ws
|
||||
this.sliceItem()
|
||||
})
|
||||
selectPlcList().then(data => {
|
||||
this.dataOpcPlcs = data
|
||||
this.plc_id = this.$props.parentForm.opc_plc_id
|
||||
})
|
||||
selectOpcList().then(data => {
|
||||
this.dataOpcservers = data
|
||||
this.opc_id = this.$props.parentForm.opc_server_id
|
||||
})
|
||||
deviceCrud.selectDeviceList().then(data => {
|
||||
this.deviceList = data
|
||||
})
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
finishReadEdit(data) {
|
||||
// 编辑的是code列,并且值包含mode
|
||||
if (data.code.indexOf('mode') !== -1) {
|
||||
debugger
|
||||
const dbValue = data.db
|
||||
// .之前的字符串
|
||||
const beforeStr = dbValue.match(/(\S*)\./)[1]
|
||||
// .之后的字符串
|
||||
const afterStr = dbValue.match(/\.(\S*)/)[1]
|
||||
// 取最后数字
|
||||
const endNumber = afterStr.substring(1)
|
||||
// 最后为非数字
|
||||
if (isNaN(parseInt(endNumber))) {
|
||||
return
|
||||
}
|
||||
for (const val in this.data1) {
|
||||
if (this.data1[val].code.indexOf('heartbeat') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) - 1)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('move') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 1)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('error') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('task') !== -1) {
|
||||
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
finishWriteEdit(data) {
|
||||
// 编辑的是code列,并且值包含mode
|
||||
if (data.code.indexOf('to_command') !== -1) {
|
||||
const dbValue = data.db
|
||||
// .之前的字符串
|
||||
const beforeStr = dbValue.match(/(\S*)\./)[1]
|
||||
// .之后的字符串
|
||||
const afterStr = dbValue.match(/\.(\S*)/)[1]
|
||||
// 取最后数字
|
||||
const endNumber = afterStr.substring(1)
|
||||
// 最后为非数字
|
||||
if (isNaN(parseInt(endNumber))) {
|
||||
return
|
||||
}
|
||||
for (const val in this.data2) {
|
||||
if (this.data2[val].code.indexOf('to_target') !== -1) {
|
||||
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
|
||||
}
|
||||
if (this.data2[val].code.indexOf('to_task') !== -1) {
|
||||
this.data2[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 4)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
changeOpc(val) {
|
||||
this.dataOpcservers.forEach(item => {
|
||||
if (item.opc_id === val) {
|
||||
this.opc_code = item.opc_code
|
||||
}
|
||||
})
|
||||
|
||||
selectListByOpcID(val).then(data => {
|
||||
this.dataOpcPlcs = data
|
||||
this.plc_id = ''
|
||||
this.plc_code = ''
|
||||
if (this.dataOpcPlcs && this.dataOpcPlcs.length > 0) {
|
||||
this.plc_id = this.dataOpcPlcs[0].plc_id
|
||||
this.plc_code = this.dataOpcPlcs[0].plc_code
|
||||
}
|
||||
this.sliceItem()
|
||||
})
|
||||
},
|
||||
changePlc(val) {
|
||||
this.dataOpcPlcs.forEach(item => {
|
||||
if (item.plc_id === val) {
|
||||
this.plc_code = item.plc_code
|
||||
this.sliceItem()
|
||||
return
|
||||
}
|
||||
})
|
||||
},
|
||||
test_read1() {
|
||||
testRead(this.data1, this.opc_id).then(data => {
|
||||
this.data1 = data
|
||||
this.notify('操作成功!', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
test_write1() {
|
||||
testwrite(this.data2, this.opc_id).then(data => {
|
||||
this.notify('操作成功!', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
doSubmit() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.configLoading = true
|
||||
// 根据驱动类型判断是否为路由设备
|
||||
const parentForm = this.parentForm
|
||||
parentForm.is_route = true
|
||||
parentForm.plc_id = this.plc_id
|
||||
parentForm.opc_id = this.opc_id
|
||||
updateConfig(parentForm, this.form, this.data1, this.data2).then(res => {
|
||||
this.notify('保存成功', 'success')
|
||||
this.configLoading = false
|
||||
}).catch(err => {
|
||||
this.configLoading = false
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
sliceItem() { // 拼接DB的Item值
|
||||
this.data1.forEach(item => {
|
||||
const str = item.code
|
||||
// 是否包含.
|
||||
if (str.search('.') !== -1) {
|
||||
// 截取最后一位
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
|
||||
} else {
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
|
||||
}
|
||||
})
|
||||
this.data2.forEach(item => {
|
||||
const str = item.code
|
||||
// 是否包含.
|
||||
if (str.search('.') !== -1) {
|
||||
// 截取最后一位
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
|
||||
} else {
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -103,13 +103,23 @@ public class PadController {
|
||||
/**
|
||||
* 查询物料
|
||||
*
|
||||
* @return 所有物料
|
||||
* @param param String device_id 点位标识
|
||||
* @return 点位可以选择的物料
|
||||
*/
|
||||
@PostMapping("/matrial")
|
||||
@Log("查询物料")
|
||||
@ApiOperation("查询物料")
|
||||
public ResponseEntity<JSONObject> material() {
|
||||
return new ResponseEntity<>(padService.material(), HttpStatus.OK);
|
||||
public ResponseEntity<JSONObject> material(@RequestBody JSONObject param) {
|
||||
// 参数校验
|
||||
String point_id = param.getString("device_id");
|
||||
if (StrUtil.isEmpty(point_id)) {
|
||||
JSONObject resultJSON = new JSONObject();
|
||||
resultJSON.put("code", "0");
|
||||
resultJSON.put("desc", "点位不能为空");
|
||||
return new ResponseEntity<>(resultJSON, HttpStatus.OK);
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(padService.material(point_id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,9 +41,10 @@ public interface PadService {
|
||||
/**
|
||||
* 查询物料
|
||||
*
|
||||
* @return 所有物料
|
||||
* @param point_id 点位标识
|
||||
* @return 点位可以选择的物料
|
||||
*/
|
||||
JSONObject material();
|
||||
JSONObject material(String point_id);
|
||||
|
||||
/**
|
||||
* 点位状态绑定
|
||||
|
||||
@@ -179,15 +179,22 @@ public class PadServiceImpl implements PadService {
|
||||
/**
|
||||
* 查询物料
|
||||
*
|
||||
* @return 所有物料
|
||||
* @param point_id 点位标识
|
||||
* @return 点位可以选择的物料
|
||||
*/
|
||||
@Override
|
||||
public JSONObject material() {
|
||||
public JSONObject material(String point_id) {
|
||||
// 返回值
|
||||
JSONObject resultJSON = new JSONObject();
|
||||
|
||||
// 查询物料
|
||||
resultJSON.put("result", WQL.getWO("PAD").addParam("flag", "3").process().getResultJSONArray(0));
|
||||
resultJSON.put("result",
|
||||
WQL
|
||||
.getWO("PAD")
|
||||
.addParam("flag", "3")
|
||||
.addParam("point_id", point_id)
|
||||
.process()
|
||||
.getResultJSONArray(0));
|
||||
|
||||
// 返回
|
||||
resultJSON.put("code", "1");
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#################################################
|
||||
输入.flag TYPEAS s_string
|
||||
输入.region_id TYPEAS s_string
|
||||
输入.point_id TYPEAS s_string
|
||||
输入.lock_type TYPEAS s_string
|
||||
输入.col TYPEAS s_string
|
||||
|
||||
@@ -86,12 +87,15 @@
|
||||
IF 输入.flag = "3"
|
||||
QUERY
|
||||
SELECT
|
||||
`value`,
|
||||
label
|
||||
dd.label,
|
||||
dd.`value`
|
||||
FROM
|
||||
sys_dict_detail
|
||||
sch_base_point point
|
||||
LEFT JOIN sch_base_point_material pm ON point.point_id = pm.point_id
|
||||
LEFT JOIN sys_dict_detail dd ON pm.material = dd.`value`
|
||||
AND dd.`name` = 'material_type'
|
||||
WHERE
|
||||
`name` = 'current_material_type'
|
||||
point.point_id = 输入.point_id
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
@@ -43,7 +43,7 @@ public class PointController {
|
||||
@Log("新增点位")
|
||||
@ApiOperation("新增点位")
|
||||
//@PreAuthorize("@el.check('point:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody PointDto dto) {
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody JSONObject dto) {
|
||||
pointService.create(dto);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class PointController {
|
||||
@Log("修改点位")
|
||||
@ApiOperation("修改点位")
|
||||
//@PreAuthorize("@el.check('point:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody PointDto dto) {
|
||||
public ResponseEntity<Object> updatePoint(@Validated @RequestBody JSONObject dto) {
|
||||
pointService.update(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.sch.service.dto.PointDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -22,21 +21,21 @@ public interface PointService {
|
||||
* @param page 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(Map whereJson, Pageable page);
|
||||
Map<String,Object> queryAll(Map<String, Object> whereJson, Pageable page);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param whereJson 条件参数
|
||||
* @return List<PointDto>
|
||||
*/
|
||||
List<PointDto> queryAll(Map whereJson);
|
||||
JSONArray queryAll(Map whereJson);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param point_id ID
|
||||
* @return Point
|
||||
*/
|
||||
PointDto findById(Long point_id);
|
||||
JSONObject findById(Long point_id);
|
||||
|
||||
/**
|
||||
* 根据编码查询
|
||||
@@ -50,13 +49,13 @@ public interface PointService {
|
||||
* 创建
|
||||
* @param dto /
|
||||
*/
|
||||
void create(PointDto dto);
|
||||
void create(JSONObject dto);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param dto /
|
||||
*/
|
||||
void update(PointDto dto);
|
||||
void update(JSONObject dto);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
|
||||
@@ -131,11 +131,6 @@ public class PointDto implements Serializable {
|
||||
*/
|
||||
private String material_code;
|
||||
|
||||
/**
|
||||
* 物料类型
|
||||
*/
|
||||
private String material_type;
|
||||
|
||||
/**
|
||||
* 上一区域id
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,6 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mchange.lang.DoubleUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.exception.BadRequestException;
|
||||
@@ -25,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
@@ -36,8 +36,8 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
public class PointServiceImpl implements PointService {
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
HashMap map = new HashMap();
|
||||
public Map<String, Object> queryAll(Map<String, Object> whereJson, Pageable page) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("flag", "1");
|
||||
map.put("region_id", whereJson.get("region_id"));
|
||||
map.put("ids", whereJson.get("ids"));
|
||||
@@ -46,27 +46,34 @@ public class PointServiceImpl implements PointService {
|
||||
map.put("is_used", whereJson.get("is_used"));
|
||||
map.put("point_type", whereJson.get("point_type"));
|
||||
map.put("name", whereJson.get("name"));
|
||||
JSONObject json = WQL.getWO("QSCH_BASE_POINT").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "point_code asc");
|
||||
return json;
|
||||
}
|
||||
JSONObject result = WQL.getWO("QSCH_BASE_POINT").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "point_code asc");
|
||||
|
||||
@Override
|
||||
public List<PointDto> queryAll(Map whereJson) {
|
||||
WQLObject wo = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONArray arr = wo.query().getResultJSONArray(0);
|
||||
List<PointDto> list = arr.toJavaList(PointDto.class);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointDto findById(Long point_id) {
|
||||
WQLObject wo = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONObject json = wo.query("point_id =" + point_id + "").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(PointDto.class);
|
||||
JSONArray content = result.getJSONArray("content");
|
||||
WQLObject pm_table = WQLObject.getWQLObject("sch_base_point_material");
|
||||
for (Object o : content) {
|
||||
JSONObject point = (JSONObject) o;
|
||||
List<String> material_type = pm_table
|
||||
.query("point_id = " + point.getString("point_id"))
|
||||
.getResultJSONArray(0)
|
||||
.stream()
|
||||
.map(pm -> ((JSONObject) pm).getString("material"))
|
||||
.collect(Collectors.toList());
|
||||
point.put("material_type", material_type);
|
||||
}
|
||||
final PointDto obj = json.toJavaObject(PointDto.class);
|
||||
return obj;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray queryAll(Map whereJson) {
|
||||
WQLObject wo = WQLObject.getWQLObject("sch_base_point");
|
||||
return wo.query().getResultJSONArray(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject findById(Long point_id) {
|
||||
WQLObject wo = WQLObject.getWQLObject("sch_base_point");
|
||||
return wo.query("point_id =" + point_id + "").uniqueResult(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,103 +89,134 @@ public class PointServiceImpl implements PointService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(PointDto dto) {
|
||||
public void create(JSONObject dto) {
|
||||
// 参数校验
|
||||
PointDto byCode = this.findByCode(dto.getPoint_code());
|
||||
PointDto byCode = this.findByCode(dto.getString("point_code"));
|
||||
if (ObjectUtil.isNotEmpty(byCode)) {
|
||||
throw new BadRequestException("存在相同的点位编码");
|
||||
}
|
||||
if (!StrUtil.equals(dto.getMaterial_type(), "14")) {
|
||||
int count = WQLObject.getWQLObject("sch_base_point")
|
||||
.query("is_delete = '0' AND seq = " + dto.getSeq() + " AND region_id = " + dto.getRegion_id() + "'")
|
||||
.getResultJSONArray(0)
|
||||
.size();
|
||||
if (count > 0) {
|
||||
throw new BadRequestException("该区域存在相同的出入库顺序");
|
||||
}
|
||||
int count = WQLObject.getWQLObject("sch_base_point")
|
||||
.query("is_delete = '0' AND seq = " + dto.getLong("seq") + " AND region_id = '" + dto.getString("region_id") + "'")
|
||||
.getResultJSONArray(0)
|
||||
.size();
|
||||
if (count > 0) {
|
||||
throw new BadRequestException("该区域存在相同的出入库顺序");
|
||||
}
|
||||
if (StrUtil.equals(dto.getPoint_status(), "00") && !StrUtil.equals(dto.getCurrent_material_type(), "14")) {
|
||||
String current_material_type = dto.getString("current_material_type");
|
||||
if (StrUtil.equals(dto.getString("point_status"), "00") && StrUtil.isNotBlank(current_material_type)) {
|
||||
throw new BadRequestException("当前为空位但是存放物料类型不为空");
|
||||
}
|
||||
if (StrUtil.equals(dto.getPoint_status(), "01") && StrUtil.equals(dto.getCurrent_material_type(), "14")) {
|
||||
if (StrUtil.equals(dto.getString("point_status"), "01") && StrUtil.isBlank(current_material_type)) {
|
||||
throw new BadRequestException("当前为有货但是存放物料类型为空");
|
||||
}
|
||||
if (dto.getSeq() < 0L) {
|
||||
if (dto.getLongValue("seq") < 0L) {
|
||||
throw new BadRequestException("出入库顺序号不能小于0");
|
||||
}
|
||||
if (dto.getCol() < 0L) {
|
||||
if (dto.getLongValue("col") < 0L) {
|
||||
throw new BadRequestException("排号不能小于0");
|
||||
}
|
||||
JSONObject colPoint = WQLObject.getWQLObject("sch_base_point").query("region_id = '" + dto.getRegion_id() + "' AND col = " + dto.getCol()).uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(colPoint) && !StrUtil.equals(colPoint.getString("material_type"), dto.getMaterial_type())) {
|
||||
throw new BadRequestException("当前排不能限定这种物料");
|
||||
}
|
||||
if (!StrUtil.equals(dto.getCurrent_material_type(), "14")
|
||||
&& !StrUtil.equals(dto.getMaterial_type(), "14")
|
||||
&& !StrUtil.equals(dto.getMaterial_type(), dto.getCurrent_material_type())) {
|
||||
throw new BadRequestException("当前存放物料与限定物料不一致");
|
||||
List<String> material_types = dto.getJSONArray("material_type").stream().map(Object::toString).collect(Collectors.toList());
|
||||
if (StrUtil.isNotBlank(current_material_type) && !material_types.contains(current_material_type)) {
|
||||
throw new BadRequestException("该点位不能存放这种物料");
|
||||
}
|
||||
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getNickName();
|
||||
String now = DateUtil.now();
|
||||
dto.setPoint_id(IdUtil.getSnowflake(1, 1).nextId());
|
||||
dto.setCreate_id(currentUserId);
|
||||
dto.setCreate_name(nickName);
|
||||
dto.setUpdate_optid(currentUserId);
|
||||
dto.setUpdate_optname(nickName);
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
WQLObject pm_table = WQLObject.getWQLObject("sch_base_point_material");
|
||||
long point_id = IdUtil.createSnowflake(1L, 1L).nextId();
|
||||
JSONObject pm = new JSONObject();
|
||||
pm.put("point_id", point_id);
|
||||
for (String material_type : material_types) {
|
||||
pm.put("pm_id", IdUtil.getSnowflake(1L, 1L).nextId());
|
||||
pm.put("material", material_type);
|
||||
pm_table.insert(pm);
|
||||
}
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.insert(json);
|
||||
JSONObject point = new JSONObject();
|
||||
point.put("point_id", point_id);
|
||||
point.put("point_code", dto.getString("point_code"));
|
||||
point.put("point_name", dto.getString("point_name"));
|
||||
point.put("point_status", dto.getString("point_status"));
|
||||
point.put("lock_type", dto.getString("lock_type"));
|
||||
point.put("current_material_type", dto.getString("current_material_type"));
|
||||
point.put("col", dto.getString("col"));
|
||||
point.put("region_id", dto.getString("region_id"));
|
||||
point.put("prev_region_id", dto.getString("prev_region_id"));
|
||||
point.put("next_region_id", dto.getString("next_region_id"));
|
||||
point.put("seq", dto.getString("seq"));
|
||||
point.put("remark", dto.getString("remark"));
|
||||
point.put("create_id", SecurityUtils.getCurrentUserId());
|
||||
point.put("create_name", SecurityUtils.getNickName());
|
||||
point.put("create_time", DateUtil.now());
|
||||
WQLObject.getWQLObject("sch_base_point").insert(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(PointDto dto) {
|
||||
Long pointId = dto.getPoint_id();
|
||||
PointDto entity = this.findById(pointId);
|
||||
public void update(JSONObject dto) {
|
||||
Long point_id = dto.getLong("point_id");
|
||||
JSONObject entity = this.findById(point_id);
|
||||
if (entity == null) {
|
||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
}
|
||||
|
||||
// 参数校验
|
||||
PointDto byCode = this.findByCode(dto.getPoint_code());
|
||||
if (!byCode.getPoint_id().equals(pointId)) {
|
||||
PointDto byCode = this.findByCode(dto.getString("point_code"));
|
||||
if (!byCode.getPoint_id().equals(point_id)) {
|
||||
throw new BadRequestException("该点位编码已被其他点位占用");
|
||||
}
|
||||
if (!StrUtil.equals(dto.getMaterial_type(), "14")) {
|
||||
int count = WQLObject.getWQLObject("sch_base_point")
|
||||
.query("is_delete = '0' AND seq = " + dto.getSeq() + " AND region_id = " + dto.getRegion_id() + " AND point_id <> " + pointId)
|
||||
.getResultJSONArray(0)
|
||||
.size();
|
||||
if (count > 0) {
|
||||
throw new BadRequestException("该区域的其他点位中存在相同的出入库顺序");
|
||||
}
|
||||
int count = WQLObject.getWQLObject("sch_base_point")
|
||||
.query("is_delete = '0' AND seq = " + dto.getString("seq") + " AND region_id = " + dto.getLongValue("region_id") + " AND point_id <> " + point_id)
|
||||
.getResultJSONArray(0)
|
||||
.size();
|
||||
if (count > 0) {
|
||||
throw new BadRequestException("该区域的其他点位中存在相同的出入库顺序");
|
||||
}
|
||||
if (StrUtil.equals(dto.getPoint_status(), "00") && !StrUtil.equals(dto.getCurrent_material_type(), "14")) {
|
||||
|
||||
String current_material_type = dto.getString("current_material_type");
|
||||
if (StrUtil.equals(dto.getString("point_status"), "00") && StrUtil.isNotBlank(current_material_type)) {
|
||||
throw new BadRequestException("当前为空位但是存放物料类型不为空");
|
||||
}
|
||||
if (StrUtil.equals(dto.getPoint_status(), "01") && StrUtil.equals(dto.getCurrent_material_type(), "14")) {
|
||||
if (StrUtil.equals(dto.getString("point_status"), "01") && StrUtil.isBlank(current_material_type)) {
|
||||
throw new BadRequestException("当前为有货但是存放物料类型为空");
|
||||
}
|
||||
if (!StrUtil.equals(dto.getMaterial_type(), "14") && StrUtil.equals(dto.getCurrent_material_type(), dto.getMaterial_type())) {
|
||||
throw new BadRequestException("当前存放物料类型与限定物料类型不一致");
|
||||
if (dto.getLongValue("seq") < 0L) {
|
||||
throw new BadRequestException("出入库顺序号不能小于0");
|
||||
}
|
||||
if (dto.getLongValue("col") < 0L) {
|
||||
throw new BadRequestException("排号不能小于0");
|
||||
}
|
||||
List<String> material_types = dto.getJSONArray("material_type").stream().map(Object::toString).collect(Collectors.toList());
|
||||
if (StrUtil.isNotBlank(current_material_type) && !material_types.contains(current_material_type)) {
|
||||
throw new BadRequestException("该点位不能存放这种物料");
|
||||
}
|
||||
WQLObject pm_table = WQLObject.getWQLObject("sch_base_point_material");
|
||||
pm_table.delete("point_id = " + point_id);
|
||||
JSONObject pm = new JSONObject();
|
||||
pm.put("point_id", point_id);
|
||||
for (String material_type : material_types) {
|
||||
pm.put("pm_id", IdUtil.getSnowflake(1L, 1L).nextId());
|
||||
pm.put("material", material_type);
|
||||
pm_table.insert(pm);
|
||||
}
|
||||
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getNickName();
|
||||
JSONObject point = new JSONObject();
|
||||
point.put("point_code", dto.getString("point_code"));
|
||||
point.put("point_name", dto.getString("point_name"));
|
||||
point.put("point_status", dto.getString("point_status"));
|
||||
point.put("lock_type", dto.getString("lock_type"));
|
||||
point.put("current_material_type", dto.getString("current_material_type"));
|
||||
point.put("col", dto.getString("col"));
|
||||
point.put("region_id", dto.getString("region_id"));
|
||||
point.put("prev_region_id", dto.getString("prev_region_id"));
|
||||
point.put("next_region_id", dto.getString("next_region_id"));
|
||||
point.put("seq", dto.getString("seq"));
|
||||
point.put("remark", dto.getString("remark"));
|
||||
point.put("update_optid", SecurityUtils.getCurrentUserId());
|
||||
point.put("update_optname", SecurityUtils.getNickName());
|
||||
point.put("update_time", DateUtil.now());
|
||||
|
||||
String now = DateUtil.now();
|
||||
dto.setUpdate_time(now);
|
||||
dto.setUpdate_optid(currentUserId);
|
||||
dto.setUpdate_optname(nickName);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.update(json);
|
||||
WQLObject
|
||||
.getWQLObject("sch_base_point")
|
||||
.update(point, "point_id = " + point_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -82,10 +82,8 @@
|
||||
point.next_region_id,
|
||||
prev_region.region_name AS prev_region_name,
|
||||
next_region.region_name AS next_region_name,
|
||||
d5.label AS material_type_name,
|
||||
point.seq,
|
||||
d6.label AS current_material_type_name,
|
||||
point.material_type,
|
||||
point.current_material_type,
|
||||
point.col
|
||||
FROM
|
||||
@@ -96,7 +94,6 @@
|
||||
LEFT JOIN sys_dict_detail d4 ON point.point_status = d4.value and d4.name='sch_point_status'
|
||||
LEFT JOIN SCH_BASE_Region prev_region ON point.prev_region_id = prev_region.region_id
|
||||
LEFT JOIN SCH_BASE_Region next_region ON point.next_region_id = next_region.region_id
|
||||
LEFT JOIN sys_dict_detail d5 ON point.material_type = d5.`value` AND d5.`name` = 'material_type'
|
||||
LEFT JOIN sys_dict_detail d6 ON point.current_material_type = d6.`value` AND d6.`name` = 'current_material_type'
|
||||
WHERE
|
||||
point.is_delete = '0'
|
||||
|
||||
Binary file not shown.
@@ -8,12 +8,16 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.utils.SpringContextHolder;
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||
import org.nl.wql.WQL;
|
||||
import org.nl.wql.core.bean.WQLObject;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 徐工叫料任务类
|
||||
*
|
||||
@@ -25,8 +29,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Slf4j
|
||||
public class CallTask extends AbstractAcsTask {
|
||||
|
||||
private final SendTask sendTask = new SendTask();
|
||||
|
||||
/**
|
||||
* 更新任务状态
|
||||
*
|
||||
@@ -36,7 +38,7 @@ public class CallTask extends AbstractAcsTask {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void updateTaskStatus(JSONObject taskJSON, String status) {
|
||||
sendTask.updateTaskStatus(taskJSON, status);
|
||||
SpringContextHolder.getBean(SendTask.class).updateTaskStatus(taskJSON, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,12 +62,7 @@ public class CallTask extends AbstractAcsTask {
|
||||
@Override
|
||||
public String createTask(JSONObject param) {
|
||||
String nextPointCode = param.getString("next_point_code");
|
||||
String materialType = param.getString("material_type");
|
||||
|
||||
// 判断呼叫的物料类型
|
||||
if (StrUtil.equals(materialType, "14")) {
|
||||
throw new BadRequestException("不能呼叫空物料");
|
||||
}
|
||||
String materialType = param.getString("call_material_type");
|
||||
|
||||
// 判断点位是否存在
|
||||
JSONObject nextPoint = WQLObject
|
||||
@@ -83,8 +80,14 @@ public class CallTask extends AbstractAcsTask {
|
||||
}
|
||||
|
||||
// 判断叫的物料是否为点位的限定物料
|
||||
String nextPointMaterialType = nextPoint.getString("material_type");
|
||||
if (!StrUtil.equals(nextPointMaterialType, "14") && !StrUtil.equals(nextPointMaterialType, materialType)) {
|
||||
List<String> materialTypes = WQLObject
|
||||
.getWQLObject("sch_base_point_material")
|
||||
.query("point_id = " + nextPoint.getLong("point_id"))
|
||||
.getResultJSONArray(0)
|
||||
.stream()
|
||||
.map(o -> ((JSONObject) o).getString("material"))
|
||||
.collect(Collectors.toList());
|
||||
if (!materialTypes.contains(materialType)) {
|
||||
throw new BadRequestException("该点位不能呼叫这种物料");
|
||||
}
|
||||
|
||||
@@ -98,10 +101,7 @@ public class CallTask extends AbstractAcsTask {
|
||||
throw new BadRequestException("该点位不是空位");
|
||||
}
|
||||
|
||||
// 起点
|
||||
JSONObject startPoint = null;
|
||||
|
||||
// 查询该区域存放此物料的排
|
||||
// 查询叫料区域存放此物料的排
|
||||
JSONArray colArray = WQL
|
||||
.getWO("SEND_TASK")
|
||||
.addParam("flag", "2")
|
||||
@@ -111,9 +111,10 @@ public class CallTask extends AbstractAcsTask {
|
||||
.getResultJSONArray(0);
|
||||
|
||||
// 遍历该区域存放此物料的排寻找合适的点位
|
||||
JSONObject startPoint = null;
|
||||
for (Object o : colArray) {
|
||||
// 查找该排有货 或 已锁定的点位(出入库顺序降序)
|
||||
startPoint = WQL
|
||||
JSONObject tempPoint = WQL
|
||||
.getWO("SEND_TASK")
|
||||
.addParam("flag", "3")
|
||||
.addParam("region_id", startRegionId)
|
||||
@@ -122,19 +123,17 @@ public class CallTask extends AbstractAcsTask {
|
||||
.uniqueResult(0);
|
||||
|
||||
// 点位不为空 且 点位未锁定,则为合适的叫料点位
|
||||
if (ObjectUtil.isNotEmpty(startPoint) && StrUtil.equals(startPoint.getString("lock_type"), "00")) {
|
||||
if (ObjectUtil.isNotEmpty(tempPoint) && StrUtil.equals(tempPoint.getString("lock_type"), "00")) {
|
||||
startPoint = tempPoint;
|
||||
break;
|
||||
}
|
||||
|
||||
// 如果不合适重置为null
|
||||
startPoint = null;
|
||||
}
|
||||
if (ObjectUtil.isEmpty(startPoint)) {
|
||||
throw new BadRequestException("未找到合适的叫料点位");
|
||||
}
|
||||
|
||||
assert startPoint != null;
|
||||
return sendTask.createTaskRelated(
|
||||
return SpringContextHolder.getBean(SendTask.class).createTaskRelated(
|
||||
startPoint,
|
||||
nextPoint,
|
||||
param,
|
||||
@@ -151,7 +150,7 @@ public class CallTask extends AbstractAcsTask {
|
||||
*/
|
||||
@Override
|
||||
public void forceFinish(String task_id) {
|
||||
sendTask.forceFinish(task_id);
|
||||
SpringContextHolder.getBean(SendTask.class).forceFinish(task_id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -194,32 +194,16 @@ public class SendTask extends AbstractAcsTask {
|
||||
throw new BadRequestException("该点位是空位");
|
||||
}
|
||||
|
||||
// 如果起点是大吨位装配线下线区这根据物料类型给终点
|
||||
// 查送料点位(出入库顺序升序)
|
||||
JSONObject nextPoint;
|
||||
String startRegionId = startPoint.getString("region_id");
|
||||
String currentMaterialType = startPoint.getString("current_material_type");
|
||||
if (StrUtil.equals(startRegionId, "1578917189698850816") || StrUtil.equals(startRegionId, "1578917627470942208")) {
|
||||
String nextPointCode = null;
|
||||
if (StrUtil.equals(currentMaterialType, "08")) {
|
||||
nextPointCode = "TZSXDCP1";
|
||||
}
|
||||
if (StrUtil.equals(currentMaterialType, "09")) {
|
||||
nextPointCode = "TZSXDCP2";
|
||||
}
|
||||
nextPoint = WQLObject
|
||||
.getWQLObject("sch_base_point")
|
||||
.query("is_delete = '0' AND is_used = '1' AND point_code = '" + nextPointCode + "'")
|
||||
.uniqueResult(0);
|
||||
} else {
|
||||
// 查送料点位(出入库顺序升序)
|
||||
nextPoint = WQL
|
||||
.getWO("SEND_TASK")
|
||||
.addParam("flag", "1")
|
||||
.addParam("region_id", nextRegionId)
|
||||
.addParam("material_type", currentMaterialType)
|
||||
.process()
|
||||
.uniqueResult(0);
|
||||
}
|
||||
nextPoint = WQL
|
||||
.getWO("SEND_TASK")
|
||||
.addParam("flag", "1")
|
||||
.addParam("region_id", nextRegionId)
|
||||
.addParam("material_type", currentMaterialType)
|
||||
.process()
|
||||
.uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(nextPoint)) {
|
||||
throw new BadRequestException("未找到合适的送料点位");
|
||||
}
|
||||
|
||||
@@ -45,17 +45,18 @@
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sch_base_point
|
||||
sch_base_point point
|
||||
LEFT JOIN sch_base_point_material pm ON point.point_id = pm.point_id
|
||||
WHERE
|
||||
point_status = '00'
|
||||
AND lock_type = '00'
|
||||
AND is_delete = '0'
|
||||
AND is_used = '1'
|
||||
point.point_status = '00'
|
||||
AND point.lock_type = '00'
|
||||
AND point.is_delete = '0'
|
||||
AND point.is_used = '1'
|
||||
OPTION 输入.region_id <> ""
|
||||
region_id = 输入.region_id
|
||||
point.region_id = 输入.region_id
|
||||
ENDOPTION
|
||||
OPTION 输入.material_type <> ""
|
||||
material_type = 输入.material_type
|
||||
pm.material = 输入.material_type
|
||||
ENDOPTION
|
||||
ORDER BY
|
||||
seq ASC
|
||||
@@ -66,17 +67,18 @@
|
||||
IF 输入.flag = "2"
|
||||
QUERY
|
||||
SELECT DISTINCT
|
||||
col
|
||||
point.col
|
||||
FROM
|
||||
`sch_base_point`
|
||||
`sch_base_point` point
|
||||
LEFT JOIN sch_base_point_material pm ON point.point_id = pm.point_id
|
||||
WHERE
|
||||
is_delete = '0'
|
||||
AND is_used = '1'
|
||||
point.is_delete = '0'
|
||||
AND point.is_used = '1'
|
||||
OPTION 输入.region_id <> ""
|
||||
region_id = 输入.region_id
|
||||
point.region_id = 输入.region_id
|
||||
ENDOPTION
|
||||
OPTION 输入.material_type <> ""
|
||||
material_type = 输入.material_type
|
||||
pm.material = 输入.material_type
|
||||
ENDOPTION
|
||||
ORDER BY
|
||||
col
|
||||
|
||||
@@ -3,13 +3,16 @@ package org.nl;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.nl.utils.SecurityUtils;
|
||||
import org.nl.wms.sch.service.dto.PointDto;
|
||||
import org.nl.wql.core.bean.WQLObject;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@RunWith(SpringRunner.class)
|
||||
@@ -17,40 +20,48 @@ public class PointTest {
|
||||
|
||||
@Test
|
||||
public void test01() {
|
||||
for (int i = 0; i < 21; i++) {
|
||||
int nameSeq = i + 1;
|
||||
PointDto point = new PointDto();
|
||||
|
||||
point.setMaterial_type("10");
|
||||
if (nameSeq < 10) {
|
||||
point.setPoint_code("XCPM0" + nameSeq);
|
||||
} else {
|
||||
point.setPoint_code("XCPM" + nameSeq);
|
||||
WQLObject point_table = WQLObject.getWQLObject("sch_base_point");
|
||||
// JSONObject point = new JSONObject();
|
||||
// point.put("region_id", "1628275194667864064");
|
||||
// point.put("point_type", "00");
|
||||
// point.put("point_status", "00");
|
||||
// point.put("lock_type", "00");
|
||||
// point.put("is_used", "1");
|
||||
// point.put("is_delete", "0");
|
||||
// String now = DateUtil.now();
|
||||
// point.put("create_id", 1);
|
||||
// point.put("create_name", "管理员");
|
||||
// point.put("create_time", now);
|
||||
// point.put("update_optid", 1);
|
||||
// point.put("update_optname", "管理员");
|
||||
// point.put("update_time", now);
|
||||
// point.put("current_material_type", "14");
|
||||
//
|
||||
// int seq = 0;
|
||||
// for (int i = 1; i < 6; i++) {
|
||||
// for (int j = 1; j < 6; j++) {
|
||||
// point.put("point_id", IdUtil.createSnowflake(1L, 1L).nextId());
|
||||
// point.put("point_code", "HC" + i + "-0" + j + "-01");
|
||||
// point.put("point_name", "缓存周转区" + i + "排" + j + "列");
|
||||
// point.put("seq", ++seq);
|
||||
// point.put("col", i);
|
||||
// point.put("seq_num", ((i - 1) * 10) + j);
|
||||
// point_table.insert(point);
|
||||
// }
|
||||
// }
|
||||
JSONArray points = point_table
|
||||
.query("region_id = 1628275194667864064")
|
||||
.getResultJSONArray(0);
|
||||
WQLObject pm_table = WQLObject.getWQLObject("sch_base_point_material");
|
||||
JSONObject pm = new JSONObject();
|
||||
String[] materials = new String[]{"08", "09", "10", "11", "12", "13"};
|
||||
for (Object o : points) {
|
||||
pm.put("point_id", ((JSONObject) o).getLongValue("point_id"));
|
||||
for (String material : materials) {
|
||||
pm.put("pm_id", IdUtil.getSnowflake(1L, 1L).nextId());
|
||||
pm.put("material", material);
|
||||
pm_table.insert(pm);
|
||||
}
|
||||
point.setPoint_name("小吨位成品满框" + nameSeq + "号位");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
point.setRegion_id(1578915492142387200L);
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
point.setSeq((long) i);
|
||||
point.setPoint_status("00");
|
||||
point.setPoint_type("00");
|
||||
point.setLock_type("00");
|
||||
Long currentUserId = 1L;
|
||||
String nickName = "管理员";
|
||||
String now = DateUtil.now();
|
||||
point.setPoint_id(IdUtil.getSnowflake(1, 1).nextId());
|
||||
point.setCreate_id(currentUserId);
|
||||
point.setCreate_name(nickName);
|
||||
point.setUpdate_optid(currentUserId);
|
||||
point.setUpdate_optname(nickName);
|
||||
point.setUpdate_time(now);
|
||||
point.setCreate_time(now);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(point));
|
||||
wo.insert(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission">
|
||||
<el-button
|
||||
v-if="false"
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="info"
|
||||
@@ -178,13 +179,14 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="当前存放物料类型" prop="current_material_type">
|
||||
<el-form-item label="当前存放物料" prop="current_material_type">
|
||||
<el-select
|
||||
v-model="form.current_material_type"
|
||||
size="mini"
|
||||
placeholder="当前存放物料类型"
|
||||
placeholder="当前存放物料"
|
||||
class="filter-item"
|
||||
style="width: 370px;"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dict.current_material_type"
|
||||
@@ -197,7 +199,9 @@
|
||||
<el-form-item label="限定物料类型" prop="material_type">
|
||||
<el-select
|
||||
v-model="form.material_type"
|
||||
size="mini"
|
||||
multiple
|
||||
filterable
|
||||
size="medium"
|
||||
placeholder="限定物料类型"
|
||||
class="filter-item"
|
||||
style="width: 370px;"
|
||||
@@ -242,6 +246,7 @@
|
||||
v-model="form.prev_region_id"
|
||||
placeholder="请选择"
|
||||
style="width: 370px;"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="item in reginoList"
|
||||
@@ -256,6 +261,7 @@
|
||||
v-model="form.next_region_id"
|
||||
placeholder="请选择"
|
||||
style="width: 370px;"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="item in reginoList"
|
||||
@@ -289,16 +295,6 @@
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="point_code" label="点位编码" sortable width="90" />
|
||||
<el-table-column prop="point_name" label="点位名称" width="200" />
|
||||
<el-table-column v-if="false" prop="point_type_name" label="点位类型" />
|
||||
<el-table-column prop="point_status_name" label="点位状态" />
|
||||
<el-table-column prop="lock_type_name" label="锁定类型" />
|
||||
<el-table-column prop="current_material_type_name" label="当前存放物料类型" width="120" />
|
||||
<el-table-column prop="material_type_name" label="限定物料类型" width="120" />
|
||||
<el-table-column prop="col" label="排号" width="60" />
|
||||
<el-table-column prop="region_name" label="所属区域" width="190" />
|
||||
<el-table-column prop="prev_region_name" label="叫料区域" width="190" />
|
||||
<el-table-column prop="next_region_name" label="送料区域" width="190" />
|
||||
<el-table-column prop="seq" label="出入库顺序" width="90" />
|
||||
<el-table-column label="是否启用" align="center" prop="is_used">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
@@ -309,8 +305,18 @@
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="taskdtl_type" label="锁定任务类型" width="110" :formatter="taskdtl_typeFormat" />
|
||||
<el-table-column prop="task_code" label="锁定任务编码" width="100" />
|
||||
<el-table-column v-if="false" prop="point_type_name" label="点位类型" />
|
||||
<el-table-column prop="point_status_name" label="点位状态" />
|
||||
<el-table-column prop="lock_type_name" label="锁定类型" />
|
||||
<el-table-column prop="current_material_type_name" label="存放物料" width="120" />
|
||||
<el-table-column v-if="false" prop="material_type_name" label="限定物料类型" width="120" />
|
||||
<el-table-column prop="col" label="排号" width="60" />
|
||||
<el-table-column prop="region_name" label="所属区域" width="190" />
|
||||
<el-table-column prop="prev_region_name" label="叫料区域" width="190" />
|
||||
<el-table-column prop="next_region_name" label="送料区域" width="190" />
|
||||
<el-table-column prop="seq" label="出入库顺序" width="90" />
|
||||
<el-table-column v-if="false" prop="taskdtl_type" label="锁定任务类型" width="110" :formatter="taskdtl_typeFormat" />
|
||||
<el-table-column v-if="false" prop="task_code" label="锁定任务编码" width="100" />
|
||||
<el-table-column prop="update_optname" label="修改者" />
|
||||
<el-table-column prop="update_time" label="修改时间" width="150" />
|
||||
<el-table-column
|
||||
@@ -343,7 +349,7 @@ import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
// import checkoutbill from '@/api/wms/st/core/outbill/checkoutbill'
|
||||
|
||||
const defaultForm = { device_point_type: null, point_id: null, is_host: null, point_code: null, point_name: null, area_type: null, point_type: '00', point_status: '00', lock_type: '00', vehicle_code: null, source_id: null, remark: null, is_used: null, is_delete: null, create_id: null, create_name: null, create_time: null, update_optid: null, update_optname: null, update_time: null, material_type: '14', region_id: null, prev_region_id: null, next_region_id: null, seq: 0, current_material_type: '14', col: 0 }
|
||||
const defaultForm = { device_point_type: null, point_id: null, is_host: null, point_code: null, point_name: null, area_type: null, point_type: '00', point_status: '00', lock_type: '00', vehicle_code: null, source_id: null, remark: null, is_used: null, is_delete: null, create_id: null, create_name: null, create_time: null, update_optid: null, update_optname: null, update_time: null, material_type: [], region_id: null, prev_region_id: null, next_region_id: null, seq: 0, current_material_type: null, col: 1 }
|
||||
export default {
|
||||
name: 'Point',
|
||||
dicts: ['sch_point_type', 'sch_area_type', 'sch_point_status', 'is_used', 'd_lock_type', 'SCH_TASK_TYPE_DTL', 'storagevehicle_type', 'IS_HOST', 'device_point_type', 'material_type', 'current_material_type'],
|
||||
@@ -356,7 +362,7 @@ export default {
|
||||
idField: 'point_id',
|
||||
optShow: {
|
||||
add: true,
|
||||
edit: true,
|
||||
edit: false,
|
||||
del: true,
|
||||
download: false,
|
||||
reset: true
|
||||
@@ -395,15 +401,12 @@ export default {
|
||||
material_type: [
|
||||
{ required: true, message: '物料类型不能为空', trigger: 'blur' }
|
||||
],
|
||||
current_material_type: [
|
||||
{ required: true, message: '当前存放物料类型不能为空', trigger: 'blur' }
|
||||
],
|
||||
col: [
|
||||
{ required: true, message: '排号不能为空', trigger: 'blur' }
|
||||
],
|
||||
lock_type: [
|
||||
{ required: true, message: '锁定类型不能为空', trigger: 'blur' }
|
||||
]
|
||||
// lock_type: [
|
||||
// { required: true, message: '锁定类型不能为空', trigger: 'blur' }
|
||||
// ]
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user