Commit 9d7953d8 authored by wanghao's avatar wanghao

1 接收标定数据后只更新实时数据,一键解绑后 去 记录 历史数据 和 上传MES调整,上传失败后记录失败记录。可再次上传。

2 解绑完成时 形成  历史数据 和 上传MES失败记录 两份数据及界面展示 调整。
3 老化过程中 读取设备数据,如果没读到数据 记录 通信异常。
parent 315e3959
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.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.PalletDeviceUploadFailure;
import com.zehong.system.service.IPalletDeviceUploadFailureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 上传失败历史记录Controller
*
* @author zehong
* @date 2026-01-16
*/
@RestController
@RequestMapping("/palletDevice/binding/failure")
public class PalletDeviceUploadFailureController extends BaseController
{
@Autowired
private IPalletDeviceUploadFailureService palletDeviceUploadFailureService;
/**
* 查询上传失败历史记录列表
*/
@GetMapping("/list")
public TableDataInfo list(PalletDeviceUploadFailure palletDeviceUploadFailure)
{
startPage();
List<PalletDeviceUploadFailure> list = palletDeviceUploadFailureService.selectPalletDeviceUploadFailureList(palletDeviceUploadFailure);
return getDataTable(list);
}
/**
* 重新上传
*/
@GetMapping("/handleReUpload")
public AjaxResult handleReUpload(){
return palletDeviceUploadFailureService.handleReUpload();
}
/**
* 导出上传失败历史记录列表
*/
@GetMapping("/export")
public AjaxResult export(PalletDeviceUploadFailure palletDeviceUploadFailure)
{
List<PalletDeviceUploadFailure> list = palletDeviceUploadFailureService.selectPalletDeviceUploadFailureList(palletDeviceUploadFailure);
ExcelUtil<PalletDeviceUploadFailure> util = new ExcelUtil<PalletDeviceUploadFailure>(PalletDeviceUploadFailure.class);
return util.exportExcel(list, "上传失败历史记录数据");
}
/**
* 获取上传失败历史记录详细信息
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(palletDeviceUploadFailureService.selectPalletDeviceUploadFailureById(id));
}
/**
* 新增上传失败历史记录
*/
@PostMapping
public AjaxResult add(@RequestBody PalletDeviceUploadFailure palletDeviceUploadFailure)
{
return toAjax(palletDeviceUploadFailureService.insertPalletDeviceUploadFailure(palletDeviceUploadFailure));
}
/**
* 修改上传失败历史记录
*/
@PutMapping
public AjaxResult edit(@RequestBody PalletDeviceUploadFailure palletDeviceUploadFailure)
{
return toAjax(palletDeviceUploadFailureService.updatePalletDeviceUploadFailure(palletDeviceUploadFailure));
}
/**
* 删除上传失败历史记录
*/
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(palletDeviceUploadFailureService.deletePalletDeviceUploadFailureByIds(ids));
}
}
......@@ -13,7 +13,7 @@ import java.util.List;
/**
* 未上传成功的历史数据列Controller
*
*
* @author zehong
* @date 2025-11-24
*/
......@@ -64,14 +64,6 @@ public class PalletDeviceUploadHistoryController extends BaseController
return toAjax(palletDeviceUploadHistoryService.insertPalletDeviceUploadHistory(palletDeviceUploadHistory));
}
/**
* 重新上传
*/
@GetMapping("/handleReUpload")
public AjaxResult handleReUpload(){
return palletDeviceUploadHistoryService.handleReUpload();
}
/**
* 修改未上传成功的历史数据列
*/
......
......@@ -33,7 +33,7 @@ public class PalletDeviceBinding extends BaseEntity
private String storeyCode;
/** 绑定的设备编号 */
@Excel(name = "绑定的设备编号")
private String deviceCode;
private String motherboardCode;
/** 行 */
@Excel(name = "行")
......@@ -64,9 +64,9 @@ public class PalletDeviceBinding extends BaseEntity
private Date unbindingTime;
/**
* 状态 0-预热;1-正常;3-传感器故障;4-报警;5-通讯故障
* 状态 0-预热;1-正常;3-传感器故障;4-报警;5-通讯故障;-9999 通讯异常
*/
private String status;
private String deviceStatus;
/**
* modbus 通信设置时间 年
......@@ -180,12 +180,24 @@ public class PalletDeviceBinding extends BaseEntity
*/
private Integer networkStatus;
public String getStatus() {
return status;
/**
* 解绑状态 (0:否, 1:是)
*/
private String calibrationUnbindStatus;
/**
* 第一个解绑的设备编号
* 这个字段就是为了区分第一个解绑的设备编号标志,如果是的话,则 需要存 历史,上传MES,生成 标检 质检 等。
* 1 是 0 不是
*/
private String firstUnboundDeviceFlag;
public String getDeviceStatus() {
return deviceStatus;
}
public void setStatus(String status) {
this.status = status;
public void setDeviceStatus(String deviceStatus) {
this.deviceStatus = deviceStatus;
}
public void setPalletDeviceBindingId(Long palletDeviceBindingId)
......@@ -206,15 +218,15 @@ public class PalletDeviceBinding extends BaseEntity
{
return trayId;
}
public void setDeviceCode(String deviceCode)
{
this.deviceCode = deviceCode;
public String getMotherboardCode() {
return motherboardCode;
}
public String getDeviceCode()
{
return deviceCode;
public void setMotherboardCode(String motherboardCode) {
this.motherboardCode = motherboardCode;
}
public void setRow(Integer row)
{
this.row = row;
......@@ -460,6 +472,22 @@ public class PalletDeviceBinding extends BaseEntity
this.storeyCode = storeyCode;
}
public String getFirstUnboundDeviceFlag() {
return firstUnboundDeviceFlag;
}
public void setFirstUnboundDeviceFlag(String firstUnboundDeviceFlag) {
this.firstUnboundDeviceFlag = firstUnboundDeviceFlag;
}
public String getCalibrationUnbindStatus() {
return calibrationUnbindStatus;
}
public void setCalibrationUnbindStatus(String calibrationUnbindStatus) {
this.calibrationUnbindStatus = calibrationUnbindStatus;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
......@@ -467,14 +495,14 @@ public class PalletDeviceBinding extends BaseEntity
.append("trayId", getTrayId())
.append("storeyCode", getStoreyCode())
.append("fTrayCode", getfTrayCode())
.append("deviceCode", getDeviceCode())
.append("motherboardCode", getMotherboardCode())
.append("row", getRow())
.append("col", getCol())
.append("index", getIndex())
.append("number", getNumber())
.append("bindingTime", getBindingTime())
.append("unbindingTime", getUnbindingTime())
.append("status", getStatus())
.append("deviceStatus", getDeviceStatus())
.append("recordYear", getRecordYear())
.append("recordMonth", getRecordMonth())
.append("recordDate", getRecordDate())
......@@ -501,6 +529,7 @@ public class PalletDeviceBinding extends BaseEntity
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.append("calibrationUnbindStatus", getCalibrationUnbindStatus())
.toString();
}
}
......@@ -33,7 +33,7 @@ public class PalletDeviceUploadHistory extends BaseEntity
/** 绑定的设备编号 */
@Excel(name = "设备编号")
private String deviceCode;
private String motherboardCode;
/** 行 */
@Excel(name = "行")
......@@ -58,12 +58,11 @@ public class PalletDeviceUploadHistory extends BaseEntity
/** 解绑时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "解绑时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date unbindingTime;
/** 0-预热;1-正常;3-传感器故障;4-报警;5-通讯故障 */
/** 0-预热;1-正常;3-传感器故障;4-报警;5-通讯故障 ;-9999-通讯异常*/
@Excel(name = "状态")
private String status;
private String deviceStatus;
/** 设置-年 */
@Excel(name = "设置-年")
......@@ -103,7 +102,7 @@ public class PalletDeviceUploadHistory extends BaseEntity
/** 合格;不合格 */
@Excel(name = "标定状态0-不合格;1-合格")
private String calibrationStatus;
private String calibrationAdStatus;
/** 浓度值 */
@Excel(name = "浓度值")
......@@ -119,7 +118,7 @@ public class PalletDeviceUploadHistory extends BaseEntity
/** 实时AD状态;0-异常;1-正常 */
@Excel(name = "实时AD状态;0-异常;1-正常 ")
private String realTimeAdStatus;
private String realTimeStatus;
/**
* 传感器校准浓度
......@@ -187,14 +186,13 @@ public class PalletDeviceUploadHistory extends BaseEntity
{
return trayId;
}
public void setDeviceCode(String deviceCode)
{
this.deviceCode = deviceCode;
public String getMotherboardCode() {
return motherboardCode;
}
public String getDeviceCode()
{
return deviceCode;
public void setMotherboardCode(String motherboardCode) {
this.motherboardCode = motherboardCode;
}
public void setRow(Integer row)
{
......@@ -250,15 +248,15 @@ public class PalletDeviceUploadHistory extends BaseEntity
{
return unbindingTime;
}
public void setStatus(String status)
{
this.status = status;
public String getDeviceStatus() {
return deviceStatus;
}
public String getStatus()
{
return status;
public void setDeviceStatus(String deviceStatus) {
this.deviceStatus = deviceStatus;
}
public void setRecordYear(String recordYear)
{
this.recordYear = recordYear;
......@@ -340,15 +338,15 @@ public class PalletDeviceUploadHistory extends BaseEntity
{
return calibrationAd;
}
public void setCalibrationStatus(String calibrationStatus)
{
this.calibrationStatus = calibrationStatus;
public String getCalibrationAdStatus() {
return calibrationAdStatus;
}
public String getCalibrationStatus()
{
return calibrationStatus;
public void setCalibrationAdStatus(String calibrationAdStatus) {
this.calibrationAdStatus = calibrationAdStatus;
}
public void setConcentration(String concentration)
{
this.concentration = concentration;
......@@ -376,14 +374,13 @@ public class PalletDeviceUploadHistory extends BaseEntity
{
return realTimeAd;
}
public void setRealTimeAdStatus(String realTimeAdStatus)
{
this.realTimeAdStatus = realTimeAdStatus;
public String getRealTimeStatus() {
return realTimeStatus;
}
public String getRealTimeAdStatus()
{
return realTimeAdStatus;
public void setRealTimeStatus(String realTimeStatus) {
this.realTimeStatus = realTimeStatus;
}
public String getTrayCode() {
......@@ -473,14 +470,14 @@ public class PalletDeviceUploadHistory extends BaseEntity
", trayId=" + trayId +
", storeyCode=" + storeyCode +
", trayCode='" + trayCode + '\'' +
", deviceCode='" + deviceCode + '\'' +
", motherboardCode='" + motherboardCode + '\'' +
", row=" + row +
", col=" + col +
", index=" + index +
", number=" + number +
", bindingTime=" + bindingTime +
", unbindingTime=" + unbindingTime +
", status='" + status + '\'' +
", deviceStatus='" + deviceStatus + '\'' +
", recordYear='" + recordYear + '\'' +
", recordMonth='" + recordMonth + '\'' +
", recordDate='" + recordDate + '\'' +
......@@ -490,11 +487,11 @@ public class PalletDeviceUploadHistory extends BaseEntity
", adjustmentZeroAd='" + adjustmentZeroAd + '\'' +
", zeroStatus='" + zeroStatus + '\'' +
", calibrationAd='" + calibrationAd + '\'' +
", calibrationStatus='" + calibrationStatus + '\'' +
", calibrationAdStatus='" + calibrationAdStatus + '\'' +
", concentration='" + concentration + '\'' +
", runTimeStatus='" + runTimeStatus + '\'' +
", realTimeAd=" + realTimeAd +
", realTimeAdStatus='" + realTimeAdStatus + '\'' +
", realTimeStatus='" + realTimeStatus + '\'' +
", calibrationConcentration=" + calibrationConcentration +
", calibrationConcentrationStatus='" + calibrationConcentrationStatus + '\'' +
", writeSelfCheckStatus=" + writeSelfCheckStatus +
......
......@@ -48,6 +48,8 @@ public interface PalletDeviceBindingMapper
public int countDeviceByTrayId(Long trayId);
public List<PalletDeviceBinding> listByTrayId(Long trayId);
/**
* 新增托盘绑定的设备列
*
......@@ -72,6 +74,8 @@ public interface PalletDeviceBindingMapper
public int unbindDevice(Long palletDeviceBindingId);
public int unbindDeviceByCalibrationUnbindStatus(Long palletDeviceBindingId);
public int resetAll(Long trayId);
public int batchUpdateDeviceCode(@Param("palletDeviceBindingList") List<PalletDeviceBinding> palletDeviceBindingList);
......
package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.PalletDeviceBinding;
import com.zehong.system.domain.PalletDeviceUploadFailure;
import com.zehong.system.domain.PalletDeviceUploadHistory;
/**
* 上传失败历史记录Mapper接口
*
* @author zehong
* @date 2026-01-16
*/
public interface PalletDeviceUploadFailureMapper
{
/**
* 查询上传失败历史记录
*
* @param id 上传失败历史记录ID
* @return 上传失败历史记录
*/
public PalletDeviceUploadFailure selectPalletDeviceUploadFailureById(Long id);
public int batchInsert(List<PalletDeviceUploadFailure> list);
public int batchInsertRealTimeData(List<PalletDeviceBinding> list);
/**
* 查询上传失败历史记录列表
*
* @param palletDeviceUploadFailure 上传失败历史记录
* @return 上传失败历史记录集合
*/
public List<PalletDeviceUploadFailure> selectPalletDeviceUploadFailureList(PalletDeviceUploadFailure palletDeviceUploadFailure);
/**
* 新增上传失败历史记录
*
* @param palletDeviceUploadFailure 上传失败历史记录
* @return 结果
*/
public int insertPalletDeviceUploadFailure(PalletDeviceUploadFailure palletDeviceUploadFailure);
/**
* 修改上传失败历史记录
*
* @param palletDeviceUploadFailure 上传失败历史记录
* @return 结果
*/
public int updatePalletDeviceUploadFailure(PalletDeviceUploadFailure palletDeviceUploadFailure);
/**
* 删除上传失败历史记录
*
* @param id 上传失败历史记录ID
* @return 结果
*/
public int deletePalletDeviceUploadFailureById(Long id);
/**
* 批量删除上传失败历史记录
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deletePalletDeviceUploadFailureByIds(Long[] ids);
}
package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.PalletDeviceBinding;
import com.zehong.system.domain.PalletDeviceUploadHistory;
/**
* 未上传成功的历史数据列Mapper接口
*
*
* @author zehong
* @date 2025-11-24
*/
public interface PalletDeviceUploadHistoryMapper
public interface PalletDeviceUploadHistoryMapper
{
/**
* 查询未上传成功的历史数据列
*
*
* @param id 未上传成功的历史数据列ID
* @return 未上传成功的历史数据列
*/
......@@ -21,7 +23,7 @@ public interface PalletDeviceUploadHistoryMapper
/**
* 查询未上传成功的历史数据列列表
*
*
* @param palletDeviceUploadHistory 未上传成功的历史数据列
* @return 未上传成功的历史数据列集合
*/
......@@ -29,7 +31,7 @@ public interface PalletDeviceUploadHistoryMapper
/**
* 新增未上传成功的历史数据列
*
*
* @param palletDeviceUploadHistory 未上传成功的历史数据列
* @return 结果
*/
......@@ -37,9 +39,11 @@ public interface PalletDeviceUploadHistoryMapper
public int batchInsert(List<PalletDeviceUploadHistory> list);
public int batchInsertRealTimeData(List<PalletDeviceBinding> list);
/**
* 修改未上传成功的历史数据列
*
*
* @param palletDeviceUploadHistory 未上传成功的历史数据列
* @return 结果
*/
......@@ -47,7 +51,7 @@ public interface PalletDeviceUploadHistoryMapper
/**
* 删除未上传成功的历史数据列
*
*
* @param id 未上传成功的历史数据列ID
* @return 结果
*/
......@@ -55,7 +59,7 @@ public interface PalletDeviceUploadHistoryMapper
/**
* 批量删除未上传成功的历史数据列
*
*
* @param ids 需要删除的数据ID
* @return 结果
*/
......
......@@ -127,7 +127,7 @@ public class ModbusResultHandler implements Consumer<DeviceStatusReaderDto> {
// 4. 校验数据长度并处理
if (data.length >= 2) {
// 更新设备状态
palletDeviceBinding.setStatus(String.valueOf(data[1]));
palletDeviceBinding.setDeviceStatus(String.valueOf(data[1]));
// 校验状态是否允许写时间
if (data[1] == 1 || data[1] == 3 || data[1] == 4) {
......@@ -143,16 +143,16 @@ public class ModbusResultHandler implements Consumer<DeviceStatusReaderDto> {
} catch (ModbusInitException e) {
log.error("Modbus初始化异常:ip={}, port={}", ip, port, e);
palletDeviceBinding.setStatus("5");
palletDeviceBinding.setDeviceStatus("5");
recordAlarm(palletDeviceBinding, "Modbus初始化失败:" + e.getMessage());
} catch (ModbusTransportException e) {
log.error("Modbus传输异常:ip={}, port={}, deviceId={}", ip, port, deviceId, e);
palletDeviceBinding.setStatus("5");
palletDeviceBinding.setDeviceStatus("5");
recordAlarm(palletDeviceBinding, "Modbus写时间失败:" + e.getMessage());
} catch (Exception e) {
// 捕获其他异常(如NPE、数据溢出)
log.error("处理Modbus数据异常:ip={}, port={}, deviceId={}", ip, port, deviceId, e);
palletDeviceBinding.setStatus("5");
palletDeviceBinding.setDeviceStatus("5");
recordAlarm(palletDeviceBinding, "数据处理异常:" + e.getMessage());
} finally {
// 关键:关闭Modbus连接,避免资源泄漏
......@@ -258,7 +258,7 @@ public class ModbusResultHandler implements Consumer<DeviceStatusReaderDto> {
* 统一告警记录(修复字段错误,确保写入成功)
*/
private void recordAlarm(PalletDeviceBinding binding, String alarmMsg) {
String equipmentCode = binding != null ? binding.getDeviceCode() : "unknown";
String equipmentCode = binding != null ? binding.getMotherboardCode() : "unknown";
recordAlarm(binding, equipmentCode, alarmMsg);
}
......
......@@ -74,90 +74,11 @@ public class CalibrationResultEventHandler {
processCalibrationResultHistoryService.insertProcessCalibrationResultHistory(processCalibrationResultHistory);
// 例如:更新校准状态、保存校准数据、通知前端等
// 1 根据信息拿到点位信息 假如说1L是传过来的
List<PalletDeviceBinding> palletDeviceBindings = initAdAndStatus(message);
initAdAndStatus(message);
// 2 解析数据上传MES 返回如果失败则记录失败,等下次有时间再上传
initMesDataAndUpload(palletDeviceBindings);
}
/**
* 初始化MES数据并上传
*/
private void initMesDataAndUpload(List<PalletDeviceBinding> palletDeviceBindings) {
if(palletDeviceBindings.isEmpty()) {
log.info("initMesDataAndUpload:没有数据需要处理");
return;
}
List<MesDeviceDomain> mesDeviceDomains = new ArrayList<>();
for (PalletDeviceBinding palletDeviceBinding : palletDeviceBindings) {
MesDeviceDomain mesDeviceDomain = new MesDeviceDomain();
// 如果设备编号为空 则不处理改设备
if(StringUtils.isBlank(palletDeviceBinding.getDeviceCode())) continue;
// 主板码
mesDeviceDomain.setMotherboardCode(palletDeviceBinding.getDeviceCode());
// 浓度
mesDeviceDomain.setConcentration(palletDeviceBinding.getConcentration());
// 设备状态
mesDeviceDomain.setDeviceStatus(palletDeviceBinding.getStatus());
// 实时AD
mesDeviceDomain.setRealTimeAd(palletDeviceBinding.getRealTimeAd());
// 实时状态
mesDeviceDomain.setRealTimeStatus(palletDeviceBinding.getRealTimeStatus());
// 写时间状态
mesDeviceDomain.setWriteTimeStatus(palletDeviceBinding.getWriteTimeStatus());
// 运行时间状态
mesDeviceDomain.setRunTimeStatus(palletDeviceBinding.getRunTimeStatus());
// 标定浓度值
mesDeviceDomain.setCalibrationConcentration(palletDeviceBinding.getCalibrationConcentration());
// 标定状态
mesDeviceDomain.setCalibrationConcentrationStatus(palletDeviceBinding.getCalibrationConcentrationStatus());
mesDeviceDomain.setRecordYear(palletDeviceBinding.getRecordYear());
mesDeviceDomain.setRecordMonth(palletDeviceBinding.getRecordMonth());
mesDeviceDomain.setRecordDate(palletDeviceBinding.getRecordDate());
mesDeviceDomain.setRecordHour(palletDeviceBinding.getRecordHour());
mesDeviceDomain.setRecordMinute(palletDeviceBinding.getRecordMinute());
// 写入自检状态 继电器状态 脉冲状态 模块状态 SIM状态 网络状态
mesDeviceDomain.setWriteSelfCheckStatus(palletDeviceBinding.getWriteSelfCheckStatus());
mesDeviceDomain.setRelayStatus(palletDeviceBinding.getRelayStatus());
mesDeviceDomain.setPulseStatus(palletDeviceBinding.getPulseStatus());
mesDeviceDomain.setModuleStatus(palletDeviceBinding.getModuleStatus());
mesDeviceDomain.setSimCardStatus(palletDeviceBinding.getSimCardStatus());
mesDeviceDomain.setNetworkStatus(palletDeviceBinding.getNetworkStatus());
mesDeviceDomains.add(mesDeviceDomain);
}
String mesUploadAddress = sysConfigService.directSelectConfigByKey(RoboticArmConstans.UPLOAD_MES_ADDRESS);
if(StringUtils.isNotBlank(mesUploadAddress)) {
try{
String result = HttpUtils.sendPost(mesUploadAddress, JSON.toJSONString(mesDeviceDomains));
UploadMesResultHistory uploadMesResultHistory = new UploadMesResultHistory();
uploadMesResultHistory.setMessage(result);
uploadMesResultHistoryService.insertUploadMesResultHistory(uploadMesResultHistory);
if(StringUtils.isNotBlank(result)) {
JSONObject jsonObject = JSON.parseObject(result);
// if(jsonObject.getInteger("code") != 200) {
// String data = jsonObject.getString("data");
// if(StringUtils.isNotBlank(data)) {
// processPalletDeviceUploadHistory(palletDeviceBindings,data);
// } else {
// directProcessPaalletDeviceUploadHistory(palletDeviceBindings);
// }
// }
// 20251210 领导说 先 保存所有历史数据
directProcessPaalletDeviceUploadHistory(palletDeviceBindings);
} else {
directProcessPaalletDeviceUploadHistory(palletDeviceBindings);
}
}catch (Exception e){
directProcessPaalletDeviceUploadHistory(palletDeviceBindings);
}
} else {
directProcessPaalletDeviceUploadHistory(palletDeviceBindings);
}
// 20260116 调整 接收标定结果后 不存历史,解绑的时候才去处理。
//initMesDataAndUpload(palletDeviceBindings);
}
/**
......@@ -353,113 +274,6 @@ public class CalibrationResultEventHandler {
}
}
/**
* 处理托盘设备上传历史数据
*/
private void processPalletDeviceUploadHistory(List<PalletDeviceBinding> palletDeviceBindings,String data){
JSONObject jsonObject = JSON.parseObject(data);
if (!jsonObject.containsKey("failedCodes")) {
return;
} else {
log.info("上传失败;没有返回正确数据");
}
JSONArray failedCodes = jsonObject.getJSONArray("failedCodes");
if (failedCodes == null || failedCodes.isEmpty()) {
return;
}
// 使用Set提高查找效率
Set<String> failedCodeSet = failedCodes.stream()
.map(Object::toString)
.collect(Collectors.toSet());
List<PalletDeviceUploadHistory> palletDeviceUploadHistories = palletDeviceBindings.stream()
.filter(binding -> failedCodeSet.contains(binding.getDeviceCode()))
.map(this::convertToUploadHistory)
.collect(Collectors.toList());
if (!palletDeviceUploadHistories.isEmpty()) {
palletDeviceUploadHistoryService.batchInsert(palletDeviceUploadHistories);
}
}
/**
* 直接处理托盘设备上传历史数据
*/
private void directProcessPaalletDeviceUploadHistory(List<PalletDeviceBinding> palletDeviceBindings) {
List<PalletDeviceUploadHistory> collect = palletDeviceBindings.stream().map(this::convertToUploadHistory).collect(Collectors.toList());
palletDeviceUploadHistoryService.batchInsert(collect);
}
/**
* 转换对象
*/
private PalletDeviceUploadHistory convertToUploadHistory(PalletDeviceBinding binding) {
PalletDeviceUploadHistory history = new PalletDeviceUploadHistory();
// 基础信息字段
history.setTrayId(binding.getTrayId());
history.setStoreyCode(binding.getStoreyCode());
history.setDeviceCode(binding.getDeviceCode());
history.setRow(binding.getRow());
history.setCol(binding.getCol());
history.setIndex(binding.getIndex());
history.setNumber(binding.getNumber());
history.setBindingTime(binding.getBindingTime());
history.setUnbindingTime(binding.getUnbindingTime());
// 状态字段
history.setStatus(binding.getStatus());
// 时间记录字段
history.setRecordYear(binding.getRecordYear());
history.setRecordMonth(binding.getRecordMonth());
history.setRecordDate(binding.getRecordDate());
history.setRecordHour(binding.getRecordHour());
history.setRecordMinute(binding.getRecordMinute());
// 写入状态字段
history.setWriteTimeStatus(binding.getWriteTimeStatus());
history.setRunTimeStatus(binding.getRunTimeStatus());
// 调零相关字段
history.setAdjustmentZeroAd(binding.getAdjustmentZeroAd());
history.setZeroStatus(binding.getZeroStatus());
// 标定相关字段 - 注意字段名称不同
history.setCalibrationAd(binding.getCalibrationAd());
history.setCalibrationStatus(binding.getCalibrationAdStatus()); // 注意:这里字段名不同
// 浓度字段
history.setConcentration(binding.getConcentration());
// 实时AD相关字段
history.setRealTimeAd(binding.getRealTimeAd());
history.setRealTimeAdStatus(binding.getRealTimeStatus()); // 注意:这里字段名不同
// 托盘编号字段 - 注意字段名称不同
history.setTrayCode(binding.getfTrayCode()); // 注意:这里字段名不同
// 创建时间和更新时间(如果需要)
history.setCreateTime(binding.getCreateTime());
history.setUpdateTime(binding.getUpdateTime());
// 标定浓度字段 - 注意字段名称不同
history.setCalibrationConcentration(binding.getCalibrationConcentration());
history.setCalibrationConcentrationStatus(binding.getCalibrationConcentrationStatus());
// 写入自检状态 继电器状态 脉冲状态 模组状态 SIM卡状态 网络状态
history.setWriteSelfCheckStatus(binding.getWriteSelfCheckStatus());
history.setRelayStatus(binding.getRelayStatus());
history.setPulseStatus(binding.getPulseStatus());
history.setModuleStatus(binding.getModuleStatus());
history.setSimCardStatus(binding.getSimCardStatus());
history.setNetworkStatus(binding.getNetworkStatus());
return history;
}
/**
* 设备数据内部类(如果需要存储设备类型,可以扩展此类)
*/
......
package com.zehong.system.service;
import java.util.List;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.system.domain.PalletDeviceBinding;
import com.zehong.system.domain.PalletDeviceUploadFailure;
import com.zehong.system.domain.PalletDeviceUploadHistory;
/**
* 上传失败历史记录Service接口
*
* @author zehong
* @date 2026-01-16
*/
public interface IPalletDeviceUploadFailureService
{
/**
* 查询上传失败历史记录
*
* @param id 上传失败历史记录ID
* @return 上传失败历史记录
*/
public PalletDeviceUploadFailure selectPalletDeviceUploadFailureById(Long id);
public AjaxResult handleReUpload();
/**
* 查询上传失败历史记录列表
*
* @param palletDeviceUploadFailure 上传失败历史记录
* @return 上传失败历史记录集合
*/
public List<PalletDeviceUploadFailure> selectPalletDeviceUploadFailureList(PalletDeviceUploadFailure palletDeviceUploadFailure);
/**
* 新增上传失败历史记录
*
* @param palletDeviceUploadFailure 上传失败历史记录
* @return 结果
*/
public int insertPalletDeviceUploadFailure(PalletDeviceUploadFailure palletDeviceUploadFailure);
public int batchInsert(List<PalletDeviceUploadFailure> palletDeviceUploadFailures);
public int batchInsertRealTimeData(List<PalletDeviceBinding> palletDeviceBindings);
/**
* 修改上传失败历史记录
*
* @param palletDeviceUploadFailure 上传失败历史记录
* @return 结果
*/
public int updatePalletDeviceUploadFailure(PalletDeviceUploadFailure palletDeviceUploadFailure);
/**
* 批量删除上传失败历史记录
*
* @param ids 需要删除的上传失败历史记录ID
* @return 结果
*/
public int deletePalletDeviceUploadFailureByIds(Long[] ids);
/**
* 删除上传失败历史记录信息
*
* @param id 上传失败历史记录ID
* @return 结果
*/
public int deletePalletDeviceUploadFailureById(Long id);
}
......@@ -3,19 +3,20 @@ package com.zehong.system.service;
import java.util.List;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.system.domain.PalletDeviceBinding;
import com.zehong.system.domain.PalletDeviceUploadHistory;
/**
* 未上传成功的历史数据列Service接口
*
*
* @author zehong
* @date 2025-11-24
*/
public interface IPalletDeviceUploadHistoryService
public interface IPalletDeviceUploadHistoryService
{
/**
* 查询未上传成功的历史数据列
*
*
* @param id 未上传成功的历史数据列ID
* @return 未上传成功的历史数据列
*/
......@@ -23,7 +24,7 @@ public interface IPalletDeviceUploadHistoryService
/**
* 查询未上传成功的历史数据列列表
*
*
* @param palletDeviceUploadHistory 未上传成功的历史数据列
* @return 未上传成功的历史数据列集合
*/
......@@ -31,19 +32,19 @@ public interface IPalletDeviceUploadHistoryService
public int batchInsert(List<PalletDeviceUploadHistory> palletDeviceUploadHistoryList);
public int batchInsertRealTimeData(List<PalletDeviceBinding> palletDeviceBindings);
/**
* 新增未上传成功的历史数据列
*
*
* @param palletDeviceUploadHistory 未上传成功的历史数据列
* @return 结果
*/
public int insertPalletDeviceUploadHistory(PalletDeviceUploadHistory palletDeviceUploadHistory);
public AjaxResult handleReUpload();
/**
* 修改未上传成功的历史数据列
*
*
* @param palletDeviceUploadHistory 未上传成功的历史数据列
* @return 结果
*/
......@@ -51,7 +52,7 @@ public interface IPalletDeviceUploadHistoryService
/**
* 批量删除未上传成功的历史数据列
*
*
* @param ids 需要删除的未上传成功的历史数据列ID
* @return 结果
*/
......@@ -59,7 +60,7 @@ public interface IPalletDeviceUploadHistoryService
/**
* 删除未上传成功的历史数据列信息
*
*
* @param id 未上传成功的历史数据列ID
* @return 结果
*/
......
......@@ -588,6 +588,9 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
throw new RuntimeException(e);
}
tStoreyInfo.setfStatus("0");
tStoreyInfoMapper.updateStatusByCode(tStoreyInfo);
return AjaxResult.success();
}
......
......@@ -153,7 +153,7 @@ public class AgingStageOneProcessJob implements Job {
int[] result = Modbus4jUtils.readDeviceWithRetry(ip, port, deviceId);
// 3. 更新设备状态
binding.setStatus(String.valueOf(result[1]));
binding.setDeviceStatus(String.valueOf(result[1]));
// 4. 更新浓度值
binding.setConcentration(String.valueOf(result[0]));
......@@ -194,8 +194,7 @@ public class AgingStageOneProcessJob implements Job {
} catch (Exception e) {
log.info("设备{}处理异常: ip={}, port={}", deviceId, ip, port, e);
binding.setStatus("5");
binding.setWriteTimeStatus("0");
binding.setDeviceStatus("-9999");
palletDeviceBindingMapper.updatePalletDeviceBinding(binding);
errorCount.incrementAndGet();
return false;
......@@ -322,7 +321,7 @@ public class AgingStageOneProcessJob implements Job {
* 统一告警记录(修复字段错误,确保写入成功)
*/
private void recordAlarmByBinding(PalletDeviceBinding binding, String alarmMsg) {
String equipmentCode = binding != null ? binding.getDeviceCode() : "unknown";
String equipmentCode = binding != null ? binding.getMotherboardCode() : "unknown";
recordAlarmByBingding(equipmentCode, alarmMsg);
}
......
......@@ -166,7 +166,7 @@ public class AgingStageThreeProcessJob implements Job {
int[] result = Modbus4jUtils.readDeviceWithRetry(ip, port, deviceId);
// 3. 更新设备状态
binding.setStatus(String.valueOf(result[1]));
binding.setDeviceStatus(String.valueOf(result[1]));
// 3. 更新浓度值
binding.setConcentration(String.valueOf(result[0]));
......@@ -205,7 +205,7 @@ public class AgingStageThreeProcessJob implements Job {
binding.setNetworkStatus(1);
}
if("5".equals(binding.getStatus())) {
if("5".equals(binding.getDeviceStatus())) {
binding.setWriteTimeStatus("0");
}
......@@ -217,7 +217,7 @@ public class AgingStageThreeProcessJob implements Job {
} catch (Exception e) {
log.error("设备{}处理异常: ip={}, port={}", deviceId, ip, port, e);
binding.setStatus("5");
binding.setDeviceStatus("-9999");
binding.setWriteTimeStatus("0");
binding.setRunTimeStatus("0");
palletDeviceBindingMapper.updatePalletDeviceBinding(binding);
......@@ -436,7 +436,7 @@ public class AgingStageThreeProcessJob implements Job {
* 统一告警记录(修复字段错误,确保写入成功)
*/
private void recordAlarmByBinding(PalletDeviceBinding binding, String alarmMsg) {
String equipmentCode = binding != null ? binding.getDeviceCode() : "unknown";
String equipmentCode = binding != null ? binding.getMotherboardCode() : "unknown";
recordAlarmByBingding(equipmentCode, alarmMsg);
}
......
......@@ -232,7 +232,7 @@ public class AgingStageTwoProcessJob implements Job {
} catch (Exception e) {
log.info("设备{}处理异常: ip={}, port={}", deviceId, ip, port, e);
binding.setStatus("5");
binding.setDeviceStatus("-9999");
palletDeviceBindingMapper.updatePalletDeviceBinding(binding);
errorCount.incrementAndGet();
return false;
......
......@@ -194,7 +194,7 @@ public abstract class BaseDeviceCommJob implements Job {
*/
private TStoreyInfo validateBaseParams(String storeyIdStr) {
// 1. 校验storeyId格式
if (StringUtils.isBlank(storeyIdStr)) {
if (StringUtils.isBlank(storeyIdStr)) {
log.info("storeyId为空:port=" + getFixedPort());
}
Long storeyId = parseStoreyId(storeyIdStr);
......@@ -206,7 +206,7 @@ public abstract class BaseDeviceCommJob implements Job {
// 2. 校验设备信息和IP
TStoreyInfo storeyInfo = tStoreyInfoMapper.selectTStoreyInfoById(storeyId);
if (storeyInfo == null || StringUtils.isBlank(storeyInfo.getfIp())) {
log.info("设备信息无效:storeyId="+storeyId);
log.info("设备信息无效:storeyId="+storeyId);
}
return storeyInfo;
}
......@@ -218,7 +218,7 @@ public abstract class BaseDeviceCommJob implements Job {
try {
return Long.parseLong(storeyIdStr);
} catch (NumberFormatException e) {
log.info("设备信息无效:storeyId="+storeyIdStr);
log.info("设备信息无效:storeyId="+storeyIdStr);
}
return null;
}
......@@ -397,13 +397,13 @@ public abstract class BaseDeviceCommJob implements Job {
}
protected void updateDeviceError(String ip) {
int deviceId = getDeviceId();
int deviceId = getDeviceId();
// 2. 查询数据库并校验(避免NPE)
PalletDeviceBinding palletDeviceBinding;
try {
palletDeviceBinding = palletDeviceBindingMapper.selectByTrayIdAndIndex(ip, deviceId);
if(palletDeviceBinding != null) {
palletDeviceBinding.setStatus("4");
palletDeviceBinding.setDeviceStatus("4");
}
} catch (Exception e) {
log.info("查询PalletDeviceBinding异常:ip={}, deviceId={}", ip, deviceId, e);
......
......@@ -25,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
trayInfo.f_binding_time,
trayInfo.f_unbinding_time,
trayInfo.f_create_time,
( SELECT count( 1 ) FROM t_pallet_device_binding WHERE f_tray_id = trayInfo.f_tray_id AND ( f_device_code != '' ) AND f_unbinding_time IS NULL ) AS boardCount ,
( SELECT count( 1 ) FROM t_pallet_device_binding WHERE f_tray_id = trayInfo.f_tray_id AND ( f_motherboard_code != '' ) AND f_unbinding_time IS NULL ) AS boardCount ,
storeyInfo.f_aging_start_time,
storeyInfo.f_estimated_end_time
FROM
......
import request from '@/utils/request'
// 查询上传失败历史记录列表
export function listFailure(query) {
return request({
url: '/palletDevice/binding/failure/list',
method: 'get',
params: query
})
}
// 查询上传失败历史记录详细
export function getFailure(id) {
return request({
url: '/palletDevice/binding/failure/' + id,
method: 'get'
})
}
// 新增上传失败历史记录
export function addFailure(data) {
return request({
url: '/palletDevice/binding/failure',
method: 'post',
data: data
})
}
// 修改上传失败历史记录
export function updateFailure(data) {
return request({
url: '/palletDevice/binding/failure',
method: 'put',
data: data
})
}
// 删除上传失败历史记录
export function delFailure(id) {
return request({
url: '/palletDevice/binding/failure/' + id,
method: 'delete'
})
}
// 导出上传失败历史记录
export function exportFailure(query) {
return request({
url: '/palletDevice/binding/failure/export',
method: 'get',
params: query
})
}
export function reUpload() {
return request({
url: '/palletDevice/binding/failure/handleReUpload',
method: 'get'
})
}
......@@ -51,10 +51,3 @@ export function exportHistory(query) {
params: query
})
}
export function reUpload() {
return request({
url: '/palletDevice/binding/history/handleReUpload',
method: 'get'
})
}
This diff is collapsed.
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="设备编号" prop="deviceCode">
<el-form-item label="设备编号" prop="motherboardCode">
<el-input
v-model="queryParams.deviceCode"
v-model="queryParams.motherboardCode"
placeholder="请输入绑定的设备编号"
clearable
size="small"
......@@ -26,15 +26,6 @@
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
......@@ -45,23 +36,13 @@
@click="handleExport"
>导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-upload"
size="mini"
:loading="exportLoading"
@click="handleReUpload"
>重新上传</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="historyList" @selection-change="handleSelectionChange">
<el-table-column label="托盘编号" align="center" prop="trayCode" />
<el-table-column label="绑定层编号" align="center" prop="storeyCode" width="100px" />
<el-table-column label="设备编号" align="center" prop="deviceCode" />
<el-table-column label="设备编号" align="center" prop="motherboardCode" />
<el-table-column label="行" align="center" prop="row" />
<el-table-column label="列" align="center" prop="col" />
<el-table-column label="第几个" align="center" prop="index" />
......@@ -71,18 +52,14 @@
<span>{{ parseTime(scope.row.bindingTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="解绑时间" align="center" prop="unbindingTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.unbindingTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="status" >
<el-table-column label="状态" align="center" prop="deviceStatus" >
<template slot-scope="scope">
<el-tag type="info" v-if="scope.row.status === '0'">预热</el-tag>
<el-tag type="success" v-if="scope.row.status === '1'">正常</el-tag>
<el-tag type="warning" v-if="scope.row.status === '3'">传感器故障</el-tag>
<el-tag type="danger" v-if="scope.row.status === '4'">报警</el-tag>
<el-tag type="danger" v-if="scope.row.status === '5'">通讯故障</el-tag>
<el-tag type="info" v-if="scope.row.deviceStatus === '0'">预热</el-tag>
<el-tag type="success" v-if="scope.row.deviceStatus === '1'">正常</el-tag>
<el-tag type="warning" v-if="scope.row.deviceStatus === '3'">传感器故障</el-tag>
<el-tag type="danger" v-if="scope.row.deviceStatus === '4'">报警</el-tag>
<el-tag type="danger" v-if="scope.row.deviceStatus === '5'">通讯故障</el-tag>
<el-tag type="danger" v-if="scope.row.deviceStatus === '-9999'">通讯异常</el-tag>
</template>
</el-table-column>
<el-table-column label="写时间状态" align="center" prop="writeTimeStatus" width="100px" >
......@@ -99,10 +76,10 @@
</el-table-column>
<el-table-column label="浓度值" align="center" prop="concentration" />
<el-table-column label="实时AD值" align="center" prop="realTimeAd" />
<el-table-column label="实时AD状态" align="center" prop="realTimeAdStatus" width="110px" >
<el-table-column label="实时AD状态" align="center" prop="realTimeStatus" width="110px" >
<template slot-scope="scope">
<el-tag type="info" v-if="scope.row.realTimeAdStatus === '0'">异常</el-tag>
<el-tag type="success" v-if="scope.row.realTimeAdStatus === '1'">正常</el-tag>
<el-tag type="info" v-if="scope.row.realTimeStatus === '0'">异常</el-tag>
<el-tag type="success" v-if="scope.row.realTimeStatus === '1'">正常</el-tag>
</template>
</el-table-column>
<el-table-column label="标定浓度值" align="center" width="150" prop="calibrationConcentration"></el-table-column>
......@@ -194,8 +171,8 @@
<el-form-item label="托盘id" prop="trayId">
<el-input v-model="form.trayId" placeholder="请输入托盘id" />
</el-form-item>
<el-form-item label="绑定的设备编号" prop="deviceCode">
<el-input v-model="form.deviceCode" placeholder="请输入绑定的设备编号" />
<el-form-item label="绑定的设备编号" prop="motherboardCode">
<el-input v-model="form.motherboardCode" placeholder="请输入绑定的设备编号" />
</el-form-item>
<el-form-item label="行" prop="row">
<el-input v-model="form.row" placeholder="请输入行" />
......@@ -226,7 +203,7 @@
</el-date-picker>
</el-form-item>
<el-form-item label="0-预热;1-正常;3-传感器故障;4-报警;5-通讯故障">
<el-radio-group v-model="form.status">
<el-radio-group v-model="form.deviceStatus">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
......@@ -278,7 +255,7 @@
<el-input v-model="form.realTimeAd" placeholder="请输入实时AD值" />
</el-form-item>
<el-form-item label="实时AD状态;0-异常;1-正常">
<el-radio-group v-model="form.realTimeAdStatus">
<el-radio-group v-model="form.realTimeStatus">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
......@@ -292,7 +269,7 @@
</template>
<script>
import { listHistory, getHistory, delHistory, addHistory, updateHistory, exportHistory ,reUpload} from "@/api/palletDeviceBinding/palletDeviceUploadHistory";
import { listHistory, getHistory, delHistory, addHistory, updateHistory, exportHistory} from "@/api/palletDeviceBinding/palletDeviceUploadHistory";
export default {
name: "History",
......@@ -325,7 +302,7 @@ export default {
pageNum: 1,
pageSize: 10,
trayId: null,
deviceCode: null,
motherboardCode: null,
trayCode: null,
row: null,
col: null,
......@@ -334,7 +311,7 @@ export default {
bindingTime: null,
unbindingTime: null,
createTime: null,
status: null,
deviceStatus: null,
recordYear: null,
recordMonth: null,
recordDate: null,
......@@ -348,7 +325,7 @@ export default {
concentration: null,
runTimeStatus: null,
realTimeAd: null,
realTimeAdStatus: null
realTimeStatus: null
},
// 表单参数
form: {},
......@@ -365,18 +342,18 @@ export default {
},
methods: {
// 获取标定状态文本
getCalibrationText(status) {
if (status === '4') {
getCalibrationText(deviceStatus) {
if (deviceStatus === '4') {
return '正常'
} else if (status) {
} else if (deviceStatus) {
return '异常'
}
},
// 获取标定状态的el-tag类型
getCalibrationTagType(status) {
if (status === '4') {
getCalibrationTagType(deviceStatus) {
if (deviceStatus === '4') {
return 'success' // 正常 - 绿色
} else if (status) {
} else if (deviceStatus) {
return 'info' // 异常 - 红色
}
},
......@@ -399,7 +376,7 @@ export default {
this.form = {
id: null,
trayId: null,
deviceCode: null,
motherboardCode: null,
row: null,
col: null,
index: null,
......@@ -407,7 +384,7 @@ export default {
bindingTime: null,
unbindingTime: null,
createTime: null,
status: "0",
deviceStatus: "0",
recordYear: null,
recordMonth: null,
recordDate: null,
......@@ -421,7 +398,7 @@ export default {
concentration: null,
runTimeStatus: "0",
realTimeAd: null,
realTimeAdStatus: "0"
realTimeStatus: "0"
};
this.resetForm("form");
},
......@@ -491,23 +468,6 @@ export default {
this.msgSuccess("删除成功");
}).catch(() => {});
},
handleReUpload() {
this.$confirm('是否确认重新上传当前时间下设备编号不为空的所有数据?', '提示-成功后数据直接删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
reUpload().then(response => {
// 确保 response 有正确的结构
if (response && response.code === 200) {
// 处理部分失败或完全失败的情况
this.handleUploadResult(response);
}
this.getList(); // 重新加载数据
})
}).catch(() => {
});
},
// 单独处理上传结果的方法
handleUploadResult(response) {
......
......@@ -20,7 +20,7 @@
</el-input>
<el-input
class="search-input"
v-model="queryParams.deviceCode"
v-model="queryParams.motherboardCode"
placeholder="请输入设备编号"
clearable
>
......@@ -63,9 +63,9 @@
<div class="tray-id">{{ scope.row.storeyCode }}</div>
</template>
</el-table-column>
<el-table-column label="设备编号" prop="deviceCode" align="center" width="150" fixed="left">
<el-table-column label="设备编号" prop="motherboardCode" align="center" width="150" fixed="left">
<template slot-scope="scope">
<div class="device-code">{{ scope.row.deviceCode }}</div>
<div class="device-code">{{ scope.row.motherboardCode }}</div>
</template>
</el-table-column>
<!-- <el-table-column label="行" prop="row" align="center" width="80" />-->
......@@ -83,11 +83,14 @@
<el-table-column label="状态" align="center" width="120">
<template slot-scope="scope">
<el-tag
:type="statusTagType(scope.row.status)"
:type="statusTagType(scope.row.deviceStatus)"
size="mini"
class="status-tag"
:class="{
'custom-critical-tag': scope.row.deviceStatus === '-9999'
}"
>
{{ statusLabel(scope.row.status) }}
{{ statusLabel(scope.row.deviceStatus) }}
</el-tag>
</template>
</el-table-column>
......@@ -122,18 +125,6 @@
<span v-else class="write-unknown">-</span>
</template>
</el-table-column>
<!-- <el-table-column label="零点AD" align="center" width="150">-->
<!-- <template slot-scope="scope">-->
<!-- <div class="device-code">{{ scope.row.adjustmentZeroAd || '-' }}</div>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="零点AD状态" align="center" width="150">-->
<!-- <template slot-scope="scope">-->
<!-- <span v-if="scope.row.zeroStatus === '1'" class="write-success">正常</span>-->
<!-- <span v-else-if="scope.row.zeroStatus === '0'" class="write-failed">异常</span>-->
<!-- <span v-else class="write-unknown">-</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="标定浓度值" align="center" width="150">
<template slot-scope="scope">
<div class="device-code">{{ scope.row.calibrationConcentration != null ? scope.row.calibrationConcentration : '-' }}</div>
......@@ -252,8 +243,8 @@ export default {
pageNum: 1,
pageSize: 10,
fTrayCode: "",
deviceCode: "",
status: "",
motherboardCode: "",
deviceStatus: "",
bindingTime: ""
}
};
......@@ -286,10 +277,10 @@ export default {
},
methods: {
// 获取标定状态文本
getCalibrationText(status) {
if (status === '4') {
getCalibrationText(deviceStatus) {
if (deviceStatus === '4') {
return '正常'
} else if (status) {
} else if (deviceStatus) {
return '异常'
} else {
return '-'
......@@ -297,10 +288,10 @@ export default {
},
// 获取标定状态样式类
getCalibrationClass(status) {
if (status === '4') {
getCalibrationClass(deviceStatus) {
if (deviceStatus === '4') {
return 'write-success'
} else if (status) {
} else if (deviceStatus) {
return 'write-failed'
} else {
return 'write-unknown'
......@@ -320,8 +311,8 @@ export default {
},
/** 状态标签类型映射 */
statusTagType(status) {
switch (status) {
statusTagType(deviceStatus) {
switch (deviceStatus) {
case "0":
return "info"; // 预热-信息蓝
case "1":
......@@ -331,22 +322,25 @@ export default {
case "4":
return "danger"; // 报警-危险红
case "5":
return ""; // 通讯故障-使用自定义灰色
return "error"; // 通讯故障-使用自定义灰色
case "-9999":
return "critical"; // 通讯异常-使用自定义灰色
default:
return "";
}
},
/** 状态中文映射 */
statusLabel(status) {
statusLabel(deviceStatus) {
const statusMap = {
"0": "预热",
"1": "正常",
"3": "传感器故障",
"4": "报警",
"5": "通讯故障"
"5": "通讯故障",
"-9999": "通讯异常"
};
return statusMap[status] || "-";
return statusMap[deviceStatus] || "-";
},
/** 格式化通信时间(年-月-日 时:分) */
......@@ -375,8 +369,8 @@ export default {
pageNum: 1,
pageSize: 10,
fTrayCode: "",
deviceCode: "",
status: "",
motherboardCode: "",
deviceStatus: "",
bindingTime: ""
};
this.getList();
......@@ -398,6 +392,20 @@ export default {
</script>
<style scoped>
/* 通讯异常(危急 - 比危险红更强烈) */
.custom-critical-tag {
background: linear-gradient(135deg, #ff0000 0%, #990000 100%) !important;
border-color: #ff3838 !important;
color: white !important;
font-weight: bold !important;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3) !important;
box-shadow: 0 0 8px rgba(255, 56, 56, 0.5) !important;
animation: critical-pulse 1.5s infinite alternate !important;
position: relative !important;
z-index: 1 !important;
}
/* 主容器样式 */
.tray-container {
width: 100%;
......
......@@ -76,7 +76,7 @@
class="device-cell"
:class="{
'active': activeCell === index,
'empty': !device.deviceCode,
'empty': !device.motherboardCode,
'error': isDeviceError(device),
'duplicate': device.isDuplicate
}"
......@@ -84,7 +84,10 @@
:ref="`deviceCell_${index}`"
>
<div class="device-id">
{{ device.deviceCode || '+' }}
<div class="device-id">
{{ (device.motherboardCode && device.calibrationUnbindStatus === '0') ? device.motherboardCode : '+' }}
<!-- 其他图标保持不变 -->
</div>
<!-- 添加错误状态图标 -->
<i v-if="isDeviceError(device)" class="error-icon fas fa-exclamation-circle"></i>
<!-- 添加重复状态图标 -->
......@@ -243,7 +246,7 @@ export default {
return {
index: i + 1,
number: number,
deviceCode: '',
motherboardCode: '',
row: row,
col: col,
isDuplicate: false // 添加重复标记属性
......@@ -271,7 +274,7 @@ export default {
},
// 计算已填充的设备数量
filledCount() {
return this.devices.filter(d => d.deviceCode).length;
return this.devices.filter(d => d.motherboardCode).length;
},
// 计算绑定按钮是否禁用
......@@ -352,26 +355,20 @@ export default {
}
},
// 在 methods 中添加一个专门判断设备是否异常的方法
isDeviceError(device) {
if (!device.deviceCode) return false;
// 只有在标定完成状态下才进行详细状态检查
if (this.trayStatus === '3') {
// 标定完成状态下的完整异常检查
return device.status === '0' ||
device.status === '5' ||
(device.realTimeStatus != null && device.realTimeStatus === '0') ||
(device.calibrationConcentrationStatus != null && device.calibrationConcentrationStatus !== '4') ||
(device.writeTimeStatus != null && device.writeTimeStatus === '0') ||
(device.runTimeStatus != null && device.runTimeStatus === '0') ||
device.relayStatus === 0 || device.pulseStatus === 0 ||
device.moduleStatus === 0 || device.simCardStatus === 0 || device.networkStatus === 0;
} else {
// 非标定完成状态(0,4,1,2等),只检查设备状态是否为 0 或 5
// 其他状态字段在绑定阶段可能为 null,不应该视为错误
return device.status === '0' || device.status === '5';
}
// 如果设备已解绑,则不视为错误
if (!device.motherboardCode || device.calibrationUnbindStatus === '1') return false;
// 原有的异常判断逻辑保持不变
return device.deviceStatus === '0' ||
device.deviceStatus === '5' ||
device.deviceStatus === '-9999' ||
(device.realTimeStatus != null && device.realTimeStatus === '0') ||
(device.calibrationConcentrationStatus != null && device.calibrationConcentrationStatus !== '4') ||
(device.writeTimeStatus != null && device.writeTimeStatus === '0') ||
(device.runTimeStatus != null && device.runTimeStatus === '0') ||
device.relayStatus === 0 || device.pulseStatus === 0 ||
device.moduleStatus === 0 || device.simCardStatus === 0 || device.networkStatus === 0;
},
getAllBindingData(trayId) {
......@@ -393,9 +390,9 @@ export default {
this.checkDuplicateDevices();
const firstDeviceCodeEmptyItem = this.devices.find(item =>
item.deviceCode === null ||
item.deviceCode === undefined ||
(typeof item.deviceCode === 'string' && item.deviceCode.trim() === '')
item.motherboardCode === null ||
item.motherboardCode === undefined ||
(typeof item.motherboardCode === 'string' && item.motherboardCode.trim() === '')
);
if(firstDeviceCodeEmptyItem !== undefined) {
......@@ -437,9 +434,10 @@ export default {
trayId: this.fTrayId,
index: i + 1,
number: number,
deviceCode: '',
motherboardCode: '',
row: row,
col: col,
calibrationUnbindStatus: '0', // 默认未解绑
isDuplicate: false // 添加重复标记属性
}
})
......@@ -476,7 +474,7 @@ export default {
if (this.trayStatus === '3') {
// 检查扫描的设备是否存在
const deviceIndex = this.devices.findIndex(
d => d.deviceCode === this.deviceInput
d => d.motherboardCode === this.deviceInput
);
if (deviceIndex !== -1) {
......@@ -501,7 +499,7 @@ export default {
// 检查设备号是否已存在(排除当前单元格自身)
const existingIndex = this.devices.findIndex(
(d, idx) => idx !== this.activeCell && d.deviceCode === trimmedInput
(d, idx) => idx !== this.activeCell && d.motherboardCode === trimmedInput
);
if (existingIndex !== -1) {
......@@ -520,7 +518,8 @@ export default {
}
// 如果没有重复,则正常添加设备
this.devices[this.activeCell].deviceCode = trimmedInput;
this.devices[this.activeCell].motherboardCode = trimmedInput;
this.devices[this.activeCell].calibrationUnbindStatus = '0';
// 添加后重新检查重复状态
this.checkDuplicateDevices();
......@@ -543,15 +542,15 @@ export default {
// 统计每个设备码出现的次数
this.devices.forEach(device => {
if (device.deviceCode && device.deviceCode.trim()) {
deviceCodeMap[device.deviceCode] = (deviceCodeMap[device.deviceCode] || 0) + 1;
if (device.motherboardCode && device.motherboardCode.trim()) {
deviceCodeMap[device.motherboardCode] = (deviceCodeMap[device.motherboardCode] || 0) + 1;
}
});
// 标记重复的设备
this.devices.forEach(device => {
if (device.deviceCode && device.deviceCode.trim()) {
device.isDuplicate = deviceCodeMap[device.deviceCode] > 1;
if (device.motherboardCode && device.motherboardCode.trim()) {
device.isDuplicate = deviceCodeMap[device.motherboardCode] > 1;
} else {
device.isDuplicate = false;
}
......@@ -589,15 +588,17 @@ export default {
// 调用解绑方法,传递设备信息和palletDeviceBindingId
let palletDeviceBinding = {
deviceCode: device.deviceCode,
palletDeviceBindingId: device.palletDeviceBindingId
motherboardCode: device.motherboardCode,
palletDeviceBindingId: device.palletDeviceBindingId,
calibrationUnbindStatus: '1' // 标记为解绑
}
unbindSingleDevice(palletDeviceBinding).then(res => {
if (res.code === 200) {
// 解绑成功后的处理
const wasErrorDevice = this.isDeviceError(this.devices[deviceIndex]);
this.devices[deviceIndex].deviceCode = '';
this.devices[deviceIndex].motherboardCode = '';
this.devices[deviceIndex].calibrationUnbindStatus = '1'; // 标记为已解绑
// 清除重复标记
this.devices[deviceIndex].isDuplicate = false;
......@@ -615,7 +616,7 @@ export default {
}
}
this.$message.success(`设备 ${device.deviceCode} 解绑成功`);
this.$message.success(`设备 ${device.motherboardCode} 解绑成功`);
} else {
this.$message.error("解绑失败");
}
......@@ -641,8 +642,8 @@ export default {
// 解绑成功后重置设备矩阵
this.devices = this.devices.map(d => ({
...d,
deviceCode: '',
status: '1',
motherboardCode: '',
deviceStatus: '1',
isDuplicate: false
}));
this.abnormalCount = this.devices.length; // 重置异常计数为总设备数
......@@ -706,7 +707,7 @@ export default {
// 重置时也清除重复标记
this.devices = this.devices.map(d => ({
...d,
deviceCode: '',
motherboardCode: '',
isDuplicate: false
}));
this.activeCell = 0;
......
......@@ -432,7 +432,7 @@ export default {
return clearTasks(row);
}).then(() => {
this.getList();
this.msgSuccess("重新老化开始");
this.msgSuccess("清空任务完成");
}).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