Commit 0413cc73 authored by wanghao's avatar wanghao

1 报警记录界面实现

2 在所有设备上下电的基础上,增加指定柜子上下电实现
3 实时数据界面增加位置编号字段,位置编号是在托盘上用记号笔记录的编号。
4 解绑时判断 如果都解绑了则更新托盘状态
parent e42f2e1c
package com.zehong.web.controller.equipment;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.system.domain.TEquipmentAlarmData;
import com.zehong.system.service.ITEquipmentAlarmDataService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @author lenovo
* @date 2025/11/12
* @description 报警历史记录
*/
@RestController
@RequestMapping("/equipmentAlarmData/record")
public class TEquipmentAlarmDataController extends BaseController {
@Resource
private ITEquipmentAlarmDataService tEquipmentAlarmDataService;
@RequestMapping("/list")
public TableDataInfo list(TEquipmentAlarmData tEquipmentAlarmData) {
startPage();
List<TEquipmentAlarmData> list = tEquipmentAlarmDataService.selectTEquipmentAlarmDataList(tEquipmentAlarmData);
return getDataTable(list);
}
}
...@@ -119,6 +119,21 @@ public class TStoreyInfoController extends BaseController ...@@ -119,6 +119,21 @@ public class TStoreyInfoController extends BaseController
public AjaxResult powerOffAllStore() { public AjaxResult powerOffAllStore() {
return tStoreyInfoService.powerOffAllStore(); return tStoreyInfoService.powerOffAllStore();
} }
/**
* 指定设备下电 逗号分隔
*/
@GetMapping(value = "/designatedDevicePowerOff/{equipmentCode}")
public AjaxResult designatedDevicePowerOff(@PathVariable("equipmentCode") String equipmentCode) {
return tStoreyInfoService.designatedDevicePowerOff(equipmentCode);
}
/**
* 批量扫描并开始老化
*/
@GetMapping(value = "/scanAndStartAgingAllCabinetLayers")
public AjaxResult scanAndStartAgingAllCabinetLayers() {
return tStoreyInfoService.scanAndStartAgingAllCabinetLayers();
}
/** /**
* 给所有设备上电 * 给所有设备上电
...@@ -128,6 +143,14 @@ public class TStoreyInfoController extends BaseController ...@@ -128,6 +143,14 @@ public class TStoreyInfoController extends BaseController
return tStoreyInfoService.powerOnAllStore(); return tStoreyInfoService.powerOnAllStore();
} }
/**
* 指定设备上电 逗号分隔
*/
@GetMapping(value = "/designatedDevicePowerOn/{equipmentCode}")
public AjaxResult designatedDevicePowerOn(@PathVariable("equipmentCode") String equipmentCode) {
return tStoreyInfoService.designatedDevicePowerOn(equipmentCode);
}
/** /**
* 获取老化层信息详细信息 * 获取老化层信息详细信息
*/ */
......
...@@ -42,6 +42,8 @@ public interface PalletDeviceBindingMapper ...@@ -42,6 +42,8 @@ public interface PalletDeviceBindingMapper
public int countByTrayId(Long trayId); public int countByTrayId(Long trayId);
public int countDeviceByTrayId(Long trayId);
/** /**
* 新增托盘绑定的设备列 * 新增托盘绑定的设备列
* *
......
...@@ -37,6 +37,10 @@ public interface TEquipmentInfoMapper ...@@ -37,6 +37,10 @@ public interface TEquipmentInfoMapper
*/ */
public List<TEquipmentInfo> selectTEquipmentList(@Param("types") List<String> types); public List<TEquipmentInfo> selectTEquipmentList(@Param("types") List<String> types);
public List<TEquipmentInfo> getAll();
public List<TEquipmentInfo> getAllByEquipmentCodeList(@Param("equipmentCodes") List<String> equipmentCodes);
/** /**
* 新增生产设备信息 * 新增生产设备信息
* *
......
...@@ -21,6 +21,9 @@ public interface ITStoreyInfoService ...@@ -21,6 +21,9 @@ public interface ITStoreyInfoService
*/ */
public TStoreyInfo selectTStoreyInfoById(Long fStoreyId); public TStoreyInfo selectTStoreyInfoById(Long fStoreyId);
public AjaxResult designatedDevicePowerOn(String equipmentCode);
public AjaxResult designatedDevicePowerOff(String equipmentCode);
/** /**
* 查询老化层信息 * 查询老化层信息
* *
...@@ -49,6 +52,8 @@ public interface ITStoreyInfoService ...@@ -49,6 +52,8 @@ public interface ITStoreyInfoService
public AjaxResult powerOffAllStore(); public AjaxResult powerOffAllStore();
public AjaxResult scanAndStartAgingAllCabinetLayers();
public AjaxResult powerOnAllStore(); public AjaxResult powerOnAllStore();
public AjaxResult handleFeeding(String command); public AjaxResult handleFeeding(String command);
......
...@@ -234,6 +234,13 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi ...@@ -234,6 +234,13 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
int i = palletDeviceBindingMapper.unbindDevice(palletDeviceBindingDb.getPalletDeviceBindingId()); int i = palletDeviceBindingMapper.unbindDevice(palletDeviceBindingDb.getPalletDeviceBindingId());
if (i > 0) { if (i > 0) {
// 成功之后 判断 是否还有设备,如果没有设备的话则 初始化托盘状态
int count = palletDeviceBindingMapper.countDeviceByTrayId(palletDeviceBindingDb.getTrayId());
if(count == 0) {
tTrayInfoMapper.initStatusByTrayId(palletDeviceBindingDb.getTrayId());
}
return AjaxResult.success(); return AjaxResult.success();
} }
return AjaxResult.error(); return AjaxResult.error();
......
...@@ -7,25 +7,26 @@ import com.serotonin.modbus4j.exception.ModbusTransportException; ...@@ -7,25 +7,26 @@ import com.serotonin.modbus4j.exception.ModbusTransportException;
import com.zehong.common.core.domain.AjaxResult; import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.utils.DateUtils; import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils; import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.TEquipmentAlarmData;
import com.zehong.system.domain.TEquipmentInfo; import com.zehong.system.domain.TEquipmentInfo;
import com.zehong.system.domain.TStoreyInfo; import com.zehong.system.domain.TStoreyInfo;
import com.zehong.system.domain.TTrayInfo; import com.zehong.system.domain.TTrayInfo;
import com.zehong.system.mapper.TEquipmentInfoMapper; import com.zehong.system.mapper.TEquipmentInfoMapper;
import com.zehong.system.mapper.TStoreyInfoMapper; import com.zehong.system.mapper.TStoreyInfoMapper;
import com.zehong.system.mapper.TTrayInfoMapper; import com.zehong.system.mapper.TTrayInfoMapper;
import com.zehong.system.modbus.business.DeviceStatusReaderAndTimeSetter;
import com.zehong.system.modbus.handler.ModbusResultHandler;
import com.zehong.system.modbus.util.Modbus4jUtils; import com.zehong.system.modbus.util.Modbus4jUtils;
import com.zehong.system.service.IRobotArmCommandService; import com.zehong.system.service.IRobotArmCommandService;
import com.zehong.system.service.ITEquipmentAlarmDataService;
import com.zehong.system.service.ITEquipmentInfoService;
import com.zehong.system.service.ITStoreyInfoService; import com.zehong.system.service.ITStoreyInfoService;
import com.zehong.system.service.websocket.RobotArmWebSocketHandler; import com.zehong.system.service.websocket.AgingCabinetWebSocketHandler;
import com.zehong.system.task.CheckPowerOnCommandEvent;
import com.zehong.system.task.DeviceTaskScheduler; import com.zehong.system.task.DeviceTaskScheduler;
import org.quartz.JobKey; import org.quartz.*;
import org.quartz.SchedulerException; import org.quartz.impl.matchers.GroupMatcher;
import org.quartz.TriggerKey;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -35,6 +36,9 @@ import java.util.concurrent.ExecutorService; ...@@ -35,6 +36,9 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.zehong.system.task.DeviceTaskScheduler.JOB_GROUP;
import static com.zehong.system.task.DeviceTaskScheduler.TRIGGER_GROUP;
/** /**
* 老化层信息Service业务层处理 * 老化层信息Service业务层处理
* *
...@@ -60,6 +64,15 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService ...@@ -60,6 +64,15 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
@Resource @Resource
private DeviceTaskScheduler deviceTaskScheduler; private DeviceTaskScheduler deviceTaskScheduler;
@Resource
private ITEquipmentAlarmDataService tEquipmentAlarmDataService;
@Resource
private Scheduler scheduler;
@Resource
private ITEquipmentInfoService tEquipmentInfoService;
private final ExecutorService executor = Executors.newFixedThreadPool(10);
@Resource
private ApplicationEventPublisher eventPublisher; // 新增事件发布器
private final ExecutorService executorService = Executors.newFixedThreadPool(10); private final ExecutorService executorService = Executors.newFixedThreadPool(10);
/** /**
...@@ -74,6 +87,169 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService ...@@ -74,6 +87,169 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
return tStoreyInfoMapper.selectTStoreyInfoById(fStoreyId); return tStoreyInfoMapper.selectTStoreyInfoById(fStoreyId);
} }
/**
* 指定设备断电
*
* @param equipmentCode aging cabinet
* @return aging cabinet
*/
@Override
public AjaxResult designatedDevicePowerOff(String equipmentCode) {
// 1.1 校验参数
List<TEquipmentInfo> equipmentInfos = checkEquipmentCodesReturnEquipmentInfos(equipmentCode);
// 1.2 批量上电
powerOffToEquipments(equipmentInfos);
return AjaxResult.success();
}
/**
* 指定设备上电
* @param equipmentCode e
* @return r
*/
@Override
public AjaxResult designatedDevicePowerOn(String equipmentCode) {
// 1.1 校验参数
List<TEquipmentInfo> equipmentInfos = checkEquipmentCodesReturnEquipmentInfos(equipmentCode);
// 1.2 批量上电
powerOnToEquipments(equipmentInfos);
return AjaxResult.success();
}
/**
* 校验参数
* @return r r
*/
private List<TEquipmentInfo> checkEquipmentCodesReturnEquipmentInfos(String equipmentCodes) {
if(StringUtils.isBlank(equipmentCodes)) {
throw new RuntimeException("设备编号不能为空");
}
String[] split = equipmentCodes.split("[,,]");
if(split.length == 0) {
throw new RuntimeException("设备编号格式错误");
}
List<String> equipmentCodeList = Arrays.stream(split).filter(StringUtils::isNotBlank).collect(Collectors.toList());
List<TEquipmentInfo> equipmentInfos = equipmentInfoMapper.getAllByEquipmentCodeList(equipmentCodeList);
if(equipmentInfos.size() == 0) {
throw new RuntimeException("设备不存在");
}
return equipmentInfos;
}
/**
* 批量断电
* @param equipmentInfos e
* @return r r
*/
private void powerOffToEquipments(List<TEquipmentInfo> equipmentInfos) {
// 收集所有异步任务
List<CompletableFuture<TEquipmentInfo>> futures = equipmentInfos.stream()
.map(equipmentInfo -> CompletableFuture.supplyAsync(() -> {
ModbusMaster master = null;
List<Integer> registerOffsets = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
try {
master = Modbus4jUtils.getMaster(equipmentInfo.getfPowerOutageIp(), equipmentInfo.getfPowerOutagePort());
for (Integer registerOffset : registerOffsets) {
Boolean aBoolean = Modbus4jUtils.readCoilStatus(master, 1, registerOffset);
if (aBoolean) {
Modbus4jUtils.writeCoil(master, 1, registerOffset, false);
}
}
} catch (ModbusInitException | ModbusTransportException | ErrorResponseException e) {
log.info("equipmentinfo -> ip = {} port = {}" + equipmentInfo.getfPowerOutageIp(), equipmentInfo.getfPowerOutagePort());
throw new RuntimeException(e);
} finally {
// 建议在这里关闭master连接,避免资源泄露
if (master != null) {
try {
master.destroy();
} catch (Exception e) {
// 处理关闭异常
}
}
}
return equipmentInfo;
}, executorService))
.collect(Collectors.toList());
// 等待所有异步任务完成
CompletableFuture<Void> allFutures = CompletableFuture.allOf(
futures.toArray(new CompletableFuture[0])
);
// 所有任务完成后执行数据库更新
allFutures.thenRun(() -> {
TStoreyInfo tStoreyInfo = new TStoreyInfo();
tStoreyInfo.setfStatus("0");
tStoreyInfo.setfAgingStartTime(null);
tStoreyInfoMapper.updateAllStatusAndAgingStartTime(tStoreyInfo);
}).join(); // 阻塞等待所有操作完成
}
/**
* 批量上电
* @return r r
*/
private void powerOnToEquipments(List<TEquipmentInfo> equipmentInfos) {
// 收集所有异步任务
List<CompletableFuture<TEquipmentInfo>> futures = equipmentInfos.stream()
.map(equipmentInfo -> CompletableFuture.supplyAsync(() -> {
ModbusMaster master = null;
List<Integer> registerOffsets = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
try {
master = Modbus4jUtils.getMaster(equipmentInfo.getfPowerOutageIp(), equipmentInfo.getfPowerOutagePort());
for (Integer registerOffset : registerOffsets) {
Boolean aBoolean = Modbus4jUtils.readCoilStatus(master, 1, registerOffset);
if (!aBoolean) {
Modbus4jUtils.writeCoil(master, 1, registerOffset, true);
}
}
} catch (ModbusInitException | ModbusTransportException | ErrorResponseException e) {
log.info("equipmentinfo -> ip = {} port = {}" + equipmentInfo.getfPowerOutageIp(), equipmentInfo.getfPowerOutagePort());
throw new RuntimeException(e);
} finally {
// 建议在这里关闭master连接,避免资源泄露
if (master != null) {
try {
master.destroy();
} catch (Exception e) {
// 处理关闭异常
}
}
}
return equipmentInfo;
}, executorService))
.collect(Collectors.toList());
// 等待所有异步任务完成
CompletableFuture<Void> allFutures = CompletableFuture.allOf(
futures.toArray(new CompletableFuture[0])
);
// 所有任务完成后执行数据库更新
allFutures.thenRun(() -> {
TStoreyInfo tStoreyInfo = new TStoreyInfo();
tStoreyInfo.setfStatus("1");
// 先不给 老化开始时间 只 上电
// tStoreyInfo.setfAgingStartTime(DateUtils.getNowDate());
tStoreyInfoMapper.updateAllStatusAndAgingStartTime(tStoreyInfo);
}).join(); // 阻塞等待所有操作完成
}
/** /**
* 更新南边指令 * 更新南边指令
*/ */
...@@ -193,58 +369,168 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService ...@@ -193,58 +369,168 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
return tStoreyInfoMapper.queryByDepartmentId(fEquipmentId); return tStoreyInfoMapper.queryByDepartmentId(fEquipmentId);
} }
public AjaxResult powerOffAllStore() { /**
* 批量扫描所有老化柜的层数据记录系统开始老化
* @return r
*/
@Override
public AjaxResult scanAndStartAgingAllCabinetLayers() {
List<String> types = Arrays.asList("1", "2"); List<TEquipmentInfo> equipmentInfos = equipmentInfoMapper.getAll();
List<TEquipmentInfo> equipmentInfos = equipmentInfoMapper.selectTEquipmentList(types);
if (equipmentInfos.size() == 0) { if (equipmentInfos.size() == 0) {
return AjaxResult.error("无设备信息!!!"); return AjaxResult.error("无设备信息!!!");
} }
// 收集所有异步任务 try {
List<CompletableFuture<TEquipmentInfo>> futures = equipmentInfos.stream() // 先清理所有定时任务和触发器
.map(equipmentInfo -> CompletableFuture.supplyAsync(() -> { Set<JobKey> jobKeys = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(JOB_GROUP));
ModbusMaster master = null; List<JobKey> jobKeysList = new ArrayList<>(jobKeys);
List<Integer> registerOffsets = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); // 清理触发器
try { Set<TriggerKey> triggerKeys = scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(TRIGGER_GROUP));
master = Modbus4jUtils.getMaster(equipmentInfo.getfPowerOutageIp(), equipmentInfo.getfPowerOutagePort()); List<TriggerKey> triggerKeysList = new ArrayList<>(triggerKeys);
scheduler.deleteJobs(jobKeysList);
scheduler.unscheduleJobs(triggerKeysList);
startScanAllCabinetLayers(equipmentInfos);
} catch (SchedulerException e) {
throw new RuntimeException(e);
}
for (Integer registerOffset : registerOffsets) { return null;
Boolean aBoolean = Modbus4jUtils.readCoilStatus(master, 1, registerOffset); }
if (aBoolean) {
Modbus4jUtils.writeCoil(master, 1, registerOffset, false); /**
} * 开始扫描所有老化柜的层数据记录系统开始老化
} */
} catch (ModbusInitException | ModbusTransportException | ErrorResponseException e) { private void startScanAllCabinetLayers(List<TEquipmentInfo> equipmentInfos) {
log.info("equipmentinfo -> ip = {} port = {}" + equipmentInfo.getfPowerOutageIp(), equipmentInfo.getfPowerOutagePort()); TEquipmentAlarmData alarmData = new TEquipmentAlarmData();
throw new RuntimeException(e); List<CompletableFuture<TEquipmentInfo>> futures = equipmentInfos.stream().map(equipmentInfo -> CompletableFuture.supplyAsync(() -> {
} finally { ModbusMaster master = null;
// 建议在这里关闭master连接,避免资源泄露 // 10 层
if (master != null) { List<Integer> registerOffsets = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
try { try {
master.destroy(); master = Modbus4jUtils.getMaster(equipmentInfo.getfIp(), equipmentInfo.getfPort());
} catch (Exception e) { Map<Integer, Object> integerObjectMap = Modbus4jUtils.batchReadAgingCabinetStatus(master, registerOffsets);
// 处理关闭异常
} equipmentInfo.setRegisterValues(integerObjectMap);
}
} catch (ModbusInitException e) {
// 记录异常数据
alarmData.setfAlarmType("01"); //01.老化柜 02.机械臂 03.老化层 04.点位
alarmData.setfEquipmentCode(equipmentInfo.getfEquipmentCode());
alarmData.setfAlarmData("定时任务巡检:Modbus初始化失败");
tEquipmentAlarmDataService.insertTEquipmentAlarmData(alarmData);
// 更新老化柜状态(“0”空闲,“1”运行,“2”故障)
equipmentInfo.setfStatus("2");
equipmentInfo.setErrorReason("定时任务巡检:Modbus初始化失败");
equipmentInfo.setRegisterValues(new HashMap<>());
// 返回结果
return equipmentInfo;
// 层有错误返回 柜可能连不上也在这个报错里面
} catch (ModbusTransportException e) {
// 网线没插好通讯不上
if (e.getMessage().equals("java.net.SocketTimeoutException: connect timed out")) {
// 记录异常数据
alarmData.setfAlarmType("01"); //01.老化柜 02.机械臂 03.老化层 04.点位
alarmData.setfEquipmentCode(equipmentInfo.getfEquipmentCode());
alarmData.setfAlarmData("定时任务巡检:老化柜网线没插好");
equipmentInfo.setErrorReason("定时任务巡检:老化柜网线没插好");
// 线接错误
} else {
// 记录异常数据
alarmData.setfAlarmType("01"); //01.老化柜 02.机械臂 03.老化层 04.点位
alarmData.setfEquipmentCode(equipmentInfo.getfEquipmentCode());
alarmData.setfAlarmData("定时任务巡检:老化柜通信线路没接好");
equipmentInfo.setErrorReason("定时任务巡检:老化柜通信线路没接好");
}
tEquipmentAlarmDataService.insertTEquipmentAlarmData(alarmData);
// 更新老化柜状态(“0”空闲,“1”运行,“2”故障)
equipmentInfo.setRegisterValues(new HashMap<>());
equipmentInfo.setfStatus("2");
return equipmentInfo;
} catch (ErrorResponseException e) {
equipmentInfo.setfStatus("2");
equipmentInfo.setRegisterValues(new HashMap<>());
equipmentInfo.setErrorReason("定时任务巡检:ErrorResponseException");
return equipmentInfo;
} finally {
if (master != null) {
master.destroy();
}
}
return equipmentInfo;
}, executor)).collect(Collectors.toList());
// 等待所有任务完成并收集结果
CompletableFuture<List<TEquipmentInfo>> listCompletableFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
.thenApply(v -> futures.stream()
.map(CompletableFuture::join)
.collect(Collectors.toList()));
// 处理 老化柜 是 运行 开始 空闲
CompletableFuture<List<TEquipmentInfo>> processedFuture = listCompletableFuture.thenApply(this::processDeviceData);
processedFuture.whenComplete((result, ex) -> {
tEquipmentInfoService.batchUpdate(result);
// 执行WebSocket广播,推送最新老化柜状态
// if (result != null && !result.isEmpty()) {
// agingCabinetWebSocketHandler.broadcastAgingCabinetData(result);
// log.info("已通过WebSocket广播{}条老化柜状态数据", result.size());
// }
});
}
// 处理 老化柜 是 运行 开始 空闲
private List<TEquipmentInfo> processDeviceData(List<TEquipmentInfo> deviceDataList) {
for (TEquipmentInfo modbusDeviceData : deviceDataList) {
Map<Integer, Object> registerValues = modbusDeviceData.getRegisterValues();
// 大于0 说明 柜能通信;小于0 说明柜 不能通信
if (registerValues.size() > 0) {
boolean isRun = false;
for (Map.Entry<Integer, Object> entry : registerValues.entrySet()) {
Integer registerOffset = entry.getKey();
Object registerValue = entry.getValue();
log.info("registerValue = " + registerValue);
log.info("true equals registerValue" + Boolean.TRUE.equals(registerValue));
if (Boolean.TRUE.equals(registerValue)) {
eventPublisher.publishEvent(new CheckPowerOnCommandEvent(
this,
modbusDeviceData.getfEquipmentCode(),
modbusDeviceData.getfPowerOutageIp(),
modbusDeviceData.getfPowerOutagePort(),
registerOffset + 1,
registerOffset
));
isRun = true;
} }
return equipmentInfo; }
}, executorService)) if (isRun) {
.collect(Collectors.toList()); modbusDeviceData.setfStatus("1");
} else {
modbusDeviceData.setfStatus("0");
}
} else {
modbusDeviceData.setfStatus("0");
}
}
return deviceDataList;
}
// 等待所有异步任务完成 /**
CompletableFuture<Void> allFutures = CompletableFuture.allOf( * 所有设备断电
futures.toArray(new CompletableFuture[0]) */
); public AjaxResult powerOffAllStore() {
// 所有任务完成后执行数据库更新 List<TEquipmentInfo> equipmentInfos = equipmentInfoMapper.getAll();
allFutures.thenRun(() -> {
TStoreyInfo tStoreyInfo = new TStoreyInfo(); if (equipmentInfos.size() == 0) {
tStoreyInfo.setfStatus("0"); return AjaxResult.error("无设备信息!!!");
tStoreyInfo.setfAgingStartTime(null); }
tStoreyInfoMapper.updateAllStatusAndAgingStartTime(tStoreyInfo);
}).join(); // 阻塞等待所有操作完成 // 批量处理
powerOffToEquipments(equipmentInfos);
return AjaxResult.success(); return AjaxResult.success();
} }
...@@ -308,49 +594,7 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService ...@@ -308,49 +594,7 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
return AjaxResult.error("无设备信息!!!"); return AjaxResult.error("无设备信息!!!");
} }
// 收集所有异步任务 powerOnToEquipments(equipmentInfos);
List<CompletableFuture<TEquipmentInfo>> futures = equipmentInfos.stream()
.map(equipmentInfo -> CompletableFuture.supplyAsync(() -> {
ModbusMaster master = null;
List<Integer> registerOffsets = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
try {
master = Modbus4jUtils.getMaster(equipmentInfo.getfPowerOutageIp(), equipmentInfo.getfPowerOutagePort());
for (Integer registerOffset : registerOffsets) {
Boolean aBoolean = Modbus4jUtils.readCoilStatus(master, 1, registerOffset);
if (!aBoolean) {
Modbus4jUtils.writeCoil(master, 1, registerOffset, true);
}
}
} catch (ModbusInitException | ModbusTransportException | ErrorResponseException e) {
log.info("equipmentinfo -> ip = {} port = {}" + equipmentInfo.getfPowerOutageIp(), equipmentInfo.getfPowerOutagePort());
throw new RuntimeException(e);
} finally {
// 建议在这里关闭master连接,避免资源泄露
if (master != null) {
try {
master.destroy();
} catch (Exception e) {
// 处理关闭异常
}
}
}
return equipmentInfo;
}, executorService))
.collect(Collectors.toList());
// 等待所有异步任务完成
CompletableFuture<Void> allFutures = CompletableFuture.allOf(
futures.toArray(new CompletableFuture[0])
);
// 所有任务完成后执行数据库更新
allFutures.thenRun(() -> {
TStoreyInfo tStoreyInfo = new TStoreyInfo();
tStoreyInfo.setfStatus("1");
tStoreyInfo.setfAgingStartTime(DateUtils.getNowDate());
tStoreyInfoMapper.updateAllStatusAndAgingStartTime(tStoreyInfo);
}).join(); // 阻塞等待所有操作完成
return AjaxResult.success(); return AjaxResult.success();
} }
...@@ -399,7 +643,7 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService ...@@ -399,7 +643,7 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
return AjaxResult.success(integerObjectMap); return AjaxResult.success(integerObjectMap);
} catch (ModbusInitException | ModbusTransportException | ErrorResponseException e) { } catch (ModbusInitException | ModbusTransportException | ErrorResponseException e) {
throw new RuntimeException(e); return AjaxResult.error("设备连接异常!!!");
} }
} }
......
...@@ -6,6 +6,7 @@ import com.zehong.system.task.DeviceCommJob.DeviceComm501Device2Job; ...@@ -6,6 +6,7 @@ import com.zehong.system.task.DeviceCommJob.DeviceComm501Device2Job;
import com.zehong.system.task.DeviceCommJob.DeviceComm501Device3Job; import com.zehong.system.task.DeviceCommJob.DeviceComm501Device3Job;
import org.quartz.*; import org.quartz.*;
import org.quartz.impl.matchers.GroupMatcher; import org.quartz.impl.matchers.GroupMatcher;
import org.quartz.utils.Key;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -15,7 +16,9 @@ import javax.annotation.Resource; ...@@ -15,7 +16,9 @@ import javax.annotation.Resource;
import java.time.Instant; import java.time.Instant;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
/** /**
* @author lenovo * @author lenovo
...@@ -30,9 +33,9 @@ public class DeviceTaskScheduler { ...@@ -30,9 +33,9 @@ public class DeviceTaskScheduler {
private Scheduler scheduler; private Scheduler scheduler;
// 任务组名(统一固定,与原有逻辑保持一致) // 任务组名(统一固定,与原有逻辑保持一致)
private static final String JOB_GROUP = "DEVICE_TASKS"; public static final String JOB_GROUP = "DEVICE_TASKS";
// 触发器组名(统一固定,与原有逻辑保持一致) // 触发器组名(统一固定,与原有逻辑保持一致)
private static final String TRIGGER_GROUP = "DEVICE_TRIGGERS"; public static final String TRIGGER_GROUP = "DEVICE_TRIGGERS";
// 新增:注入监控器 // 新增:注入监控器
@Autowired @Autowired
private QuartzTaskMonitor quartzTaskMonitor; private QuartzTaskMonitor quartzTaskMonitor;
...@@ -91,7 +94,6 @@ public class DeviceTaskScheduler { ...@@ -91,7 +94,6 @@ public class DeviceTaskScheduler {
log.info("清理现有任务: {}", jobKey.getName()); log.info("清理现有任务: {}", jobKey.getName());
} }
} }
// 清理触发器 // 清理触发器
Set<TriggerKey> triggerKeys = scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(TRIGGER_GROUP)); Set<TriggerKey> triggerKeys = scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(TRIGGER_GROUP));
for (TriggerKey triggerKey : triggerKeys) { for (TriggerKey triggerKey : triggerKeys) {
......
...@@ -63,6 +63,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -63,6 +63,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select count(1) from t_pallet_device_binding palDeviceBinding select count(1) from t_pallet_device_binding palDeviceBinding
where palDeviceBinding.f_tray_id = #{trayId} where palDeviceBinding.f_tray_id = #{trayId}
</select> </select>
<select id="countDeviceByTrayId" parameterType="long" resultType="int">
select count(1) from t_pallet_device_binding palDeviceBinding
where palDeviceBinding.f_tray_id = #{trayId}
and palDeviceBinding.f_device_code is not null
and palDeviceBinding.f_device_code != ''
</select>
<select id="selectPalletDeviceBindingList" parameterType="PalletDeviceBinding" resultMap="PalletDeviceBindingResult"> <select id="selectPalletDeviceBindingList" parameterType="PalletDeviceBinding" resultMap="PalletDeviceBindingResult">
<include refid="selectPalletDeviceBindingVo"/> <include refid="selectPalletDeviceBindingVo"/>
<where> <where>
......
...@@ -19,10 +19,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -19,10 +19,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectTEquipmentAlarmDataList" parameterType="TEquipmentAlarmData" resultMap="TEquipmentAlarmDataResult"> <select id="selectTEquipmentAlarmDataList" parameterType="TEquipmentAlarmData" resultMap="TEquipmentAlarmDataResult">
<include refid="selectTEquipmentAlarmDataVo"/> <include refid="selectTEquipmentAlarmDataVo"/>
<where> <where>
<if test="fEquipmentCode != null and fEquipmentCode != ''"> and f_equipment_code = #{fEquipmentCode}</if> <if test="fEquipmentCode != null and fEquipmentCode != ''"> and f_equipment_code like concat ('%',#{fEquipmentCode},'%')</if>
<if test="fAlarmType != null and fAlarmType != ''"> and f_alarm_type = #{fAlarmType}</if> <if test="fAlarmData != null and fAlarmData != ''"> and f_alarm_data like concat ('%', #{fAlarmData},'%')</if>
<if test="fAlarmData != null and fAlarmData != ''"> and f_alarm_data = #{fAlarmData}</if>
<if test="fCreateTime != null "> and f_create_time = #{fCreateTime}</if>
</where> </where>
</select> </select>
......
...@@ -61,7 +61,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -61,7 +61,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item} #{item}
</foreach> </foreach>
</select> </select>
<select id="getAll" resultMap="TEquipmentInfoResult">
<include refid="selectTEquipmentInfoVo"/>
</select>
<select id="getAllByEquipmentCodeList" parameterType="list" resultMap="TEquipmentInfoResult">
<include refid="selectTEquipmentInfoVo"/>
where f_equipment_code in
<foreach item="item" collection="equipmentCodes" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectTEquipmentInfoById" parameterType="Long" resultMap="TEquipmentInfoResult"> <select id="selectTEquipmentInfoById" parameterType="Long" resultMap="TEquipmentInfoResult">
<include refid="selectTEquipmentInfoVo"/> <include refid="selectTEquipmentInfoVo"/>
where f_equipment_id = #{fEquipmentId} where f_equipment_id = #{fEquipmentId}
......
...@@ -3,51 +3,8 @@ import request from '@/utils/request' ...@@ -3,51 +3,8 @@ import request from '@/utils/request'
// 查询生产设备报警信息列表 // 查询生产设备报警信息列表
export function listEquipmentAlarmData(query) { export function listEquipmentAlarmData(query) {
return request({ return request({
url: '/equipmentAlarmData/equipmentAlarmData/list', url: '/equipmentAlarmData/record/list',
method: 'get', method: 'get',
params: query params: query
}) })
} }
// 查询生产设备报警信息详细
export function getEquipmentAlarmData(fEquipmentAlarmDataId) {
return request({
url: '/equipmentAlarmData/equipmentAlarmData/' + fEquipmentAlarmDataId,
method: 'get'
})
}
// 新增生产设备报警信息
export function addEquipmentAlarmData(data) {
return request({
url: '/equipmentAlarmData/equipmentAlarmData',
method: 'post',
data: data
})
}
// 修改生产设备报警信息
export function updateEquipmentAlarmData(data) {
return request({
url: '/equipmentAlarmData/equipmentAlarmData',
method: 'put',
data: data
})
}
// 删除生产设备报警信息
export function delEquipmentAlarmData(fEquipmentAlarmDataId) {
return request({
url: '/equipmentAlarmData/equipmentAlarmData/' + fEquipmentAlarmDataId,
method: 'delete'
})
}
// 导出生产设备报警信息
export function exportEquipmentAlarmData(query) {
return request({
url: '/equipmentAlarmData/equipmentAlarmData/export',
method: 'get',
params: query
})
}
\ No newline at end of file
...@@ -109,6 +109,18 @@ export function powerOnAllStore() { ...@@ -109,6 +109,18 @@ export function powerOnAllStore() {
method: 'get' method: 'get'
}) })
} }
export function designatedDevicePowerOn(equipmentCode) {
return request({
url: '/storey/designatedDevicePowerOn/' + equipmentCode,
method: 'get'
})
}
export function designatedDevicePowerOff(equipmentCode) {
return request({
url: '/storey/designatedDevicePowerOff/' + equipmentCode,
method: 'get'
})
}
export function powerOffAllStore() { export function powerOffAllStore() {
return request({ return request({
...@@ -116,3 +128,10 @@ export function powerOffAllStore() { ...@@ -116,3 +128,10 @@ export function powerOffAllStore() {
method: 'get' method: 'get'
}) })
} }
export function scanAndStartAgingAllCabinetLayers() {
return request({
url: '/storey/scanAndStartAgingAllCabinetLayers',
method: 'get'
})
}
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="120px">
<el-form-item label="报警设备编号" prop="fEquipmentCode">
<el-input
v-model="queryParams.fEquipmentCode"
placeholder="请输入报警设备编号"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="equipmentAlarmDataList" @selection-change="handleSelectionChange">
<el-table-column label="报警设备编号" align="center" prop="fEquipmentCode" />
<el-table-column label="报警数据" align="center" prop="fAlarmData" />
<el-table-column label="创建时间" align="center" prop="fCreateTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.fCreateTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
</template>
<script>
import { listEquipmentAlarmData } from "@/api/equipmentAlarmData/equipmentAlarmData";
export default {
name: "EquipmentAlarmData",
components: {
},
data() {
return {
// 遮罩层
loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 生产设备报警信息表格数据
equipmentAlarmDataList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
fAlarmCode: null,
fAlarmType: null,
fAlarmData: null,
fCreateTime: null
},
// 表单参数
form: {},
// 表单校验
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询生产设备报警信息列表 */
getList() {
this.loading = true;
listEquipmentAlarmData(this.queryParams).then(response => {
this.equipmentAlarmDataList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
fEquipmentAlarmDataId: null,
fAlarmCode: null,
fAlarmType: null,
fAlarmData: null,
fCreateTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.fEquipmentAlarmDataId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加生产设备报警信息";
}
}
};
</script>
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
</el-table-column> </el-table-column>
<el-table-column label="行" prop="row" align="center" width="80" /> <el-table-column label="行" prop="row" align="center" width="80" />
<el-table-column label="列" prop="col" align="center" width="80" /> <el-table-column label="列" prop="col" align="center" width="80" />
<el-table-column label="位置编号" prop="number" align="center" width="80" /> <el-table-column label="位置编号" prop="number" align="center" width="150" />
<el-table-column label="绑定时间" align="center" width="150"> <el-table-column label="绑定时间" align="center" width="150">
<template slot-scope="scope"> <template slot-scope="scope">
<div class="binding-time">{{ scope.row.bindingTime ? formatDate(scope.row.bindingTime) : '-' }}</div> <div class="binding-time">{{ scope.row.bindingTime ? formatDate(scope.row.bindingTime) : '-' }}</div>
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<div class="priority-control"> <div class="priority-control">
<div class="priority-display">{{ priorityDisplayText }}</div> <div class="priority-display">{{ priorityDisplayText }}</div>
<button class="priority-toggle-btn" @click="togglePriority"> <button class="priority-toggle-btn" @click="togglePriority">
{{ priorityToggleText }} <!-- {{ priorityToggleText }}-->点击切换
</button> </button>
</div> </div>
......
...@@ -50,47 +50,12 @@ ...@@ -50,47 +50,12 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading" :loading="exportLoading"
@click="handleExport" @click="handleExport"
>导出</el-button> >导出</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-reading"
size="mini"
@click="handleReading"
>批量读取设备状态</el-button>
</el-col>
<el-col :span="1.5"> <!-- 移除的功能按钮 -->
<el-button
type="info"
plain
icon="el-icon-reading"
size="mini"
@click="handleHoldingRegister"
>测试501端口</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-circle-plus"
size="mini"
@click="handleAllPowerOn"
>所有设备上电</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-remove"
size="mini"
@click="handleAllPowerOff"
>所有设备断电</el-button>
</el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
...@@ -111,15 +76,7 @@ ...@@ -111,15 +76,7 @@
@click="handleStop" @click="handleStop"
>机械臂停止</el-button> >机械臂停止</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-circle-close"
size="mini"
@click="handleWriteHour"
>写时间测试</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
...@@ -181,12 +138,12 @@ ...@@ -181,12 +138,12 @@
@click="handlePowerOutage(scope.row)" @click="handlePowerOutage(scope.row)"
>断电</el-button> >断电</el-button>
<el-button <!-- <el-button-->
size="mini" <!-- size="mini"-->
type="text" <!-- type="text"-->
icon="el-icon-delete" <!-- icon="el-icon-delete"-->
@click="handleFeeding(scope.row)" <!-- @click="handleFeeding(scope.row)"-->
>上料</el-button> <!-- >上料</el-button>-->
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
...@@ -256,9 +213,8 @@ ...@@ -256,9 +213,8 @@
<script> <script>
import { listStorey, getStorey, delStorey, addStorey, updateStorey, import { listStorey, getStorey, delStorey, addStorey, updateStorey,
exportStorey,PowerOn,PowerOutage , exportStorey,PowerOn,PowerOutage ,
batchReadingCabinetStatus,powerOnAllStore,powerOffAllStore, feeding, blanking} from "@/api/storey/storey";
feeding, blanking,readingHoldingRegister} from "@/api/storey/storey"; import {sendHomeCommand, sendStopCommand} from "@/api/robotArm/robotArmCommand";
import {sendHomeCommand, sendStopCommand,sendWriteHour} from "@/api/robotArm/robotArmCommand";
export default { export default {
name: "Info", name: "Info",
...@@ -467,65 +423,14 @@ export default { ...@@ -467,65 +423,14 @@ export default {
handleDelete(row) { handleDelete(row) {
const fStoreyIds = row.fStoreyId || this.ids; const fStoreyIds = row.fStoreyId || this.ids;
this.$confirm('是否确认删除柜层信息编号为"' + fStoreyIds + '"的数据项?', "警告", { this.$confirm('是否确认删除柜层信息编号为"' + fStoreyIds + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delStorey(fStoreyIds);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(() => {});
},
// 测试 某个设备的 501,502,503端口号
handleHoldingRegister() {
this.$prompt('请输入ip加端口号 逗号分隔', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
}).then(({ value }) => {
readingHoldingRegister(value).then(response => {
if(response.code === 200) {
this.msgSuccess("msg = " + response.data);
}
})
}).catch(() => {
});
},
handleReading() {
this.$prompt('请输入老化柜编号', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
}).then(({ value }) => {
batchReadingCabinetStatus(value).then(response => {
if(response.code === 200) {
this.msgSuccess("msg = " + response.data);
}
})
}).catch(() => {
});
},
handleAllPowerOff() {
this.$confirm('是否确认给所有设备断电?', "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function() { }).then(function() {
return powerOffAllStore(); return delStorey(fStoreyIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("断电成功"); this.msgSuccess("删除成功");
}).catch(() => {});
},
handleAllPowerOn() {
this.$confirm('是否确认给所有设备上电?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return powerOnAllStore();
}).then(() => {
this.getList();
this.msgSuccess("上电成功");
}).catch(() => {}); }).catch(() => {});
}, },
...@@ -536,20 +441,6 @@ export default { ...@@ -536,20 +441,6 @@ export default {
}) })
}, },
/** 写时钟 */
handleWriteHour() {
this.$prompt('请输入ip加端口号 逗号分隔', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
}).then(({ value }) => {
sendWriteHour(value).then(response => {
if(response.code === 200) {
this.msgSuccess("msg = " + response.data);
}
})
}).catch(() => {
});
},
// 停止 // 停止
handleStop() { handleStop() {
sendStopCommand().then( response => { sendStopCommand().then( response => {
...@@ -560,16 +451,16 @@ export default { ...@@ -560,16 +451,16 @@ export default {
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$confirm('是否确认导出所有柜层信息数据项?', "警告", { this.$confirm('是否确认导出所有柜层信息数据项?', "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(() => { }).then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportStorey(queryParams); return exportStorey(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.download(response.msg);
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => {});
} }
} }
}; };
......
<template> <template>
<div class="app-container"> <div class="app-container">
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="primary"-->
<!-- plain-->
<!-- size="mini"-->
<!-- @click="testAgingCabinetAndPowerCheck"-->
<!-- >测试老化柜状态获取-->
<!-- </el-button>-->
<!-- </el-col>-->
<!-- 新增的批量操作按钮 -->
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="primary" type="info"
plain plain
icon="el-icon-reading"
size="mini" size="mini"
@click="testAgingCabinetAndPowerCheck" @click="handleReading"
>测试老化柜状态获取 >批量读取设备状态</el-button>
</el-button> </el-col>
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="info"-->
<!-- plain-->
<!-- icon="el-icon-reading"-->
<!-- size="mini"-->
<!-- @click="handleHoldingRegister"-->
<!-- >测试501端口</el-button>-->
<!-- </el-col>-->
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-circle-close"
size="mini"
@click="handleWriteHour"
>写时间测试</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-circle-check"
size="mini"
@click="handleScanAndStartAgingAllCabinetLayers"
>扫描并老化</el-button>
</el-col>
</el-row>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-circle-plus"
size="mini"
@click="handleAllPowerOn"
>所有设备上电</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-circle-plus"
size="mini"
@click="handleDesignatedDevicePowerOn"
>指定设备上电</el-button>
</el-col>
</el-row>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-remove"
size="mini"
@click="handleAllPowerOff"
>所有设备断电</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-remove"
size="mini"
@click="handleDesignatedDevicePowerOff"
>指定设备断电</el-button>
</el-col> </el-col>
</el-row> </el-row>
<el-input <el-input
type="textarea" type="textarea"
:rows="25" :rows="15"
placeholder="返回内容信息" placeholder="返回内容信息"
v-model="textarea"> v-model="textarea">
</el-input> </el-input>
...@@ -21,8 +99,12 @@ ...@@ -21,8 +99,12 @@
</template> </template>
<script> <script>
import {getAgingCabinetAndPowerCheck} from "@/api/testScheduledTasks/testTasks"; import {getAgingCabinetAndPowerCheck} from "@/api/testScheduledTasks/testTasks";
import {
batchReadingCabinetStatus, readingHoldingRegister, powerOnAllStore, powerOffAllStore,
scanAndStartAgingAllCabinetLayers, designatedDevicePowerOn, designatedDevicePowerOff
} from "@/api/storey/storey";
import {sendWriteHour} from "@/api/robotArm/robotArmCommand";
export default { export default {
name: "TestScheduledTasks", name: "TestScheduledTasks",
...@@ -36,7 +118,7 @@ export default { ...@@ -36,7 +118,7 @@ export default {
methods: { methods: {
testAgingCabinetAndPowerCheck() { testAgingCabinetAndPowerCheck() {
getAgingCabinetAndPowerCheck().then(response => { getAgingCabinetAndPowerCheck().then(response => {
this.textarea = ""; this.textarea = "";
if (response.length > 0) { if (response.length > 0) {
for (let i = 0; i < response.length; i++) { for (let i = 0; i < response.length; i++) {
let item = response[i]; let item = response[i];
...@@ -51,6 +133,113 @@ export default { ...@@ -51,6 +133,113 @@ export default {
} }
} }
); );
},
// 从原组件提取的功能方法
handleReading() {
this.$prompt('请输入老化柜编号', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
}).then(({ value }) => {
batchReadingCabinetStatus(value).then(response => {
if(response.code === 200) {
this.textarea = "批量读取设备状态成功:" + response.data;
this.$message.success("读取成功");
}
})
}).catch(() => {});
},
handleHoldingRegister() {
this.$prompt('请输入ip加端口号 逗号分隔', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
}).then(({ value }) => {
readingHoldingRegister(value).then(response => {
if(response.code === 200) {
this.textarea = "测试501端口成功:" + response.data;
this.$message.success("测试成功");
}
})
}).catch(() => {});
},
handleAllPowerOn() {
this.$confirm('是否确认给所有设备上电?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return powerOnAllStore();
}).then(() => {
this.textarea = "所有设备上电操作执行成功";
this.$message.success("上电成功");
}).catch(() => {});
},
handleDesignatedDevicePowerOff() {
this.$prompt('请输入需要断电的柜子设备编号北1-15,南16-30,英文逗号分隔', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
}).then(({ value }) => {
designatedDevicePowerOff(value).then(response => {
if(response.code === 200) {
this.textarea = "指定设备已断电成功:" + response.data;
this.$message.success("指定设备已断电成功");
}
})
}).catch(() => {});
},
handleDesignatedDevicePowerOn() {
this.$prompt('请输入需要上电的柜子设备编号北1-15,南16-30,英文逗号分隔', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
}).then(({ value }) => {
designatedDevicePowerOn(value).then(response => {
if(response.code === 200) {
this.textarea = "指定设备已上电成功:" + response.data;
this.$message.success("指定设备已上电成功");
}
})
}).catch(() => {});
},
handleAllPowerOff() {
this.$confirm('是否确认给所有设备断电?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return powerOffAllStore();
}).then(() => {
this.textarea = "所有设备断电操作执行成功";
this.$message.success("断电成功");
}).catch(() => {});
},
// 扫描并老化
handleScanAndStartAgingAllCabinetLayers() {
this.$confirm('警示:此操作将清理所有已存在的任务并重新扫描所有老化柜的层信息去生成任务,确认操作请点击确定!!!', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return scanAndStartAgingAllCabinetLayers();
}).then(() => {
this.$message.success("我想好了");
}).catch(() => {});
},
handleWriteHour() {
this.$prompt('请输入ip加端口号 逗号分隔', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
}).then(({ value }) => {
sendWriteHour(value).then(response => {
if(response.code === 200) {
this.textarea = "写时间测试成功:" + response.data;
this.$message.success("写时间成功");
}
})
}).catch(() => {});
} }
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment