55 changed files with 3736 additions and 594 deletions
@ -0,0 +1,49 @@ |
|||
package org.nl.acs.device_driver.basedriver.agv.xg_agv; |
|||
|
|||
import org.nl.acs.device_driver.DeviceDriver; |
|||
import org.nl.acs.device_driver.DeviceDriverDefinition; |
|||
import org.nl.acs.opc.Device; |
|||
import org.nl.acs.opc.DeviceType; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.LinkedList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 仙工AGV驱动 |
|||
*/ |
|||
@Service |
|||
public class XianGongAgvDefinition implements DeviceDriverDefinition { |
|||
@Override |
|||
public String getDriverCode() { |
|||
return "xg_agv"; |
|||
} |
|||
|
|||
@Override |
|||
public String getDriverName() { |
|||
return "标准版-仙工Agv"; |
|||
} |
|||
|
|||
@Override |
|||
public String getDriverDescription() { |
|||
return "标准版-仙工Agv"; |
|||
} |
|||
|
|||
@Override |
|||
public DeviceDriver getDriverInstance(Device device) { |
|||
return (new XianGongAgvDeviceDriver()).setDevice(device).setDriverDefinition(this); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public Class<? extends DeviceDriver> getDeviceDriverType() { |
|||
return XianGongAgvDeviceDriver.class; |
|||
} |
|||
|
|||
@Override |
|||
public List<DeviceType> getFitDeviceTypes() { |
|||
List<DeviceType> types = new LinkedList(); |
|||
types.add(DeviceType.agv); |
|||
return types; |
|||
} |
|||
} |
@ -0,0 +1,139 @@ |
|||
package org.nl.acs.device_driver.basedriver.agv.xg_agv; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.Data; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
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.monitor.DeviceStageMonitor; |
|||
import org.nl.acs.opc.Device; |
|||
import org.nl.modules.wql.util.SpringContextHolder; |
|||
|
|||
/** |
|||
* 仙工AGV |
|||
*/ |
|||
@Slf4j |
|||
@Data |
|||
@RequiredArgsConstructor |
|||
public class XianGongAgvDeviceDriver extends AbstractOpcDeviceDriver implements |
|||
DeviceDriver, |
|||
ExecutableDeviceDriver, |
|||
RouteableDeviceDriver, |
|||
DeviceStageMonitor { |
|||
|
|||
private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); |
|||
|
|||
/** |
|||
* 当前设备号 |
|||
*/ |
|||
private String currentDeviceCode; |
|||
|
|||
/** |
|||
* 当前执行任务号 |
|||
*/ |
|||
private String taskCode = "0"; |
|||
|
|||
/** |
|||
* 电量 |
|||
*/ |
|||
private Double battery_level = 0.0d; |
|||
|
|||
/** |
|||
* 角度 |
|||
*/ |
|||
private Double angle = 0.0d; |
|||
|
|||
/** |
|||
* 当前机器人X坐标 |
|||
*/ |
|||
private Double x = 0.0d; |
|||
|
|||
/** |
|||
* 当前机器人Y坐标 |
|||
*/ |
|||
private Double y = 0.0d; |
|||
|
|||
/** |
|||
* 当前开机时间 ms |
|||
*/ |
|||
private Integer time = 0; |
|||
|
|||
/** |
|||
* 累计运行时间 ms |
|||
*/ |
|||
private Integer total_time = 0; |
|||
|
|||
/** |
|||
* 今日累计行驶里程, 单位 m |
|||
*/ |
|||
private Double today_odo = 0.0d; |
|||
|
|||
/** |
|||
* 累计行驶里程 |
|||
*/ |
|||
private Integer odo = 0; |
|||
|
|||
/** |
|||
* AGV当前状态码 |
|||
*/ |
|||
private Integer status = 0; |
|||
|
|||
/** |
|||
* AGV当前状态对应名称 |
|||
*/ |
|||
private String statusName = this.status == 1 ? "工作中" : this.status == 2 ? "充电中" : this.status == 3 ? "故障" : this.status == 4 ? "休息中" : this.status == 5 ? "关机" : "未知状态"; |
|||
|
|||
/** |
|||
* 当天执行任务数量 |
|||
*/ |
|||
private Integer todayTaskNum = 0; |
|||
|
|||
/** |
|||
* 近一个月执行任务数量 |
|||
*/ |
|||
private Integer monthTaskNum = 0; |
|||
|
|||
@Override |
|||
public Device getDevice() { |
|||
return this.device; |
|||
} |
|||
|
|||
@Override |
|||
public void execute() throws Exception { |
|||
this.currentDeviceCode = this.getDeviceCode(); |
|||
this.todayTaskNum = instructionService.findTodayTaskNumByAgvCar(this.currentDeviceCode); |
|||
this.monthTaskNum = instructionService.findMonthTaskNumByAgvCar(this.currentDeviceCode); |
|||
Thread.sleep(5000); |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public JSONObject getDeviceStatusName() { |
|||
JSONObject jo = new JSONObject(); |
|||
jo.put("device_code", this.currentDeviceCode); |
|||
jo.put("device_name", this.currentDeviceCode); |
|||
jo.put("task_code", this.taskCode); |
|||
jo.put("battery_level", (this.battery_level * 100) + "%"); |
|||
jo.put("angle", this.angle); |
|||
jo.put("time", this.time / 1000 / 1.0 / 3600); |
|||
jo.put("total_time", this.total_time / 1000 / 1.0 / 3600); |
|||
jo.put("today_odo", this.today_odo); |
|||
jo.put("odo", this.odo); |
|||
jo.put("x", this.x); |
|||
jo.put("y", this.y); |
|||
jo.put("status", this.statusName); |
|||
//jo.put("status_name", this.statusName);
|
|||
jo.put("todayTaskNum", this.todayTaskNum); |
|||
jo.put("monthTaskNum", this.monthTaskNum); |
|||
return jo; |
|||
} |
|||
|
|||
@Override |
|||
public void setDeviceStatus(JSONObject data) { |
|||
|
|||
} |
|||
} |
@ -0,0 +1,133 @@ |
|||
package org.nl.acs.device_driver.rgv; |
|||
|
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
import org.nl.acs.device_driver.shangdianke.PhotoelectricDetectionDeviceDriver; |
|||
|
|||
|
|||
@Getter |
|||
@Setter |
|||
public class ItemProtocol { |
|||
|
|||
|
|||
public static final String ITEM_HEARTBEAT = "heartbeat"; |
|||
public static final String ITEM_MODE = "mode"; |
|||
public static final String ITEM_STATUS = "status"; |
|||
public static final String ITEM_ERROR = "error"; |
|||
public static final String ITEM_ENERGY_LEVEL = "energyLevel"; |
|||
public static final String ITEM_TASK_CODE = "taskCode"; |
|||
public static final String ITEM_START_DEVICE_CODE = "startDeviceCode"; |
|||
public static final String ITEM_NEXT_DEVICE_CODE = "nextDeviceCode"; |
|||
public static final String ITEM_VEHICLE_CODE = "vehicleCode"; |
|||
public static final String ITEM_X = "x"; |
|||
public static final String ITEM_Y = "y"; |
|||
public static final String ITEM_ACTION = "action"; |
|||
public static final String ITEM_TODAY_TASK_NUM = "todayTaskNum"; |
|||
public static final String ITEM_ALL_TASK_NUM = "allTaskNum"; |
|||
|
|||
|
|||
boolean isOnline; |
|||
|
|||
|
|||
private final RGVDeviceDriver driver; |
|||
|
|||
|
|||
public ItemProtocol(RGVDeviceDriver driver) { |
|||
this.driver = driver; |
|||
} |
|||
|
|||
|
|||
public int getOpcIntegerValue(String protocol) { |
|||
Integer value = this.driver.getIntegeregerValue(protocol); |
|||
if (value == null) { |
|||
this.isOnline = false; |
|||
return 0; |
|||
} else { |
|||
this.isOnline = true; |
|||
return value; |
|||
} |
|||
} |
|||
|
|||
public Double getOpcDoubleValue(String protocol) { |
|||
Double value = this.driver.getDoubleValue(protocol); |
|||
if (value == null) { |
|||
this.isOnline = false; |
|||
return 0.0d; |
|||
} else { |
|||
this.isOnline = true; |
|||
return value; |
|||
} |
|||
} |
|||
|
|||
public String getOpcStringValue(String protocol) { |
|||
String value = this.driver.getStringValue(protocol); |
|||
if (value == null) { |
|||
this.isOnline = false; |
|||
return ""; |
|||
} else { |
|||
this.isOnline = true; |
|||
return value; |
|||
} |
|||
} |
|||
|
|||
|
|||
public int getHeartbeat() { |
|||
return this.getOpcIntegerValue(ItemProtocol.ITEM_HEARTBEAT); |
|||
} |
|||
|
|||
|
|||
public int getMode() { |
|||
return this.getOpcIntegerValue(ItemProtocol.ITEM_MODE); |
|||
} |
|||
|
|||
|
|||
public int getStatus() { |
|||
return this.getOpcIntegerValue(ItemProtocol.ITEM_STATUS); |
|||
} |
|||
|
|||
|
|||
public int getError() { |
|||
return this.getOpcIntegerValue(ItemProtocol.ITEM_ERROR); |
|||
} |
|||
|
|||
|
|||
public Double getEnergyLevel() { |
|||
return this.getOpcDoubleValue(ItemProtocol.ITEM_ENERGY_LEVEL); |
|||
} |
|||
|
|||
public int getTaskCode() { |
|||
return this.getOpcIntegerValue(ItemProtocol.ITEM_TASK_CODE); |
|||
} |
|||
|
|||
public String getStartDeviceCode() { |
|||
return this.getOpcStringValue(ItemProtocol.ITEM_START_DEVICE_CODE); |
|||
} |
|||
|
|||
public String getNextDeviceCode() { |
|||
return this.getOpcStringValue(ItemProtocol.ITEM_NEXT_DEVICE_CODE); |
|||
} |
|||
|
|||
public String getVehicleCode() { |
|||
return this.getOpcStringValue(ItemProtocol.ITEM_VEHICLE_CODE); |
|||
} |
|||
|
|||
public Double getX() { |
|||
return this.getOpcDoubleValue(ItemProtocol.ITEM_X); |
|||
} |
|||
|
|||
public Double getY() { |
|||
return this.getOpcDoubleValue(ItemProtocol.ITEM_Y); |
|||
} |
|||
|
|||
public int getAction() { |
|||
return this.getOpcIntegerValue(ItemProtocol.ITEM_ACTION); |
|||
} |
|||
|
|||
public int getTodayTaskNum() { |
|||
return this.getOpcIntegerValue(ItemProtocol.ITEM_TODAY_TASK_NUM); |
|||
} |
|||
|
|||
public int getAllTaskNum() { |
|||
return this.getOpcIntegerValue(ItemProtocol.ITEM_ALL_TASK_NUM); |
|||
} |
|||
} |
@ -0,0 +1,243 @@ |
|||
package org.nl.acs.device_driver.rgv; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.Getter; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.Setter; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.acs.device_driver.*; |
|||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; |
|||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; |
|||
import org.nl.acs.monitor.DeviceStageMonitor; |
|||
import org.nl.modules.lucene.service.LuceneExecuteLogService; |
|||
import org.nl.modules.lucene.service.dto.LuceneLogDto; |
|||
import org.nl.modules.wql.util.SpringContextHolder; |
|||
|
|||
/** |
|||
* @author zhangjiangwei |
|||
*/ |
|||
@Slf4j |
|||
@Getter |
|||
@Setter |
|||
@RequiredArgsConstructor |
|||
public class RGVDeviceDriver extends AbstractOpcDeviceDriver implements |
|||
DeviceDriver, |
|||
ExecutableDeviceDriver, |
|||
RouteableDeviceDriver, |
|||
DeviceStageMonitor, |
|||
StandardRequestMethod, |
|||
HeartbeatableDeviceDriver { |
|||
|
|||
private final ItemProtocol itemProtocol = new ItemProtocol(this); |
|||
|
|||
private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class); |
|||
|
|||
/** |
|||
* 心跳 |
|||
*/ |
|||
private int heartbeat = 0; |
|||
private int lastHeartbeat = 0; |
|||
|
|||
/** |
|||
* 工作模式 |
|||
*/ |
|||
private int mode = 0; |
|||
private int lastMode = 0; |
|||
|
|||
/** |
|||
* 工作状态 |
|||
*/ |
|||
private int status = 0; |
|||
private int lastStatus = 0; |
|||
|
|||
/** |
|||
* 报警信息 |
|||
*/ |
|||
private int error = 0; |
|||
private int lastError = 0; |
|||
|
|||
/** |
|||
* 当前电量 |
|||
*/ |
|||
private Double energyLevel = 0.0d; |
|||
private Double lastEnergyLevel = 0.0d; |
|||
|
|||
/** |
|||
* 任务号 |
|||
*/ |
|||
private int taskCode = 0; |
|||
private int lastTaskCode = 0; |
|||
|
|||
/** |
|||
* 起点 |
|||
*/ |
|||
private String startDeviceCode; |
|||
private String lastStartDeviceCode; |
|||
|
|||
/** |
|||
* 终点 |
|||
*/ |
|||
private String nextDeviceCode; |
|||
private String lastNextDeviceCode; |
|||
|
|||
/** |
|||
* 载具号 |
|||
*/ |
|||
private String vehicleCode; |
|||
private String lastVehicleCode; |
|||
|
|||
/** |
|||
* x坐标 |
|||
*/ |
|||
private Double x; |
|||
private Double lastX; |
|||
|
|||
/** |
|||
* y坐标 |
|||
*/ |
|||
private Double y; |
|||
private Double lastY; |
|||
|
|||
/** |
|||
* 当前动作 |
|||
*/ |
|||
private int action = 0; |
|||
private int lastAction = 0; |
|||
|
|||
/** |
|||
* 当天执行任务数 |
|||
*/ |
|||
private int todayTaskNum = 0; |
|||
private int lastTodayTaskNum = 0; |
|||
|
|||
/** |
|||
* 历史执行任务数 |
|||
*/ |
|||
private int allTaskNum = 0; |
|||
private int lastAllTaskNum = 0; |
|||
|
|||
/** |
|||
* 当前设备号 |
|||
*/ |
|||
private String currentDeviceCode; |
|||
|
|||
/** |
|||
* 消息 |
|||
*/ |
|||
private String message = ""; |
|||
|
|||
/** |
|||
* 请求标记相关信息 |
|||
*/ |
|||
private boolean requireSuccess = false; |
|||
private long requireTime = System.currentTimeMillis(); |
|||
private long requireTimeOut = 5000L; |
|||
|
|||
/** |
|||
* 设备异常标记 |
|||
*/ |
|||
private boolean isError = false; |
|||
|
|||
|
|||
@Override |
|||
public void execute() throws Exception { |
|||
this.currentDeviceCode = this.getDevice().getDevice_code(); |
|||
this.heartbeat = this.itemProtocol.getHeartbeat(); |
|||
this.mode = this.itemProtocol.getMode(); |
|||
this.status = this.itemProtocol.getStatus(); |
|||
this.error = this.itemProtocol.getError(); |
|||
this.energyLevel = this.itemProtocol.getEnergyLevel(); |
|||
this.taskCode = this.itemProtocol.getTaskCode(); |
|||
this.startDeviceCode = this.itemProtocol.getStartDeviceCode(); |
|||
this.nextDeviceCode = this.itemProtocol.getNextDeviceCode(); |
|||
this.vehicleCode = this.itemProtocol.getVehicleCode(); |
|||
this.x = this.itemProtocol.getX(); |
|||
this.y = this.itemProtocol.getY(); |
|||
this.action = this.itemProtocol.getAction(); |
|||
this.todayTaskNum = this.itemProtocol.getTodayTaskNum(); |
|||
this.allTaskNum = this.itemProtocol.getAllTaskNum(); |
|||
|
|||
if (this.mode != this.lastMode) { |
|||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "信号mode发生变化 " + this.lastMode + "->" + this.mode)); |
|||
} |
|||
if (this.status != this.lastStatus) { |
|||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "信号status发生变化 " + this.lastStatus + "->" + this.status)); |
|||
} |
|||
if (this.error != this.lastError) { |
|||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "信号error发生变化 " + this.lastError + "->" + this.error)); |
|||
} |
|||
if (!this.energyLevel.equals(this.lastEnergyLevel)) { |
|||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "信号energyLevel发生变化 " + this.lastEnergyLevel + "->" + this.energyLevel)); |
|||
} |
|||
if (this.taskCode != this.lastTaskCode) { |
|||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "信号taskCode发生变化 " + this.lastTaskCode + "->" + this.taskCode)); |
|||
} |
|||
if (!this.startDeviceCode.equals(this.lastStartDeviceCode)) { |
|||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "信号startDeviceCode发生变化 " + this.lastStartDeviceCode + "->" + this.startDeviceCode)); |
|||
} |
|||
if (!this.nextDeviceCode.equals(this.lastNextDeviceCode)) { |
|||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "信号nextDeviceCode发生变化 " + this.lastNextDeviceCode + "->" + this.nextDeviceCode)); |
|||
} |
|||
if (!this.vehicleCode.equals(this.lastVehicleCode)) { |
|||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "信号vehicleCode发生变化 " + this.lastVehicleCode + "->" + this.vehicleCode)); |
|||
} |
|||
if (!this.x.equals(this.lastX)) { |
|||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "信号x发生变化 " + this.lastX + "->" + this.x)); |
|||
} |
|||
if (!this.y.equals(this.lastY)) { |
|||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "信号y发生变化 " + this.lastY + "->" + this.y)); |
|||
} |
|||
if (this.action != this.lastAction) { |
|||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "信号action发生变化 " + this.lastAction + "->" + this.action)); |
|||
} |
|||
if (this.todayTaskNum != this.lastTodayTaskNum) { |
|||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "信号todayTaskNum发生变化 " + this.lastTodayTaskNum + "->" + this.todayTaskNum)); |
|||
} |
|||
if (this.allTaskNum != this.lastAllTaskNum) { |
|||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "信号allTaskNum发生变化 " + this.lastAllTaskNum + "->" + this.allTaskNum)); |
|||
} |
|||
|
|||
this.lastMode = this.mode; |
|||
this.lastStatus = this.status; |
|||
this.lastError = this.error; |
|||
this.lastEnergyLevel = this.energyLevel; |
|||
this.lastTaskCode = this.taskCode; |
|||
this.lastStartDeviceCode = this.startDeviceCode; |
|||
this.lastNextDeviceCode = this.nextDeviceCode; |
|||
this.lastVehicleCode = this.vehicleCode; |
|||
this.lastX = this.x; |
|||
this.lastY = this.y; |
|||
this.lastAction = this.action; |
|||
this.lastTodayTaskNum = this.todayTaskNum; |
|||
this.lastAllTaskNum = this.allTaskNum; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public JSONObject getDeviceStatusName() throws Exception { |
|||
JSONObject jo = new JSONObject(); |
|||
jo.put("device_code", this.currentDeviceCode); |
|||
jo.put("device_name", this.currentDeviceCode); |
|||
jo.put("heartbeat", this.heartbeat); |
|||
jo.put("mode", this.mode == 1 ? "手动" : this.mode == 2 ? "自动" : "未知"); |
|||
jo.put("status", this.error > 0 ? "故障" : this.status == 0 ? "休息中" : this.status == 1 ? "工作中" : this.status == 2 ? "充电中" : "未知状态"); |
|||
jo.put("error", this.error); |
|||
jo.put("battery_level", (this.energyLevel * 100) + "%"); |
|||
jo.put("task_code", this.taskCode); |
|||
jo.put("startDeviceCode", this.startDeviceCode); |
|||
jo.put("nextDeviceCode", this.nextDeviceCode); |
|||
jo.put("vehicleCode", this.vehicleCode); |
|||
jo.put("x", this.x); |
|||
jo.put("y", this.y); |
|||
jo.put("action", this.action); |
|||
jo.put("todayTaskNum", this.todayTaskNum); |
|||
jo.put("allTaskNum", this.allTaskNum); |
|||
return jo; |
|||
} |
|||
|
|||
@Override |
|||
public void setDeviceStatus(JSONObject data) { |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,77 @@ |
|||
package org.nl.acs.device_driver.rgv; |
|||
|
|||
import org.nl.acs.device.device_driver.standard_inspect.ItemDTO; |
|||
import org.nl.acs.device_driver.DeviceDriver; |
|||
import org.nl.acs.device_driver.definition.OpcDeviceDriverDefinition; |
|||
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; |
|||
|
|||
/** |
|||
* @author zhangjiangwei |
|||
*/ |
|||
@Service |
|||
public class RGVStationDefinition implements OpcDeviceDriverDefinition { |
|||
|
|||
@Override |
|||
public String getDriverCode() { |
|||
return "rgv_station"; |
|||
} |
|||
|
|||
@Override |
|||
public String getDriverName() { |
|||
return "RGV"; |
|||
} |
|||
|
|||
@Override |
|||
public String getDriverDescription() { |
|||
return "RGV"; |
|||
} |
|||
|
|||
@Override |
|||
public DeviceDriver getDriverInstance(Device device) { |
|||
return new RGVDeviceDriver().setDevice(device).setDriverDefinition(this); |
|||
} |
|||
|
|||
@Override |
|||
public Class<? extends DeviceDriver> getDeviceDriverType() { |
|||
return RGVDeviceDriver.class; |
|||
} |
|||
|
|||
@Override |
|||
public List<DeviceType> getFitDeviceTypes() { |
|||
List<DeviceType> types = new LinkedList<>(); |
|||
types.add(DeviceType.rgv); |
|||
return types; |
|||
} |
|||
|
|||
@Override |
|||
public List<ItemDTO> getReadableItemDTOs() { |
|||
ArrayList<ItemDTO> itemDTOs = new ArrayList<>(); |
|||
itemDTOs.add(new ItemDTO(ItemProtocol.ITEM_HEARTBEAT, "心跳", "DB1101.B1")); |
|||
itemDTOs.add(new ItemDTO(ItemProtocol.ITEM_MODE, "工作模式", "DB1101.B2")); |
|||
itemDTOs.add(new ItemDTO(ItemProtocol.ITEM_STATUS, "工作状态", "DB1101.B3")); |
|||
itemDTOs.add(new ItemDTO(ItemProtocol.ITEM_ERROR, "报警信息", "DB1101.B4")); |
|||
itemDTOs.add(new ItemDTO(ItemProtocol.ITEM_ENERGY_LEVEL, "当前电量", "DB1101.D5")); |
|||
itemDTOs.add(new ItemDTO(ItemProtocol.ITEM_TASK_CODE, "当前执行任务号", "DB1101.D6")); |
|||
itemDTOs.add(new ItemDTO(ItemProtocol.ITEM_START_DEVICE_CODE, "任务起点", "DB1101.S7")); |
|||
itemDTOs.add(new ItemDTO(ItemProtocol.ITEM_NEXT_DEVICE_CODE, "任务终点", "DB1101.S8")); |
|||
itemDTOs.add(new ItemDTO(ItemProtocol.ITEM_VEHICLE_CODE, "载具号", "DB1101.S9")); |
|||
itemDTOs.add(new ItemDTO(ItemProtocol.ITEM_X, "x坐标", "DB1101.D10")); |
|||
itemDTOs.add(new ItemDTO(ItemProtocol.ITEM_Y, "y坐标", "DB1101.D11")); |
|||
itemDTOs.add(new ItemDTO(ItemProtocol.ITEM_ACTION, "当前动作", "DB1101.B12")); |
|||
itemDTOs.add(new ItemDTO(ItemProtocol.ITEM_TODAY_TASK_NUM, "当天执行任务数", "DB1101.D13")); |
|||
itemDTOs.add(new ItemDTO(ItemProtocol.ITEM_ALL_TASK_NUM, "历史执行任务数", "DB1101.D14")); |
|||
return itemDTOs; |
|||
} |
|||
|
|||
@Override |
|||
public List<ItemDTO> getWriteableItemDTOs() { |
|||
ArrayList<ItemDTO> itemDTOs = new ArrayList<>(); |
|||
return itemDTOs; |
|||
} |
|||
} |
@ -0,0 +1,10 @@ |
|||
package org.nl.acs.ext; |
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/4/22 |
|||
*/ |
|||
public interface RequestAdapter { |
|||
String getUrl(); |
|||
} |
@ -0,0 +1,12 @@ |
|||
package org.nl.acs.ext; |
|||
|
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/4/22 |
|||
*/ |
|||
public interface ResponseAdapter { |
|||
public <T> UnifiedResponse<T> adapt(String responseBody, Class<T> type); |
|||
} |
|||
|
@ -0,0 +1,37 @@ |
|||
package org.nl.acs.ext; |
|||
|
|||
|
|||
public class UnifiedResponse<T> { |
|||
private boolean success; |
|||
private String message; |
|||
private T data; |
|||
|
|||
public UnifiedResponse(boolean success, String message, T data) { |
|||
this.success = success; |
|||
this.message = message; |
|||
this.data = data; |
|||
} |
|||
|
|||
|
|||
public UnifiedResponse(boolean success, String message) { |
|||
this.success = success; |
|||
this.message = message; |
|||
} |
|||
|
|||
public boolean isSuccess() { |
|||
return this.success; |
|||
} |
|||
|
|||
public String getMessage() { |
|||
return this.message; |
|||
} |
|||
|
|||
public T getData() { |
|||
return this.data; |
|||
} |
|||
|
|||
public void setData(T data) { |
|||
this.data = data; |
|||
} |
|||
} |
|||
|
@ -0,0 +1,93 @@ |
|||
package org.nl.acs.ext.log; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import org.aspectj.lang.ProceedingJoinPoint; |
|||
import org.aspectj.lang.annotation.Around; |
|||
import org.aspectj.lang.annotation.Aspect; |
|||
import org.aspectj.lang.reflect.MethodSignature; |
|||
import org.nl.acs.ext.wms.IpUtil; |
|||
import org.nl.modules.lucene.service.LuceneExecuteLogService; |
|||
import org.nl.modules.lucene.service.dto.LuceneLogDto; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.lang.reflect.Method; |
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/7/8 |
|||
*/ |
|||
@Aspect |
|||
@Component |
|||
public class OtherToInterfaceLogAspect { |
|||
|
|||
@Autowired |
|||
private LuceneExecuteLogService logService; |
|||
|
|||
@Around("@annotation(org.nl.acs.ext.log.OthersToInterfaceLog)") |
|||
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable { |
|||
long startTime = System.currentTimeMillis(); |
|||
|
|||
MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
|||
Method method = signature.getMethod(); |
|||
|
|||
Class<?> targetClass = joinPoint.getTarget().getClass(); |
|||
RequestMapping classRequestMapping = targetClass.getAnnotation(RequestMapping.class); |
|||
String classUrlValue = classRequestMapping != null ? String.join(",", classRequestMapping.value()) : "No Class Annotation"; |
|||
|
|||
String methodUrlValue = ""; |
|||
if (method.isAnnotationPresent(GetMapping.class)) { |
|||
GetMapping getMapping = method.getAnnotation(GetMapping.class); |
|||
methodUrlValue = String.join(",", getMapping.value()); |
|||
} else if (method.isAnnotationPresent(PostMapping.class)) { |
|||
PostMapping postMapping = method.getAnnotation(PostMapping.class); |
|||
methodUrlValue = String.join(",", postMapping.value()); |
|||
} else if (method.isAnnotationPresent(PutMapping.class)) { |
|||
PutMapping putMapping = method.getAnnotation(PutMapping.class); |
|||
methodUrlValue = String.join(",", putMapping.value()); |
|||
} else if (method.isAnnotationPresent(DeleteMapping.class)) { |
|||
DeleteMapping deleteMapping = method.getAnnotation(DeleteMapping.class); |
|||
methodUrlValue = String.join(",", deleteMapping.value()); |
|||
} else if (method.isAnnotationPresent(RequestMapping.class)) { |
|||
RequestMapping methodRequestMapping = method.getAnnotation(RequestMapping.class); |
|||
methodUrlValue = String.join(",", methodRequestMapping.value()); |
|||
} |
|||
String request_direction = ""; |
|||
if (method.isAnnotationPresent(OthersToInterfaceLog.class)) { |
|||
OthersToInterfaceLog interfaceLog = method.getAnnotation(OthersToInterfaceLog.class); |
|||
request_direction = interfaceLog.value(); |
|||
} |
|||
|
|||
String methodName = joinPoint.getSignature().getName(); |
|||
Object[] args = joinPoint.getArgs(); |
|||
|
|||
LuceneLogDto logDto = |
|||
LuceneLogDto.builder() |
|||
.logType("接口日志") |
|||
.request_url(IpUtil.localIP() + classUrlValue + methodUrlValue) |
|||
.request_direction(request_direction) |
|||
.request_param(JSON.toJSONString(args)) |
|||
.method(methodName) |
|||
.content("开始请求") |
|||
.build(); |
|||
logService.interfaceExecuteLog(logDto); |
|||
|
|||
Object result = joinPoint.proceed(); |
|||
|
|||
logDto = |
|||
LuceneLogDto.builder() |
|||
.logType("接口日志") |
|||
.request_url(IpUtil.localIP() + classUrlValue + methodUrlValue) |
|||
.request_direction(request_direction) |
|||
.request_param(JSON.toJSONString(args)) |
|||
.method(methodName) |
|||
.response_param(JSON.toJSONString(result)) |
|||
.executeTime(System.currentTimeMillis() - startTime) |
|||
.content("响应请求") |
|||
.build(); |
|||
logService.interfaceExecuteLog(logDto); |
|||
return result; |
|||
} |
|||
} |
@ -0,0 +1,12 @@ |
|||
package org.nl.acs.ext.log; |
|||
|
|||
import java.lang.annotation.ElementType; |
|||
import java.lang.annotation.Retention; |
|||
import java.lang.annotation.RetentionPolicy; |
|||
import java.lang.annotation.Target; |
|||
|
|||
@Target(ElementType.METHOD) |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
public @interface OthersToInterfaceLog { |
|||
String value() default ""; |
|||
} |
@ -0,0 +1,123 @@ |
|||
package org.nl.acs.ext.log; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import org.aspectj.lang.ProceedingJoinPoint; |
|||
import org.aspectj.lang.annotation.Around; |
|||
import org.aspectj.lang.annotation.Aspect; |
|||
import org.aspectj.lang.reflect.MethodSignature; |
|||
import org.nl.modules.lucene.service.LuceneExecuteLogService; |
|||
import org.nl.modules.lucene.service.dto.LuceneLogDto; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.util.ReflectionUtils; |
|||
|
|||
import java.lang.reflect.Field; |
|||
import java.lang.reflect.Method; |
|||
import java.util.concurrent.ConcurrentHashMap; |
|||
import java.util.concurrent.ConcurrentMap; |
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/7/8 |
|||
*/ |
|||
@Aspect |
|||
@Component |
|||
public class ToOtherInterfaceLogAspect { |
|||
|
|||
private static final ConcurrentMap<Class<?>, Field> fieldCache = new ConcurrentHashMap<>(); |
|||
private static final ConcurrentMap<Class<?>, Method> methodCache = new ConcurrentHashMap<>(); |
|||
|
|||
@Autowired |
|||
private LuceneExecuteLogService logService; |
|||
|
|||
@Around("@annotation(org.nl.acs.ext.log.ToOthersInterfaceLog)") |
|||
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable { |
|||
long startTime = System.currentTimeMillis(); |
|||
|
|||
MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
|||
Method method = signature.getMethod(); |
|||
|
|||
|
|||
String request_direction = ""; |
|||
if (method.isAnnotationPresent(ToOthersInterfaceLog.class)) { |
|||
ToOthersInterfaceLog interfaceLog = method.getAnnotation(ToOthersInterfaceLog.class); |
|||
request_direction = interfaceLog.value(); |
|||
} |
|||
String methodName = joinPoint.getSignature().getName(); |
|||
Object[] args = joinPoint.getArgs(); |
|||
Object url = ""; |
|||
Object requesr_param = ""; |
|||
if (args.length > 1) { |
|||
url = args[0]; |
|||
requesr_param = args[1]; |
|||
} |
|||
|
|||
Class<?> targetClass = joinPoint.getTarget().getClass(); |
|||
|
|||
Object ipPort = ""; |
|||
try { |
|||
Field requestAdapterField = fieldCache.computeIfAbsent(targetClass, clazz -> { |
|||
try { |
|||
Field field = clazz.getDeclaredField("REQUEST_ADAPTER"); |
|||
ReflectionUtils.makeAccessible(field); |
|||
return field; |
|||
} catch (NoSuchFieldException e) { |
|||
throw new RuntimeException(e); |
|||
} |
|||
}); |
|||
|
|||
Object requestAdapterObject = requestAdapterField.get(null); |
|||
|
|||
Method getUrlMethod = methodCache.computeIfAbsent(requestAdapterObject.getClass(), clazz -> { |
|||
try { |
|||
Method m = clazz.getDeclaredMethod("getUrl"); |
|||
ReflectionUtils.makeAccessible(m); |
|||
return m; |
|||
} catch (NoSuchMethodException e) { |
|||
throw new RuntimeException(e); |
|||
} |
|||
}); |
|||
|
|||
ipPort = getUrlMethod.invoke(requestAdapterObject); |
|||
} catch (Exception e) { |
|||
LuceneLogDto logDto = |
|||
LuceneLogDto.builder() |
|||
.logType("接口日志") |
|||
.request_url(ipPort + String.valueOf(url)) |
|||
.request_direction(request_direction) |
|||
.request_param(JSON.toJSONString(requesr_param)) |
|||
.method(methodName) |
|||
.content("开始请求,获取url失败," + e.getMessage()) |
|||
.build(); |
|||
logService.interfaceExecuteLog(logDto); |
|||
} |
|||
|
|||
LuceneLogDto logDto = |
|||
LuceneLogDto.builder() |
|||
.logType("接口日志") |
|||
.request_url(ipPort + String.valueOf(url)) |
|||
.request_direction(request_direction) |
|||
.request_param(JSON.toJSONString(requesr_param)) |
|||
.method(methodName) |
|||
.content("开始请求") |
|||
.build(); |
|||
logService.interfaceExecuteLog(logDto); |
|||
|
|||
Object result = joinPoint.proceed(); |
|||
|
|||
logDto = |
|||
LuceneLogDto.builder() |
|||
.logType("接口日志") |
|||
.request_url(ipPort + String.valueOf(url)) |
|||
.request_direction(request_direction) |
|||
.request_param(JSON.toJSONString(requesr_param)) |
|||
.method(methodName) |
|||
.response_param(JSON.toJSONString(result)) |
|||
.executeTime(System.currentTimeMillis() - startTime) |
|||
.content("响应请求") |
|||
.build(); |
|||
logService.interfaceExecuteLog(logDto); |
|||
return result; |
|||
} |
|||
} |
@ -0,0 +1,12 @@ |
|||
package org.nl.acs.ext.log; |
|||
|
|||
import java.lang.annotation.ElementType; |
|||
import java.lang.annotation.Retention; |
|||
import java.lang.annotation.RetentionPolicy; |
|||
import java.lang.annotation.Target; |
|||
|
|||
@Target(ElementType.METHOD) |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
public @interface ToOthersInterfaceLog { |
|||
String value() default ""; |
|||
} |
@ -0,0 +1,35 @@ |
|||
package org.nl.acs.ext.wms; |
|||
|
|||
import java.net.InetAddress; |
|||
import java.net.NetworkInterface; |
|||
import java.net.SocketException; |
|||
import java.util.Enumeration; |
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/6/25 |
|||
*/ |
|||
public class IpUtil { |
|||
|
|||
public static final String LOCAL_IP = localIP(); |
|||
|
|||
public static String localIP() { |
|||
try { |
|||
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); |
|||
while (networkInterfaces.hasMoreElements()) { |
|||
NetworkInterface networkInterface = networkInterfaces.nextElement(); |
|||
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses(); |
|||
while (inetAddresses.hasMoreElements()) { |
|||
InetAddress inetAddress = inetAddresses.nextElement(); |
|||
if (!inetAddress.isLoopbackAddress() && inetAddress instanceof java.net.Inet4Address) { |
|||
return inetAddress.getHostAddress(); |
|||
} |
|||
} |
|||
} |
|||
} catch (SocketException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return ""; |
|||
} |
|||
} |
@ -0,0 +1,133 @@ |
|||
package org.nl.acs.ext.wms; |
|||
|
|||
import cn.hutool.core.util.StrUtil; |
|||
import cn.hutool.http.HttpRequest; |
|||
import com.alibaba.fastjson.JSON; |
|||
import org.nl.acs.config.AcsConfig; |
|||
import org.nl.acs.ext.RequestAdapter; |
|||
import org.nl.acs.ext.ResponseAdapter; |
|||
import org.nl.acs.ext.UnifiedResponse; |
|||
import org.nl.acs.ext.log.ToOthersInterfaceLog; |
|||
import org.nl.modules.system.service.ParamService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/4/22 |
|||
*/ |
|||
@Component |
|||
public class LmsHttpUtil { |
|||
|
|||
private static final RequestAdapter REQUEST_ADAPTER = new LmsRequestAdapter(); |
|||
private static final ResponseAdapter RESPONSE_ADAPTER = new LmsResponseAdapter(); |
|||
|
|||
@Autowired |
|||
private ParamService paramService; |
|||
|
|||
@ToOthersInterfaceLog("ACS->LMS") |
|||
public <T, W> UnifiedResponse<T> sendPostRequest(String path, W requestParam, Class<T> type) { |
|||
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_WMS).getValue(), "1")) { |
|||
return new UnifiedResponse<>(false, "未开启连接该系统!"); |
|||
} |
|||
try { |
|||
String body = HttpRequest |
|||
.post(REQUEST_ADAPTER.getUrl() + path) |
|||
.setConnectionTimeout(5000) |
|||
.body(JSON.toJSONString(requestParam)) |
|||
.execute() |
|||
.body(); |
|||
return RESPONSE_ADAPTER.adapt(body, type); |
|||
} catch (Exception e) { |
|||
return new UnifiedResponse<>(false, e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@ToOthersInterfaceLog("ACS->LMS") |
|||
public <T, W> UnifiedResponse<T> sendPostRequest(String path, W requestParam) { |
|||
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_WMS).getValue(),"1")) { |
|||
return new UnifiedResponse<>(false, "未开启连接该系统!"); |
|||
} |
|||
try { |
|||
String body = HttpRequest |
|||
.post(REQUEST_ADAPTER.getUrl() + path) |
|||
.setConnectionTimeout(5000) |
|||
.body(JSON.toJSONString(requestParam)) |
|||
.execute() |
|||
.body(); |
|||
return RESPONSE_ADAPTER.adapt(body, null); |
|||
} catch (Exception e) { |
|||
return new UnifiedResponse<>(false, e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@ToOthersInterfaceLog("ACS->LMS") |
|||
public <T> UnifiedResponse<T> sendPostRequest(String path, Class<T> type) { |
|||
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_WMS).getValue(), "1")) { |
|||
return new UnifiedResponse<>(false, "未开启连接该系统!"); |
|||
} |
|||
try { |
|||
String body = HttpRequest |
|||
.post(REQUEST_ADAPTER.getUrl() + path) |
|||
.setConnectionTimeout(5000) |
|||
.execute() |
|||
.body(); |
|||
return RESPONSE_ADAPTER.adapt(body, type); |
|||
} catch (Exception e) { |
|||
return new UnifiedResponse<>(false, e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@ToOthersInterfaceLog("ACS->LMS") |
|||
public <T> UnifiedResponse<T> sendPostRequest(String path) { |
|||
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_WMS).getValue(), "1")) { |
|||
return new UnifiedResponse<>(false, "未开启连接该系统!"); |
|||
} |
|||
try { |
|||
String body = HttpRequest |
|||
.post(REQUEST_ADAPTER.getUrl() + path) |
|||
.setConnectionTimeout(5000) |
|||
.execute() |
|||
.body(); |
|||
return RESPONSE_ADAPTER.adapt(body, null); |
|||
} catch (Exception e) { |
|||
return new UnifiedResponse<>(false, e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@ToOthersInterfaceLog("ACS->LMS") |
|||
public <T> UnifiedResponse<T> sendGetRequest(String path, Class<T> type) { |
|||
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_WMS).getValue(), "1")) { |
|||
return new UnifiedResponse<>(false, "未开启连接该系统!"); |
|||
} |
|||
try { |
|||
String body = HttpRequest |
|||
.get(REQUEST_ADAPTER.getUrl() + path) |
|||
.setConnectionTimeout(5000) |
|||
.execute() |
|||
.body(); |
|||
return RESPONSE_ADAPTER.adapt(body, type); |
|||
} catch (Exception e) { |
|||
return new UnifiedResponse<>(false, e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@ToOthersInterfaceLog("ACS->LMS") |
|||
public <T> UnifiedResponse<T> sendGetRequest(String path) { |
|||
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_WMS).getValue(), "1")) { |
|||
return new UnifiedResponse<>(false, "未开启连接该系统!"); |
|||
} |
|||
try { |
|||
String body = HttpRequest |
|||
.get(REQUEST_ADAPTER.getUrl() + path) |
|||
.setConnectionTimeout(5000) |
|||
.execute() |
|||
.body(); |
|||
return RESPONSE_ADAPTER.adapt(body, null); |
|||
} catch (Exception e) { |
|||
return new UnifiedResponse<>(false, e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,20 @@ |
|||
package org.nl.acs.ext.wms; |
|||
|
|||
|
|||
import org.nl.acs.config.AcsConfig; |
|||
import org.nl.acs.ext.RequestAdapter; |
|||
import org.nl.modules.system.service.ParamService; |
|||
import org.nl.modules.wql.util.SpringContextHolder; |
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/4/22 |
|||
*/ |
|||
public class LmsRequestAdapter implements RequestAdapter { |
|||
@Override |
|||
public String getUrl() { |
|||
ParamService paramService = SpringContextHolder.getBean(ParamService.class); |
|||
return paramService.findByCode(AcsConfig.WMS_URL).getValue(); |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
package org.nl.acs.ext.wms; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import org.nl.acs.ext.ResponseAdapter; |
|||
import org.nl.acs.ext.UnifiedResponse; |
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/4/22 |
|||
*/ |
|||
public class LmsResponseAdapter implements ResponseAdapter { |
|||
|
|||
@Override |
|||
public <T> UnifiedResponse<T> adapt(String responseBody, Class<T> type) { |
|||
JSONObject jsonResponse = JSONObject.parseObject(responseBody); |
|||
boolean isSuccess = jsonResponse.getInteger("code") == 200; |
|||
String message = jsonResponse.getString("message"); |
|||
if (type != null) { |
|||
if (type.isArray()) { |
|||
T data = JSONObject.toJavaObject(jsonResponse.getJSONArray("content"), type); |
|||
return new UnifiedResponse<>(isSuccess, message, data); |
|||
} else { |
|||
T data = JSONObject.toJavaObject(jsonResponse.getJSONObject("data"), type); |
|||
return new UnifiedResponse<>(isSuccess, message, data); |
|||
} |
|||
} |
|||
return new UnifiedResponse<>(isSuccess, message); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,135 @@ |
|||
package org.nl.acs.ext.xg; |
|||
|
|||
import cn.hutool.core.util.StrUtil; |
|||
import cn.hutool.http.HttpRequest; |
|||
import com.alibaba.fastjson.JSON; |
|||
import org.nl.acs.config.AcsConfig; |
|||
import org.nl.acs.ext.RequestAdapter; |
|||
import org.nl.acs.ext.ResponseAdapter; |
|||
import org.nl.acs.ext.UnifiedResponse; |
|||
import org.nl.acs.ext.log.ToOthersInterfaceLog; |
|||
import org.nl.modules.system.service.ParamService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/4/22 |
|||
*/ |
|||
@Component |
|||
public class XgHttpUtil { |
|||
|
|||
private static final RequestAdapter REQUEST_ADAPTER = new XgRequestAdapter(); |
|||
private static final ResponseAdapter RESPONSE_ADAPTER = new XgResponseAdapter(); |
|||
|
|||
@Autowired |
|||
private ParamService paramService; |
|||
|
|||
@ToOthersInterfaceLog("ACS->AGV") |
|||
public <T, W> UnifiedResponse<T> sendPostRequest(String path, W requestParam, Class<T> type) { |
|||
if (!StrUtil.equals(paramService.findByCode(AcsConfig.FORK_AGV).getValue(), "1")) { |
|||
return new UnifiedResponse<>(false, "未开启连接该系统!"); |
|||
} |
|||
try { |
|||
String body = HttpRequest |
|||
.post(REQUEST_ADAPTER.getUrl() + path) |
|||
.setConnectionTimeout(10000) |
|||
.body(JSON.toJSONString(requestParam)) |
|||
.execute() |
|||
.body(); |
|||
return RESPONSE_ADAPTER.adapt(body, type); |
|||
} catch (Exception e) { |
|||
return new UnifiedResponse<>(false, e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@ToOthersInterfaceLog("ACS->AGV") |
|||
public <T, W> UnifiedResponse<T> sendPostRequest(String path, W requestParam) { |
|||
if (!StrUtil.equals(paramService.findByCode(AcsConfig.FORK_AGV).getValue(), "1")) { |
|||
return new UnifiedResponse<>(false, "未开启连接该系统!"); |
|||
} |
|||
try { |
|||
String body = HttpRequest |
|||
.post(REQUEST_ADAPTER.getUrl() + path) |
|||
.setConnectionTimeout(10000) |
|||
.body(JSON.toJSONString(requestParam)) |
|||
.execute() |
|||
.body(); |
|||
return RESPONSE_ADAPTER.adapt(body, null); |
|||
} catch (Exception e) { |
|||
return new UnifiedResponse<>(false, e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@ToOthersInterfaceLog("ACS->AGV") |
|||
public <T> UnifiedResponse<T> sendPostRequest(String path, Class<T> type) { |
|||
if (!StrUtil.equals(paramService.findByCode(AcsConfig.FORK_AGV).getValue(), "1")) { |
|||
return new UnifiedResponse<>(false, "未开启连接该系统!"); |
|||
} |
|||
try { |
|||
String body = HttpRequest |
|||
.post(REQUEST_ADAPTER.getUrl() + path) |
|||
.setConnectionTimeout(10000) |
|||
.execute() |
|||
.body(); |
|||
return RESPONSE_ADAPTER.adapt(body, type); |
|||
} catch (Exception e) { |
|||
return new UnifiedResponse<>(false, e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
@ToOthersInterfaceLog("ACS->AGV") |
|||
public <T> UnifiedResponse<T> sendPostRequest(String path) { |
|||
if (!StrUtil.equals(paramService.findByCode(AcsConfig.FORK_AGV).getValue(), "1")) { |
|||
return new UnifiedResponse<>(false, "未开启连接该系统!"); |
|||
} |
|||
try { |
|||
String body = HttpRequest |
|||
.post(REQUEST_ADAPTER.getUrl() + path) |
|||
.setConnectionTimeout(10000) |
|||
.execute() |
|||
.body(); |
|||
return RESPONSE_ADAPTER.adapt(body, null); |
|||
} catch (Exception e) { |
|||
return new UnifiedResponse<>(false, e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
@ToOthersInterfaceLog("ACS->AGV") |
|||
public <T> UnifiedResponse<T> sendGetRequest(String path, Class<T> type) { |
|||
if (!StrUtil.equals(paramService.findByCode(AcsConfig.FORK_AGV).getValue(),"1")) { |
|||
return new UnifiedResponse<>(false, "未开启连接该系统!"); |
|||
} |
|||
try { |
|||
String body = HttpRequest |
|||
.get(REQUEST_ADAPTER.getUrl() + path) |
|||
.setConnectionTimeout(10000) |
|||
.execute() |
|||
.body(); |
|||
return RESPONSE_ADAPTER.adapt(body, type); |
|||
} catch (Exception e) { |
|||
return new UnifiedResponse<>(false, e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@ToOthersInterfaceLog("ACS->AGV") |
|||
public <T> UnifiedResponse<T> sendGetRequest(String path) { |
|||
if (!StrUtil.equals(paramService.findByCode(AcsConfig.FORK_AGV).getValue(), "1")) { |
|||
return new UnifiedResponse<>(false, "未开启连接该系统!"); |
|||
} |
|||
try { |
|||
String body = HttpRequest |
|||
.get(REQUEST_ADAPTER.getUrl() + path) |
|||
.setConnectionTimeout(10000) |
|||
.execute() |
|||
.body(); |
|||
return RESPONSE_ADAPTER.adapt(body, null); |
|||
} catch (Exception e) { |
|||
return new UnifiedResponse<>(false, e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,21 @@ |
|||
package org.nl.acs.ext.xg; |
|||
|
|||
import org.nl.acs.config.AcsConfig; |
|||
import org.nl.acs.ext.RequestAdapter; |
|||
import org.nl.modules.system.service.ParamService; |
|||
import org.nl.modules.wql.util.SpringContextHolder; |
|||
|
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/4/22 |
|||
*/ |
|||
public class XgRequestAdapter implements RequestAdapter { |
|||
@Override |
|||
public String getUrl() { |
|||
ParamService paramService = SpringContextHolder.getBean(ParamService.class); |
|||
return paramService.findByCode(AcsConfig.AGV_URL).getValue(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,44 @@ |
|||
package org.nl.acs.ext.xg; |
|||
|
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import org.nl.acs.ext.ResponseAdapter; |
|||
import org.nl.acs.ext.UnifiedResponse; |
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/4/22 |
|||
*/ |
|||
public class XgResponseAdapter implements ResponseAdapter { |
|||
|
|||
@Override |
|||
public <T> UnifiedResponse<T> adapt(String responseBody, Class<T> type) { |
|||
responseBody = responseBody.trim(); |
|||
if (responseBody.startsWith("{") && responseBody.endsWith("}")) { |
|||
JSONObject resp = JSON.parseObject(responseBody); |
|||
String message = resp.containsKey("msg") ? resp.getString("msg") : ""; |
|||
if (resp.containsKey("code") && resp.getInteger("code") != 0) { |
|||
return new UnifiedResponse<>(false, message); |
|||
} else { |
|||
if (type != null) { |
|||
T data = JSONObject.toJavaObject(resp, type); |
|||
return new UnifiedResponse<>(true, message, data); |
|||
} |
|||
return new UnifiedResponse<>(true, message, (T) resp); |
|||
} |
|||
} else if (responseBody.startsWith("[") && responseBody.endsWith("]")) { |
|||
JSONArray resp = JSON.parseArray(responseBody); |
|||
if (type != null) { |
|||
T data = JSONObject.toJavaObject(resp, type); |
|||
return new UnifiedResponse<>(true, "success", data); |
|||
} else { |
|||
return new UnifiedResponse<>(true, "success", (T) resp); |
|||
} |
|||
} else { |
|||
return new UnifiedResponse<>(false, "failed,响应数据为空!"); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,19 @@ |
|||
package org.nl.modules.lucene.enums; |
|||
|
|||
import lombok.Getter; |
|||
import lombok.RequiredArgsConstructor; |
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/4/10 |
|||
*/ |
|||
@Getter |
|||
@RequiredArgsConstructor |
|||
public enum DeviceLogTypeEnum { |
|||
AUTO_THREAD("auto", "自动线程"), |
|||
MQTT("mqtt", "MQTT"); |
|||
|
|||
private final String code; |
|||
private final String name; |
|||
} |
@ -0,0 +1,64 @@ |
|||
package org.nl.modules.quartz.task; |
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.lucene.document.Document; |
|||
import org.apache.lucene.index.DirectoryReader; |
|||
import org.apache.lucene.index.IndexReader; |
|||
import org.apache.lucene.index.IndexWriter; |
|||
import org.apache.lucene.index.Term; |
|||
import org.apache.lucene.search.*; |
|||
import org.apache.lucene.store.FSDirectory; |
|||
import org.apache.lucene.util.BytesRef; |
|||
import org.nl.modules.lucene.config.LuceneAppender; |
|||
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; |
|||
import org.springframework.core.io.ClassPathResource; |
|||
import org.springframework.core.io.Resource; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.nio.file.Paths; |
|||
import java.time.Instant; |
|||
import java.time.temporal.ChronoUnit; |
|||
import java.util.Date; |
|||
import java.util.Properties; |
|||
|
|||
|
|||
/** |
|||
* @author onepiece |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
public class AutoCleanLuceneLog { |
|||
|
|||
private static final long MAX_FILE_AGE_DAYS = 10; |
|||
|
|||
public void run() { |
|||
try { |
|||
Resource resource = new ClassPathResource("config/application.yml"); |
|||
YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean(); |
|||
yamlPropertiesFactoryBean.setResources(resource); |
|||
Properties properties = yamlPropertiesFactoryBean.getObject(); |
|||
String logDirectory = properties.getProperty("lucene.index.path"); |
|||
|
|||
Instant now = Instant.now(); |
|||
Instant cutoffTime = now.minus(MAX_FILE_AGE_DAYS, ChronoUnit.DAYS); |
|||
String cutoffTimeStr = DateUtil.format(Date.from(cutoffTime), "yyyy-MM-dd HH:mm:ss.SSS"); |
|||
|
|||
FSDirectory dir = FSDirectory.open(Paths.get(logDirectory)); |
|||
IndexWriter writer = LuceneAppender.indexWriter; |
|||
|
|||
try (IndexReader reader = DirectoryReader.open(dir)) { |
|||
IndexSearcher searcher = new IndexSearcher(reader); |
|||
Query query = new TermRangeQuery("logTime", new BytesRef(""), new BytesRef(cutoffTimeStr), true, true); |
|||
TopDocs topDocs = searcher.search(query, Integer.MAX_VALUE); |
|||
for (ScoreDoc scoreDoc : topDocs.scoreDocs) { |
|||
Document doc = searcher.doc(scoreDoc.doc); |
|||
writer.deleteDocuments(new Term("logTime", doc.get("logTime"))); |
|||
} |
|||
} |
|||
writer.commit(); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,122 @@ |
|||
package org.nl.modules.quartz.task; |
|||
|
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.acs.agv.server.XianGongAgvService; |
|||
import org.nl.acs.device_driver.basedriver.agv.xg_agv.XianGongAgvDeviceDriver; |
|||
import org.nl.acs.ext.UnifiedResponse; |
|||
import org.nl.acs.instruction.service.InstructionService; |
|||
import org.nl.acs.instruction.service.dto.Instruction; |
|||
import org.nl.acs.opc.Device; |
|||
import org.nl.acs.opc.DeviceAppService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.math.RoundingMode; |
|||
import java.text.DecimalFormat; |
|||
|
|||
/** |
|||
* 查询先工AGV设备状态 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
public class QueryXZAgvDeviceStatus { |
|||
|
|||
@Autowired |
|||
private XianGongAgvService agvService; |
|||
@Autowired |
|||
private DeviceAppService deviceAppService; |
|||
@Autowired |
|||
private InstructionService instructionService; |
|||
|
|||
|
|||
public void run() { |
|||
try { |
|||
UnifiedResponse<JSONObject> response = agvService.queryXZAgvDeviceStatus(null, JSONObject.class); |
|||
if (response.isSuccess()) { |
|||
JSONObject body = response.getData(); |
|||
JSONArray ja = body.getJSONArray("report"); |
|||
for (int i = 0; i < ja.size(); i++) { |
|||
JSONObject jo = ja.getJSONObject(i); |
|||
//机器人编码
|
|||
String agv_code = jo.getString("uuid"); |
|||
//机器人详细状态信息
|
|||
JSONObject rbk_report = jo.getJSONObject("rbk_report"); |
|||
//是否正在充电
|
|||
Boolean charging = rbk_report.getBoolean("charging"); |
|||
//角度
|
|||
Double angle = rbk_report.getDouble("angle"); |
|||
//电池电量(0-1)
|
|||
Double battery_level = rbk_report.getDouble("battery_level"); |
|||
//当前开机时间 ms
|
|||
Integer time = rbk_report.getInteger("time"); |
|||
//累计运行时间 ms
|
|||
Integer total_time = rbk_report.getInteger("total_time"); |
|||
//今日累计行驶里程, 单位 m
|
|||
Double today_odo = rbk_report.getDouble("today_odo"); |
|||
//累计行驶里程
|
|||
Integer odo = rbk_report.getInteger("odo"); |
|||
//是否正在执行任务
|
|||
Boolean procBusiness = jo.getBoolean("procBusiness"); |
|||
//agv是否故障
|
|||
Boolean is_error = jo.getBoolean("is_error"); |
|||
//执行运单信息
|
|||
JSONObject current_order = jo.getJSONObject("current_order"); |
|||
Integer connectionStatus = jo.getInteger("connection_status"); |
|||
String inst_code = current_order.getString("id"); |
|||
Instruction instruction = instructionService.findByCodeFromCache(inst_code); |
|||
String taskCode = "0"; |
|||
if (instruction != null) { |
|||
taskCode = instruction.getTask_code(); |
|||
} |
|||
DecimalFormat hisFormat = new DecimalFormat("########.###"); |
|||
hisFormat.setRoundingMode(RoundingMode.DOWN); |
|||
//x坐标
|
|||
Double x = rbk_report.getDouble("x"); |
|||
//y坐标
|
|||
Double y = rbk_report.getDouble("y"); |
|||
String status = "0"; |
|||
if (connectionStatus == 0) { |
|||
status = "5"; |
|||
} else { |
|||
if (procBusiness && !is_error) { |
|||
//工作中
|
|||
status = "1"; |
|||
} else { |
|||
if (charging) { |
|||
//充电中
|
|||
status = "2"; |
|||
} else { |
|||
if (is_error) { |
|||
//故障
|
|||
status = "3"; |
|||
} else { |
|||
//休息中
|
|||
status = "4"; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Device device = deviceAppService.findDeviceByCode(agv_code); |
|||
if (device != null && device.getDeviceDriver() instanceof XianGongAgvDeviceDriver) { |
|||
XianGongAgvDeviceDriver xgAGV = (XianGongAgvDeviceDriver) device.getDeviceDriver(); |
|||
xgAGV.setTaskCode(taskCode); |
|||
xgAGV.setBattery_level(battery_level); |
|||
xgAGV.setAngle(angle); |
|||
xgAGV.setTime(time); |
|||
xgAGV.setTotal_time(total_time); |
|||
xgAGV.setToday_odo(today_odo); |
|||
xgAGV.setOdo(odo); |
|||
xgAGV.setX(x); |
|||
xgAGV.setY(y); |
|||
xgAGV.setStatus(Integer.parseInt(status)); |
|||
} |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
System.out.println("出现异常"); |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,551 @@ |
|||
<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-col :span="8"> |
|||
<el-form-item label="站点管理" label-width="150px"> |
|||
<el-switch v-model="form.station_manager" /> |
|||
</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">交互相关:</span> |
|||
</div> |
|||
<div class="crud-opts2" style="margin-bottom: 5px;"> |
|||
<span class="crud-opts-right2"> |
|||
<!--左侧插槽--> |
|||
<slot name="left" /> |
|||
<el-button |
|||
slot="left" |
|||
class="filter-item" |
|||
type="primary" |
|||
icon="el-icon-plus" |
|||
size="mini" |
|||
@click="insertdtl()" |
|||
> |
|||
新增一行 |
|||
</el-button> |
|||
</span> |
|||
|
|||
</div> |
|||
<div class="app-container"> |
|||
<el-table :data="modeform.tableData" border fit highlight-current-row style="width: 100%;" class="tb-edit"> |
|||
<el-table-column label="mode" prop="模式" width="180"> |
|||
<template scope="scope"> |
|||
<el-input-number v-model="scope.row.mode" value="3" :min="3" size="mini" /> |
|||
<span v-show="scope.row.edit">{{ scope.row.mode }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column label="request" prop="请求方法" width="500"> |
|||
<template scope="scope"> |
|||
<el-select |
|||
v-model="scope.row.request" |
|||
filterable |
|||
clearable |
|||
placeholder="请选择" |
|||
style="width: 450px" |
|||
> |
|||
<el-option |
|||
v-for="item in requestMethodList" |
|||
:key="item.code" |
|||
:label="item.name" |
|||
:value="item.code" |
|||
/> |
|||
</el-select> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column align="center" label="操作" width="170"> |
|||
<template scope="scope"> |
|||
<el-button |
|||
type="danger" |
|||
class="filter-item" |
|||
size="mini" |
|||
icon="el-icon-delete" |
|||
@click.native.prevent="deleteRow(scope.$index, modeform.tableData)" |
|||
/> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
</div> |
|||
</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="dbr_value2"> |
|||
<template slot="header"> |
|||
<el-link type="primary" :underline="false" @click.native="test_read2()">测试读</el-link> |
|||
</template> |
|||
<template slot-scope="scope"> |
|||
<el-input v-model="data2[scope.$index].dbr_value" size="mini" class="edit-input" /> |
|||
</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: 'NL4Station', |
|||
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: [], |
|||
requestMethodList: [], |
|||
modeform: { |
|||
tableData: [] |
|||
}, |
|||
form: { |
|||
inspect_in_stocck: true, |
|||
ignore_pickup_check: false, |
|||
ignore_release_check: false, |
|||
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 |
|||
} |
|||
} |
|||
// 交互相关回显 |
|||
if (data.modeform) { |
|||
const arr = Object.keys(data.modeform) |
|||
if (arr.length > 0) { |
|||
this.modeform.tableData = data.modeform |
|||
} |
|||
} |
|||
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 |
|||
}) |
|||
deviceCrud.selectRequestMethodList().then(data => { |
|||
this.requestMethodList = data |
|||
}) |
|||
}) |
|||
}, |
|||
methods: { |
|||
insertdtl() { |
|||
this.modeform.tableData.push({ mode: '', request: '' }) |
|||
}, |
|||
deleteRow(index, rows) { |
|||
rows.splice(index, 1) |
|||
}, |
|||
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 + '.B0' |
|||
} |
|||
if (this.data1[val].code.indexOf('move') !== -1) { |
|||
this.data1[val].db = beforeStr + '.B2' |
|||
} |
|||
if (this.data1[val].code.indexOf('error') !== -1) { |
|||
this.data1[val].db = beforeStr + '.B3' |
|||
} |
|||
if (this.data1[val].code.indexOf('task') !== -1) { |
|||
this.data1[val].db = beforeStr + '.D4' |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
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 + '.W2' |
|||
} |
|||
if (this.data2[val].code.indexOf('to_task') !== -1) { |
|||
this.data2[val].db = beforeStr + '.D4' |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
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) |
|||
}) |
|||
}, |
|||
test_read2() { |
|||
testRead(this.data2, this.opc_id).then(data => { |
|||
this.data2 = data |
|||
console.log(this.data2) |
|||
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.modeform, 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> |
@ -0,0 +1,103 @@ |
|||
<template> |
|||
<!--agv单工位--> |
|||
<div> |
|||
<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" size="small" label-width="95px"> |
|||
<el-row> |
|||
<el-col :span="8"> |
|||
<el-form-item label="ip地址" prop="ip_address"> |
|||
<el-input |
|||
v-model="form.ip_address" |
|||
/> |
|||
</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" /> |
|||
<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 |
|||
} from '@/api/acs/device/driverConfig' |
|||
import crud from '@/mixins/crud' |
|||
|
|||
export default { |
|||
name: 'StandardConveyorControl', |
|||
mixins: [crud], |
|||
props: { |
|||
parentForm: { |
|||
type: Object, |
|||
require: true |
|||
} |
|||
}, |
|||
data() { |
|||
return { |
|||
form: { |
|||
ip_address: '' |
|||
} |
|||
} |
|||
}, |
|||
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 |
|||
} |
|||
} |
|||
this.sliceItem() |
|||
}) |
|||
}) |
|||
}, |
|||
methods: { |
|||
doSubmit() { |
|||
this.$refs['form'].validate((valid) => { |
|||
if (valid) { |
|||
this.configLoading = true |
|||
// 根据驱动类型判断是否为路由设备 |
|||
const parentForm = this.parentForm |
|||
parentForm.is_route = true |
|||
updateConfig(parentForm, this.form, this.modeform, this.data1, this.data2).then(res => { |
|||
this.notify('保存成功', 'success') |
|||
this.configLoading = false |
|||
}).catch(err => { |
|||
this.configLoading = false |
|||
console.log(err.response.data.message) |
|||
}) |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
|
|||
</style> |
@ -0,0 +1,32 @@ |
|||
import request from '@/utils/request' |
|||
|
|||
export function getLogData(param) { |
|||
return request({ |
|||
url: 'api/lucene/getAll', |
|||
method: 'get', |
|||
data: param |
|||
}) |
|||
} |
|||
|
|||
export function labelsValues() { |
|||
return request({ |
|||
url: 'api/loki/labels/values', |
|||
method: 'get' |
|||
}) |
|||
} |
|||
|
|||
export function getDeviceLogType() { |
|||
return request({ |
|||
url: 'api/lucene/getDeviceLogType', |
|||
method: 'get' |
|||
}) |
|||
} |
|||
|
|||
export function getLogTypes() { |
|||
return request({ |
|||
url: 'api/lucene/getLogTypes', |
|||
method: 'get' |
|||
}) |
|||
} |
|||
|
|||
export default { getLogData, labelsValues, getDeviceLogType, getLogTypes } |
@ -0,0 +1,162 @@ |
|||
<template> |
|||
<div class="app-container"> |
|||
<div class="head-container"> |
|||
<Search |
|||
:log-types="logTypes" |
|||
:device-list="deviceList" |
|||
:device-log-types="deviceLogTypes" |
|||
@performSearch="performSearch" |
|||
/> |
|||
<crudOperation /> |
|||
</div> |
|||
<!--表格渲染--> |
|||
<el-table |
|||
ref="table" |
|||
v-loading="crud.loading" |
|||
:data="crud.data" |
|||
style="width: 100%;" |
|||
@selection-change="crud.selectionChangeHandler" |
|||
> |
|||
<el-table-column |
|||
prop="request_url" |
|||
label="请求路径" |
|||
show-overflow-tooltip |
|||
/> |
|||
<el-table-column |
|||
prop="request_direction" |
|||
label="请求方向" |
|||
show-overflow-tooltip |
|||
/> |
|||
<el-table-column |
|||
prop="request_param" |
|||
label="请求参数" |
|||
show-overflow-tooltip |
|||
/> |
|||
<el-table-column |
|||
prop="response_param" |
|||
label="返回参数" |
|||
show-overflow-tooltip |
|||
/> |
|||
<el-table-column |
|||
prop="method" |
|||
label="执行方法" |
|||
show-overflow-tooltip |
|||
/> |
|||
<el-table-column |
|||
prop="executeTime" |
|||
label="执行时间" |
|||
show-overflow-tooltip |
|||
/> |
|||
<el-table-column prop="content" show-overflow-tooltip label="内容详情" /> |
|||
<el-table-column prop="logTime" show-overflow-tooltip label="记录时间" /> |
|||
</el-table> |
|||
<!--分页组件--> |
|||
<pagination /> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import Search from './search' |
|||
import CRUD, { crud, header, presenter } from '@crud/crud' |
|||
import crudOperation from '@crud/CRUD.operation' |
|||
import pagination from '@crud/Pagination' |
|||
import { delAll } from '@/api/acs/lucene/log' |
|||
import crudDevice from '@/api/acs/device/device' |
|||
import crudLucene from './api/lucene' |
|||
|
|||
export default { |
|||
name: 'LuceneLog', |
|||
components: { Search, pagination, crudOperation }, |
|||
mixins: [presenter(), header(), crud()], |
|||
cruds: function() { |
|||
return CRUD({ |
|||
title: '接口日志', url: 'api/lucene/getAll', idField: 'id', sort: 'id,desc', |
|||
queryOnPresenterCreated: true, |
|||
optShow: { |
|||
add: false, |
|||
edit: false, |
|||
del: false, |
|||
download: false |
|||
}, |
|||
page: { |
|||
size: 40, |
|||
total: 0, |
|||
page: 0 |
|||
}, |
|||
query: { |
|||
createTime: [new Date(new Date().setTime(new Date().getTime() - 3600 * 1000)), new Date(new Date().setTime(new Date().getTime() + 3600 * 1000))], |
|||
logType: '接口日志' |
|||
} |
|||
}) |
|||
}, |
|||
data() { |
|||
return { |
|||
query: { blurry: '123' }, |
|||
permission: { |
|||
add: ['admin', 'param:add'], |
|||
edit: ['admin', 'param:edit'], |
|||
del: ['admin', 'param:del'] |
|||
}, |
|||
deviceList: [], |
|||
deviceLogTypes: [], |
|||
logTypes: [], |
|||
rules: {}, |
|||
logType: '' |
|||
} |
|||
}, |
|||
created() { |
|||
this.getLogTypes() |
|||
this.getDeviceList() |
|||
this.getDeviceLogTypes() |
|||
}, |
|||
methods: { |
|||
// 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
|||
[CRUD.HOOK.beforeRefresh]() { |
|||
return true |
|||
}, |
|||
getLogTypes() { |
|||
crudLucene.getLogTypes().then(res => { |
|||
this.logTypes = res |
|||
}) |
|||
}, |
|||
getDeviceLogTypes() { |
|||
crudLucene.getDeviceLogType().then(res => { |
|||
this.deviceLogTypes = res |
|||
}) |
|||
}, |
|||
getDeviceList() { |
|||
crudDevice.selectDeviceList().then(res => { |
|||
this.deviceList = res |
|||
}) |
|||
}, |
|||
confirmDelAll() { |
|||
this.$confirm(`确认清空所有操作日志吗?`, '提示', { |
|||
confirmButtonText: '确定', |
|||
cancelButtonText: '取消', |
|||
type: 'warning' |
|||
}).then(() => { |
|||
this.crud.delAllLoading = true |
|||
delAll('device_execute').then(res => { |
|||
this.crud.delAllLoading = false |
|||
this.crud.dleChangePage(1) |
|||
this.crud.delSuccessNotify() |
|||
this.crud.toQuery() |
|||
}).catch(err => { |
|||
this.crud.delAllLoading = false |
|||
console.log(err.response.data.message) |
|||
}) |
|||
}).catch(() => { |
|||
}) |
|||
}, |
|||
performSearch(value) { |
|||
console.log('Search with:' + value) |
|||
this.logType = value |
|||
this.crud.toQuery() |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
|
|||
</style> |
@ -0,0 +1,134 @@ |
|||
<template> |
|||
<div v-if="crud.props.searchToggle"> |
|||
<el-form :model="query" class="filter-form" inline> |
|||
<el-form-item label="请求方向:"> |
|||
<el-select |
|||
v-model="query.request_direction" |
|||
filterable |
|||
clearable |
|||
size="small" |
|||
placeholder="请选择请求方向" |
|||
> |
|||
<el-option |
|||
v-for="direction in directionList" |
|||
:key="direction" |
|||
:label="direction" |
|||
:value="direction" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="请求路径:"> |
|||
<el-input |
|||
v-model="query.request_url" |
|||
clearable |
|||
size="small" |
|||
placeholder="请输入请求路径" |
|||
style="width: 200px;" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item label="请求参数:"> |
|||
<el-input |
|||
v-model="query.request_param" |
|||
clearable |
|||
size="small" |
|||
placeholder="请输入请求参数内容" |
|||
style="width: 200px;" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item label="内容详情:"> |
|||
<el-input |
|||
v-model="query.blurry" |
|||
clearable |
|||
size="small" |
|||
placeholder="请输入你要搜索的内容详情" |
|||
style="width: 200px;" |
|||
/> |
|||
</el-form-item> |
|||
|
|||
<el-form-item label="记录时间:"> |
|||
<el-date-picker |
|||
v-model="query.createTime" |
|||
type="datetimerange" |
|||
:picker-options="pickerOptions" |
|||
format="yyyy-MM-dd HH:mm:ss" |
|||
range-separator="至" |
|||
start-placeholder="开始日期" |
|||
end-placeholder="结束日期" |
|||
align="right" |
|||
/> |
|||
</el-form-item> |
|||
<rrOperation /> |
|||
</el-form> |
|||
|
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { header } from '@crud/crud' |
|||
import rrOperation from '@crud/RR.operation' |
|||
|
|||
export default { |
|||
components: { rrOperation }, |
|||
mixins: [header()], |
|||
props: { |
|||
deviceList: Array, |
|||
deviceLogTypes: Array |
|||
}, |
|||
data() { |
|||
return { |
|||
pickerOptions: { |
|||
shortcuts: [{ |
|||
text: '最近一周', |
|||
onClick(picker) { |
|||
const end = new Date() |
|||
const start = new Date() |
|||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7) |
|||
picker.$emit('pick', [start, end]) |
|||
} |
|||
}, { |
|||
text: '最近一个月', |
|||
onClick(picker) { |
|||
const end = new Date() |
|||
const start = new Date() |
|||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30) |
|||
picker.$emit('pick', [start, end]) |
|||
} |
|||
}, { |
|||
text: '最近三个月', |
|||
onClick(picker) { |
|||
const end = new Date() |
|||
const start = new Date() |
|||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90) |
|||
picker.$emit('pick', [start, end]) |
|||
} |
|||
}] |
|||
}, |
|||
value1: [new Date(2000, 10, 10, 10, 10), new Date(2000, 10, 11, 10, 10)], |
|||
value2: '', |
|||
directionList: [ |
|||
'ACS->LMS', |
|||
'LMS->ACS', |
|||
'ACS->HR', |
|||
'HR->ACS', |
|||
'ACS->AGV', |
|||
'AGV->ACS' |
|||
] |
|||
} |
|||
}, |
|||
watch: { |
|||
logTypes: { |
|||
immediate: true, |
|||
handler(newVal) { |
|||
} |
|||
} |
|||
}, |
|||
created() { |
|||
}, |
|||
methods: { |
|||
handleLogTypeChange(value) { |
|||
this.query.logType = value |
|||
this.$emit('performSearch', this.query.logType) |
|||
} |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,64 @@ |
|||
<template> |
|||
<div v-if="crud.props.searchToggle"> |
|||
<!-- |
|||
<date-range-picker v-model="query.createTime" class="date-item" /> |
|||
--> |
|||
|
|||
<el-date-picker |
|||
v-model="query.createTime" |
|||
type="datetimerange" |
|||
:picker-options="pickerOptions" |
|||
range-separator="至" |
|||
start-placeholder="开始日期" |
|||
end-placeholder="结束日期" |
|||
align="right" |
|||
/> |
|||
<rrOperation /> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { header } from '@crud/crud' |
|||
import rrOperation from '@crud/RR.operation' |
|||
|
|||
export default { |
|||
components: { rrOperation }, |
|||
mixins: [header()], |
|||
|
|||
data() { |
|||
return { |
|||
pickerOptions: { |
|||
shortcuts: [{ |
|||
text: '最近一周', |
|||
onClick(picker) { |
|||
const end = new Date() |
|||
const start = new Date() |
|||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7) |
|||
picker.$emit('pick', [start, end]) |
|||
} |
|||
}, { |
|||
text: '最近一个月', |
|||
onClick(picker) { |
|||
const end = new Date() |
|||
const start = new Date() |
|||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30) |
|||
picker.$emit('pick', [start, end]) |
|||
} |
|||
}, { |
|||
text: '最近三个月', |
|||
onClick(picker) { |
|||
const end = new Date() |
|||
const start = new Date() |
|||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90) |
|||
picker.$emit('pick', [start, end]) |
|||
} |
|||
}] |
|||
}, |
|||
value1: [new Date(2000, 10, 10, 10, 10), new Date(2000, 10, 11, 10, 10)], |
|||
value2: '' |
|||
} |
|||
}, |
|||
created() { |
|||
} |
|||
} |
|||
</script> |
Loading…
Reference in new issue