Commit 344043d7 authored by wanghao's avatar wanghao

1 解绑后 重新绑定自测报错调整

2 扫码绑定校验重复设备号
parent 630fa641
......@@ -53,6 +53,8 @@ public interface TTrayInfoMapper
*/
public int updateTTrayInfo(TTrayInfo tTrayInfo);
public int updateStatusByStoreyCode(TTrayInfo tTrayInfo);
public int updateStatusByTrayCode(TTrayInfo tTrayInfo);
public int updateStatusByTrayId(TTrayInfo tTrayInfo);
......
......@@ -7,6 +7,7 @@ import com.zehong.common.constant.RoboticArmConstans;
import com.zehong.common.utils.StringUtils;
import com.zehong.common.utils.http.HttpUtils;
import com.zehong.system.domain.*;
import com.zehong.system.mapper.TTrayInfoMapper;
import com.zehong.system.service.IPalletDeviceBindingService;
import com.zehong.system.service.IPalletDeviceUploadHistoryService;
import com.zehong.system.service.IProcessCalibrationResultHistoryService;
......@@ -52,6 +53,9 @@ public class CalibrationResultEventHandler {
@Resource
private IProcessCalibrationResultHistoryService processCalibrationResultHistoryService;
@Resource
private TTrayInfoMapper tTrayInfoMapper;
/**
* check是否启动 ,没启动就启动下 开始老化
*
......@@ -158,6 +162,12 @@ public class CalibrationResultEventHandler {
// 批量更新
palletDeviceBindingService.batchUpdateAdAndStatus(palletDeviceBindings);
// 更新托盘为标检完成状态3
TTrayInfo tTrayInfo = new TTrayInfo();
tTrayInfo.setfStatus("3");
tTrayInfo.setfTrayCode(trayCode);
tTrayInfoMapper.updateStatusByTrayCode(tTrayInfo);
return palletDeviceBindings;
}
......
......@@ -44,6 +44,8 @@ public interface ITTrayInfoService
*/
public int updateTTrayInfo(TTrayInfo tTrayInfo);
public int updateStatusByStoreCode(TTrayInfo tTrayInfo);
public int updateStatusByTrayCode(TTrayInfo tTrayInfo);
public int updateStatusByTrayId(TTrayInfo tTrayInfo);
......
......@@ -79,11 +79,21 @@ public class TTrayInfoServiceImpl implements ITTrayInfoService
return tTrayInfoMapper.updateTTrayInfo(tTrayInfo);
}
@Override
public int updateStatusByStoreCode(TTrayInfo tTrayInfo) {
return tTrayInfoMapper.updateStatusByStoreyCode(tTrayInfo);
}
/**
* 修改托盘状态
*
* @param tTrayInfo 托盘信息
* @return 批量结果
*/
@Override
public int updateStatusByTrayCode(TTrayInfo tTrayInfo) {
return tTrayInfoMapper.updateStatusByTrayCode(tTrayInfo);
}
@Override
public int updateStatusByTrayId(TTrayInfo tTrayInfo) {
return tTrayInfoMapper.initStatusByTrayId(tTrayInfo.getfTrayId());
......
......@@ -81,7 +81,7 @@ public class AllCommandHandler {
TTrayInfo tTrayInfo = new TTrayInfo();
tTrayInfo.setfStatus("1");
tTrayInfo.setfStoreyCode(storeyCode);
trayInfoService.updateStatusByTrayCode(tTrayInfo);
trayInfoService.updateStatusByStoreCode(tTrayInfo);
deviceTaskScheduler.scheduleDeviceMonitoring(tStoreyInfo.getfStoreyId(), fip, fport);
}
......
......@@ -169,6 +169,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="resetAll" parameterType="long">
update t_pallet_device_binding
set f_device_code = null,
f_status = null,
f_binding_time = null,
f_unbinding_time = null,
f_status = null,
......@@ -222,6 +223,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="unbindDevice" parameterType="long">
update t_pallet_device_binding
set f_device_code = null,
f_status = null,
f_unbinding_time = NOW(),
f_record_year = null,
f_record_month = null,
......@@ -303,6 +305,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
UPDATE t_pallet_device_binding
<trim prefix="SET" suffixOverrides=",">
f_unbinding_time = null,
f_status = null,
f_binding_time = NOW(),
f_record_year = null,
f_record_month = null,
......@@ -320,7 +323,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
f_real_time_ad_status = null,
f_calibration_concentration = null,
f_calibration_concentration_status = null
<if test="item.deviceCode != null">f_device_code = #{item.deviceCode},</if>
<choose>
<when test="item.deviceCode != null">
, f_device_code = #{item.deviceCode}
</when>
</choose>
</trim>
WHERE f_pallet_device_binding_id = #{item.palletDeviceBindingId}
</foreach>
......@@ -328,6 +335,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="unbindAllDevice" parameterType="long">
update t_pallet_device_binding
set f_device_code = null,
f_status = null,
f_unbinding_time = NOW(),
f_status = '1',
f_record_year = null,
......
......@@ -89,11 +89,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</insert>
<update id="updateStatusByTrayCode" parameterType="TTrayInfo">
<update id="updateStatusByStoreyCode" parameterType="TTrayInfo">
update t_tray_info
set f_status = #{fStatus}
where f_storey_code = #{fStoreyCode}
</update>
<update id="updateStatusByTrayCode" parameterType="TTrayInfo">
update t_tray_info
set f_status = #{fStatus}
where f_tray_code = #{fTrayCode}
</update>
<update id="updateStatusByTrayId" parameterType="TTrayInfo">
update t_tray_info
set f_status = #{fStatus}
......
......@@ -57,7 +57,8 @@
:class="{
'active': activeCell === index,
'empty': !device.deviceCode,
'error': device.deviceCode && (device.status === '0' || device.status === '5')
'error': device.deviceCode && (device.status === '0' || device.status === '5'),
'duplicate': device.isDuplicate
}"
@click="setActiveCell(index)"
>
......@@ -65,6 +66,8 @@
{{ device.deviceCode || '+' }}
<!-- 添加错误状态图标 -->
<i v-if="device.deviceCode && device.status === '0'" class="error-icon fas fa-exclamation-circle"></i>
<!-- 添加重复状态图标 -->
<i v-if="device.isDuplicate" class="duplicate-icon fas fa-exclamation-triangle"></i>
</div>
<div class="position-indicator">
{{ getPositionLabel(index) }}
......@@ -200,7 +203,8 @@ export default {
number: number,
deviceCode: '',
row: row,
col: col
col: col,
isDuplicate: false // 添加重复标记属性
}
}),
......@@ -265,7 +269,10 @@ export default {
this.devices = [];
getAllExcludeUnbindingTimeByTrayId(trayId).then(res => {
if(res.code === 200 && res.data.length > 0) {
this.devices = res.data;
this.devices = res.data.map(device => ({
...device,
isDuplicate: false // 确保每个设备都有isDuplicate属性
}));
// 计算初始异常设备数量(标定完成状态)
if (this.trayStatus === '3') {
......@@ -275,6 +282,9 @@ export default {
this.initialAbnormalCount = this.abnormalCount;
}
// 检查重复设备
this.checkDuplicateDevices();
const firstDeviceCodeEmptyItem = this.devices.find(item =>
item.deviceCode === null ||
item.deviceCode === undefined ||
......@@ -316,7 +326,8 @@ export default {
number: number,
deviceCode: '',
row: row,
col: col
col: col,
isDuplicate: false // 添加重复标记属性
}
})
}
......@@ -338,7 +349,6 @@ export default {
// 添加设备到当前激活单元格
addDevice() {
// 清除计时器(避免重复触发)
if (this.inputTimer) {
clearTimeout(this.inputTimer);
......@@ -348,7 +358,6 @@ export default {
// 原有逻辑:如果输入为空则不处理
if (!this.deviceInput.trim()) return;
if (this.deviceInput) {
// 标定完成状态下的特殊处理 - 改为解绑操作
if (this.trayStatus === '3') {
......@@ -366,7 +375,33 @@ export default {
}
} else {
// 空闲状态下的正常处理
this.devices[this.activeCell].deviceCode = this.deviceInput;
const trimmedInput = this.deviceInput.trim();
// 检查设备号是否已存在(排除当前单元格自身)
const existingIndex = this.devices.findIndex(
(d, idx) => idx !== this.activeCell && d.deviceCode === trimmedInput
);
if (existingIndex !== -1) {
// 发现重复设备号
this.$message.error({
message: `设备 ${trimmedInput} 已存在于位置 ${existingIndex + 1} 中,请勿重复添加`,
duration: 3000
});
// 高亮显示重复的单元格
this.highlightDuplicateCell(existingIndex);
// 清空输入框但不执行添加操作
this.deviceInput = '';
return;
}
// 如果没有重复,则正常添加设备
this.devices[this.activeCell].deviceCode = trimmedInput;
// 添加后重新检查重复状态
this.checkDuplicateDevices();
// 自动移动到下一个单元格
if (this.activeCell < 71) {
......@@ -380,6 +415,52 @@ export default {
}
},
// 检查所有设备的重复状态
checkDuplicateDevices() {
const deviceCodeMap = {};
// 统计每个设备码出现的次数
this.devices.forEach(device => {
if (device.deviceCode && device.deviceCode.trim()) {
deviceCodeMap[device.deviceCode] = (deviceCodeMap[device.deviceCode] || 0) + 1;
}
});
// 标记重复的设备
this.devices.forEach(device => {
if (device.deviceCode && device.deviceCode.trim()) {
device.isDuplicate = deviceCodeMap[device.deviceCode] > 1;
} else {
device.isDuplicate = false;
}
});
},
// 高亮显示重复的单元格
highlightDuplicateCell(index) {
// 先清除之前可能存在的重复高亮
this.clearDuplicateHighlights();
// 为重复的单元格添加高亮标记
this.devices[index].isDuplicate = true;
// 设置一个定时器,2秒后清除高亮
setTimeout(() => {
this.clearDuplicateHighlights();
// 重新检查重复状态
this.checkDuplicateDevices();
}, 2000);
},
// 清除所有重复高亮标记
clearDuplicateHighlights() {
this.devices.forEach(device => {
if (device.isDuplicate) {
device.isDuplicate = false;
}
});
},
// 确认解绑设备
confirmUnbind(deviceIndex) {
const device = this.devices[deviceIndex];
......@@ -401,28 +482,27 @@ export default {
const device = this.devices[deviceIndex];
// 调用解绑方法,传递设备信息和palletDeviceBindingId
this.unbindDevice(device.deviceCode, device.palletDeviceBindingId, deviceIndex);
},
// 解绑单个设备
unbindDevice(deviceCode, palletDeviceBindingId, deviceIndex) {
// 这里调用您的后台解绑逻辑
// 示例:假设您有一个解绑接口
let palletDeviceBinding = {
deviceCode: deviceCode,
palletDeviceBindingId: palletDeviceBindingId
deviceCode: device.deviceCode,
palletDeviceBindingId: device.palletDeviceBindingId
}
unbindSingleDevice(palletDeviceBinding).then(res => {
if (res.code === 200) {
// 解绑成功后的处理
this.devices[deviceIndex].deviceCode = '';
// 清除重复标记
this.devices[deviceIndex].isDuplicate = false;
// 重新检查重复状态
this.checkDuplicateDevices();
// 如果是异常设备,减少异常计数
if (this.devices[deviceIndex].status === '0' || this.devices[deviceIndex].status === '5') {
this.abnormalCount--;
}
this.$message.success(`设备 ${deviceCode} 解绑成功`);
this.$message.success(`设备 ${device.deviceCode} 解绑成功`);
} else {
this.$message.error("解绑失败");
}
......@@ -443,13 +523,15 @@ export default {
cancelButtonText: '取消',
type: 'error'
}).then(() => {
// 调用解绑接口(假设后端有对应的解绑接口,若无则需根据实际逻辑调整)
// 这里复用现有resetAll接口或替换为实际解绑接口
unbindAllDevice(this.fTrayId).then(res => {
if (res.code === 200) {
// 解绑成功后重置设备矩阵
this.devices = this.devices.map(d => ({ ...d, deviceCode: '', status: '1' }));
this.devices = this.devices.map(d => ({
...d,
deviceCode: '',
status: '1',
isDuplicate: false
}));
this.abnormalCount = this.devices.length; // 重置异常计数为总设备数
this.initialAbnormalCount = this.abnormalCount;
this.deviceInput = '';
......@@ -508,7 +590,12 @@ export default {
resetAll(this.fTrayId).then(res => {
if (res.code === 200) {
this.deviceInput = '';
this.devices = this.devices.map(d => ({ ...d, deviceCode: '' }));
// 重置时也清除重复标记
this.devices = this.devices.map(d => ({
...d,
deviceCode: '',
isDuplicate: false
}));
this.activeCell = 0;
this.$nextTick(() => {
this.$refs.deviceInput.focus();
......@@ -759,6 +846,7 @@ body {
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
max-height: 40px;
position: relative;
}
.device-cell.empty .device-id {
......@@ -949,11 +1037,16 @@ body {
top: -8px;
right: -8px;
color: #ff4d4f;
font-size: 18px;
font-size: 16px;
background: rgba(10, 20, 40, 0.9);
border-radius: 50%;
z-index: 2;
animation: pulseIcon 1.5s infinite;
width: 20px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
}
@keyframes pulseIcon {
......@@ -962,11 +1055,43 @@ body {
100% { transform: scale(1); }
}
/* 调整设备ID显示区域,为错误图标留出空间 */
/* 设备单元格重复状态样式 */
.device-cell.duplicate {
border-color: #ff9800 !important;
box-shadow: 0 0 10px rgba(255, 152, 0, 0.6) !important;
background: rgba(255, 152, 0, 0.1) !important;
}
/* 重复状态图标 */
.duplicate-icon {
position: absolute;
top: -8px;
left: -8px;
color: #ff9800;
font-size: 16px;
background: rgba(10, 20, 40, 0.9);
border-radius: 50%;
z-index: 2;
animation: pulseDuplicate 1s infinite;
width: 20px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
}
@keyframes pulseDuplicate {
0% { transform: scale(1); color: #ff9800; }
50% { transform: scale(1.2); color: #ff5722; }
100% { transform: scale(1); color: #ff9800; }
}
/* 调整设备ID显示区域,为重复图标留出空间 */
.device-id {
position: relative;
padding-top: 5px;
padding-right: 15px;
padding-left: 15px; /* 增加左侧内边距,防止文字与图标重叠 */
}
/* 一键解绑按钮样式 */
......
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