Commit 0158886c authored by wanghao's avatar wanghao

1 托盘和板子绑定 和 解绑处理,涉及到的 老化数据清理。

parent 949911b8
......@@ -52,6 +52,15 @@ public class PalletDeviceBindingController extends BaseController
return AjaxResult.success(palletDeviceBindingService.selectPalletDeviceBindingList(palletDeviceBinding));
}
/**
* 获取所有托盘绑定的设备列列表(排除已解除绑定的设备)
*/
@GetMapping("/getAllExcludeUnbindingTimeByTrayId/{trayId}")
public AjaxResult getAllExcludeUnbindingTimeByTrayId(@PathVariable("trayId") Long trayId) {
return AjaxResult.success(palletDeviceBindingService.getAllExcludeUnbindingTimeByTrayId(trayId));
}
/**
* 导出托盘绑定的设备列列表
*/
......@@ -109,6 +118,12 @@ public class PalletDeviceBindingController extends BaseController
return toAjax(palletDeviceBindingService.batchUpdateDeviceCode(palletDeviceBindings));
}
@PostMapping("/batchUpdateDeviceCodeAndUnbindingTime")
public AjaxResult batchUpdateDeviceCodeAndUnbindingTime(@RequestBody List<PalletDeviceBinding> palletDeviceBindings) {
return toAjax(palletDeviceBindingService.batchUpdateDeviceCodeAndUnbindingTime(palletDeviceBindings));
}
/**
* 修改托盘绑定的设备列
*/
......@@ -118,6 +133,26 @@ public class PalletDeviceBindingController extends BaseController
return toAjax(palletDeviceBindingService.updatePalletDeviceBinding(palletDeviceBinding));
}
/**
* 解绑设备
* @param palletDeviceBinding p
* @return l
*/
@PostMapping("/unbindDevice")
public AjaxResult unbindDevice(@RequestBody PalletDeviceBinding palletDeviceBinding) {
return palletDeviceBindingService.unbindDevice(palletDeviceBinding);
}
/**
* 解绑所有设备
* @param trayId t
* @return l
*/
@GetMapping("/unbindAllDevice/{trayId}")
public AjaxResult unbindAllDevice(@PathVariable("trayId") Long trayId) {
return palletDeviceBindingService.unbindAllDevice(trayId);
}
/**
* 删除托盘绑定的设备列
*/
......
......@@ -36,6 +36,8 @@ public interface PalletDeviceBindingMapper
*/
public List<PalletDeviceBinding> selectPalletDeviceBindingList(PalletDeviceBinding palletDeviceBinding);
public List<PalletDeviceBinding> getAllExcludeUnbindingTimeByTrayId(Long trayId);
public int countErrorByTrayId(Long trayId);
/**
......@@ -60,8 +62,14 @@ public interface PalletDeviceBindingMapper
*/
public int updatePalletDeviceBinding(PalletDeviceBinding palletDeviceBinding);
public int unbindDevice(Long palletDeviceBindingId);
public int batchUpdateDeviceCode(@Param("palletDeviceBindingList") List<PalletDeviceBinding> palletDeviceBindingList);
public int batchUpdateDeviceCodeAndUnbindingTime(@Param("palletDeviceBindingList") List<PalletDeviceBinding> palletDeviceBindingList);
public int unbindAllDevice(Long trayId);
/**
* 删除托盘绑定的设备列
*
......
......@@ -55,6 +55,10 @@ public interface TTrayInfoMapper
public int updateStatusByTrayCode(TTrayInfo tTrayInfo);
public int updateStatusByTrayId(TTrayInfo tTrayInfo);
public int updateToBoundWhenStateIsIdle(Long trayId);
public int unbindByCode(TTrayInfo tTrayInfo);
/**
* 删除托盘信息
......
......@@ -29,6 +29,8 @@ public interface IPalletDeviceBindingService
*/
public List<PalletDeviceBinding> selectPalletDeviceBindingList(PalletDeviceBinding palletDeviceBinding);
public List<PalletDeviceBinding> getAllExcludeUnbindingTimeByTrayId(Long trayId);
/**
* 新增托盘绑定的设备列
*
......@@ -42,6 +44,9 @@ public interface IPalletDeviceBindingService
public int batchInsertPalletDeviceBinding(List<PalletDeviceBinding> palletDeviceBindingList);
public int batchUpdateDeviceCode(List<PalletDeviceBinding> palletDeviceBindingList);
public int batchUpdateDeviceCodeAndUnbindingTime(List<PalletDeviceBinding> palletDeviceBindingList);
/**
* 修改托盘绑定的设备列
*
......@@ -50,6 +55,10 @@ public interface IPalletDeviceBindingService
*/
public int updatePalletDeviceBinding(PalletDeviceBinding palletDeviceBinding);
public AjaxResult unbindDevice(PalletDeviceBinding palletDeviceBinding);
public AjaxResult unbindAllDevice(Long trayId);
/**
* 批量删除托盘绑定的设备列
*
......
......@@ -46,6 +46,8 @@ public interface ITTrayInfoService
public int updateStatusByTrayCode(TTrayInfo tTrayInfo);
public int updateStatusByTrayId(TTrayInfo tTrayInfo);
/**
* 批量删除托盘信息
*
......
......@@ -4,6 +4,8 @@ import java.util.List;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.TTrayInfo;
import com.zehong.system.mapper.TTrayInfoMapper;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.PalletDeviceBindingMapper;
......@@ -51,6 +53,18 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
return palletDeviceBindingMapper.selectPalletDeviceBindingList(palletDeviceBinding);
}
/**
* 获取所有未解除绑定的托盘绑定的设备列
*
* @param trayId 托盘ID
* @return 列表
*/
@Override
public List<PalletDeviceBinding> getAllExcludeUnbindingTimeByTrayId(Long trayId) {
return palletDeviceBindingMapper.getAllExcludeUnbindingTimeByTrayId(trayId);
}
/**
* 新增托盘绑定的设备列
*
......@@ -98,6 +112,12 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
palletDeviceBinding.setCreateTime(DateUtils.getNowDate());
palletDeviceBinding.setBindingTime(DateUtils.getNowDate());
});
TTrayInfo tTrayInfo = new TTrayInfo();
tTrayInfo.setfTrayId(palletDeviceBindingList.get(0).getTrayId());
tTrayInfo.setfStatus("4");
tTrayInfoMapper.updateStatusByTrayId(tTrayInfo);
return palletDeviceBindingMapper.batchInsertPalletDeviceBinding(palletDeviceBindingList);
}
......@@ -107,9 +127,24 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
palletDeviceBinding.setStatus("1");
palletDeviceBinding.setUpdateTime(DateUtils.getNowDate());
});
tTrayInfoMapper.updateToBoundWhenStateIsIdle(palletDeviceBindingList.get(0).getTrayId());
return palletDeviceBindingMapper.batchUpdateDeviceCode(palletDeviceBindingList);
}
@Override
public int batchUpdateDeviceCodeAndUnbindingTime(List<PalletDeviceBinding> palletDeviceBindingList) {
palletDeviceBindingList.forEach(palletDeviceBinding -> {
palletDeviceBinding.setStatus("1");
palletDeviceBinding.setUpdateTime(DateUtils.getNowDate());
});
tTrayInfoMapper.updateToBoundWhenStateIsIdle(palletDeviceBindingList.get(0).getTrayId());
return palletDeviceBindingMapper.batchUpdateDeviceCodeAndUnbindingTime(palletDeviceBindingList);
}
/**
* 修改托盘绑定的设备列
*
......@@ -145,4 +180,59 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
{
return palletDeviceBindingMapper.deletePalletDeviceBindingById(palletDeviceBindingId);
}
/**
* 批量解绑所有设备
*
* @param trayId 托盘ID
* @return 删除结果
*/
@Override
public AjaxResult unbindAllDevice(Long trayId) {
if(trayId == null) {
return AjaxResult.error("参数错误");
}
int i = palletDeviceBindingMapper.unbindAllDevice(trayId);
if(i <=0) {
return AjaxResult.error("无设备绑定");
}
int i1 = tTrayInfoMapper.initStatusByTrayId(trayId);
if(i1 <=0) {
return AjaxResult.error("更新托盘状态失败");
}
return AjaxResult.success();
}
/**
* 解绑设备
*
* @param palletDeviceBinding 托盘绑定的设备列ID
* @return 删除结果
*/
@Override
public AjaxResult unbindDevice(PalletDeviceBinding palletDeviceBinding) {
if(palletDeviceBinding.getPalletDeviceBindingId() == null || StringUtils.isBlank(palletDeviceBinding.getDeviceCode())) {
return AjaxResult.error("参数错误");
}
PalletDeviceBinding palletDeviceBindingDb = palletDeviceBindingMapper.selectPalletDeviceBindingById(palletDeviceBinding.getPalletDeviceBindingId());
if(palletDeviceBindingDb == null) {
return AjaxResult.error("数据不存在");
}
if(!palletDeviceBindingDb.getDeviceCode().equals(palletDeviceBinding.getDeviceCode())) {
return AjaxResult.error("设备码错误");
}
int i = palletDeviceBindingMapper.unbindDevice(palletDeviceBindingDb.getPalletDeviceBindingId());
if (i > 0) {
return AjaxResult.success();
}
return AjaxResult.error();
}
}
......@@ -84,6 +84,11 @@ public class TTrayInfoServiceImpl implements ITTrayInfoService
return tTrayInfoMapper.updateStatusByTrayCode(tTrayInfo);
}
@Override
public int updateStatusByTrayId(TTrayInfo tTrayInfo) {
return tTrayInfoMapper.initStatusByTrayId(tTrayInfo.getfTrayId());
}
/**
* 批量删除托盘信息
*
......
......@@ -70,6 +70,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null "> and palDeviceBinding.f_create_time = #{createTime}</if>
<if test="status != null and status != '' "> and palDeviceBinding.f_status = #{status}</if>
</where>
order by palDeviceBinding.f_index asc
</select>
<select id="getAllExcludeUnbindingTimeByTrayId" parameterType="long" resultMap="PalletDeviceBindingResult">
<include refid="selectPalletDeviceBindingVo"/>
where palDeviceBinding.f_tray_id = #{trayId}
order by palDeviceBinding.f_index asc
</select>
<select id="selectPalletDeviceBindingById" parameterType="Long" resultMap="PalletDeviceBindingResult">
......@@ -108,13 +114,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<insert id="batchInsertPalletDeviceBinding" parameterType="list">
insert into t_pallet_device_binding (f_tray_id, f_device_code,f_row,f_col,f_index,f_binding_time,f_unbinding_time,
insert into t_pallet_device_binding (f_tray_id, f_device_code,f_row,f_col,f_index,f_binding_time,f_binding_time,
f_create_time,f_status)
values
<foreach collection="palletDeviceBindingList" item="item" index="index" separator=",">
(
#{item.trayId}, #{item.deviceCode}, #{item.row}, #{item.col}, #{item.index},#{item.bindingTime},
#{item.unbindingTime},#{item.createTime},#{item.status}
#{item.bindingTime},#{item.createTime},#{item.status}
)
</foreach>
</insert>
......@@ -161,11 +167,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<update id="unbindDevice" parameterType="long">
update t_pallet_device_binding
set f_device_code = null,
f_unbinding_time = NOW(),
f_record_year = null,
f_record_month = null,
f_record_date = null,
f_record_hour = null,
f_record_minute = null,
f_write_time_status = null,
f_adjustment_zero_ad = null,
f_calibration_ad = null,
f_concentration = null
where f_pallet_device_binding_id = #{palletDeviceBindingId}
</update>
<update id="updatePalletDeviceBinding" parameterType="PalletDeviceBinding">
update t_pallet_device_binding
<trim prefix="SET" suffixOverrides=",">
<if test="trayId != null">f_tray_id = #{trayId},</if>
<if test="deviceCode != null">f_device_code = #{deviceCode},</if>
<if test="deviceCode == null">f_device_code = null,</if>
<if test="row != null">f_row = #{row},</if>
<if test="col != null">f_col = #{col},</if>
<if test="index != null">f_index = #{index},</if>
......@@ -189,12 +211,49 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="batchUpdateDeviceCode" parameterType="list">
<foreach collection="palletDeviceBindingList" item="item" index="index" separator=";">
UPDATE t_pallet_device_binding
<set>
f_device_code = #{item.deviceCode}
</set>
<trim prefix="SET" suffixOverrides=",">
<if test="item.deviceCode != null">f_device_code = #{item.deviceCode},</if>
<if test="item.deviceCode == null">f_device_code = null,</if>
</trim>
WHERE f_pallet_device_binding_id = #{item.palletDeviceBindingId}
</foreach>
</update>
<update id="batchUpdateDeviceCodeAndUnbindingTime" parameterType="list">
<foreach collection="palletDeviceBindingList" item="item" index="index" separator=";">
UPDATE t_pallet_device_binding
<trim prefix="SET" suffixOverrides=",">
f_unbinding_time = null,
f_binding_time = NOW(),
f_record_year = null,
f_record_month = null,
f_record_date = null,
f_record_hour = null,
f_record_minute = null,
f_write_time_status = null,
f_adjustment_zero_ad = null,
f_calibration_ad = null,
f_concentration = null,
<if test="item.deviceCode != null">f_device_code = #{item.deviceCode},</if>
</trim>
WHERE f_pallet_device_binding_id = #{item.palletDeviceBindingId}
</foreach>
</update>
<update id="unbindAllDevice" parameterType="long">
update t_pallet_device_binding
set f_device_code = null,
f_unbinding_time = NOW(),
f_status = '1',
f_record_year = null,
f_record_month = null,
f_record_date = null,
f_record_hour = null,
f_record_minute = null,
f_write_time_status = null,
f_adjustment_zero_ad = null,
f_calibration_ad = null,
f_concentration = null
where f_tray_id = #{trayId}
</update>
<delete id="deletePalletDeviceBindingById" parameterType="Long">
delete from t_pallet_device_binding where f_pallet_device_binding_id = #{palletDeviceBindingId}
......
......@@ -94,6 +94,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
set f_status = #{fStatus}
where f_storey_code = #{fStoreyCode}
</update>
<update id="updateStatusByTrayId" parameterType="TTrayInfo">
update t_tray_info
set f_status = #{fStatus}
where f_tray_id = #{fTrayId}
</update>
<update id="updateToBoundWhenStateIsIdle" parameterType="long">
update t_tray_info
set f_status = '4' where f_status = '0' and f_tray_id = #{fTrayId}
</update>
<update id="clearStoreyCodeByStoreyCode" parameterType="string">
update t_tray_info
set f_storey_code = null
......
......@@ -18,6 +18,13 @@ export function getAllBinding(query) {
})
}
export function getAllExcludeUnbindingTimeByTrayId(trayId) {
return request({
url: '/palletDevice/binding/getAllExcludeUnbindingTimeByTrayId/' + trayId,
method: 'get'
})
}
// 查询托盘绑定的设备列详细
export function getBinding(palletDeviceBindingId) {
return request({
......@@ -44,6 +51,21 @@ export function batchAdd(data) {
})
}
export function unbindSingleDevice(data){
return request({
url: '/palletDevice/binding/unbindDevice/',
method: 'post',
data: data
})
}
export function unbindAllDevice(trayId){
return request({
url: '/palletDevice/binding/unbindAllDevice/' + trayId,
method: 'get'
})
}
// 修改托盘绑定的设备列
export function updateBinding(data) {
return request({
......@@ -62,6 +84,14 @@ export function batchUpdateDeviceCode(data) {
})
}
export function batchUpdateDeviceCodeAndUnbindingTime(data) {
return request({
url: '/palletDevice/binding/batchUpdateDeviceCodeAndUnbindingTime',
method: 'post',
data: data
})
}
// 删除托盘绑定的设备列
export function delBinding(palletDeviceBindingId) {
return request({
......
......@@ -30,93 +30,98 @@
style="align-items: center;"
v-if="trayStatus !== '1'"
>
<input
type="text"
class="scan-input"
:placeholder="scanPlaceholder"
v-model="deviceInput"
@keyup.enter="addDevice"
ref="deviceInput"
:disabled="trayStatus === '1'"
>
<div class="status-bar">
<i class="fas fa-info-circle"></i>
<span v-if="trayStatus === '0'">已绑定设备: <span class="filled-count">{{ filledCount }}</span>/72</span>
<span v-if="trayStatus === '3'">待处理异常设备: <span class="filled-count">{{ abnormalCount }}</span>/{{ initialAbnormalCount }}</span>
<input
type="text"
class="scan-input"
:placeholder="scanPlaceholder"
v-model="deviceInput"
@keyup.enter="addDevice"
ref="deviceInput"
:disabled="trayStatus === '1'"
>
<div class="status-bar">
<i class="fas fa-info-circle"></i>
<span v-if="trayStatus === '0'">已绑定设备: <span class="filled-count">{{ filledCount }}</span>/72</span>
<span v-if="trayStatus === '3'">待处理异常设备: <span class="filled-count">{{ abnormalCount }}</span>/{{ initialAbnormalCount }}</span>
</div>
</div>
</div>
</div>
<!-- 设备矩阵区域 -->
<div class="devices-grid-container">
<div class="devices-grid">
<div
v-for="(device, index) in devices"
:key="index"
class="device-cell"
:class="{
<!-- 设备矩阵区域 -->
<div class="devices-grid-container">
<div class="devices-grid">
<div
v-for="(device, index) in devices"
:key="index"
class="device-cell"
:class="{
'active': activeCell === index,
'empty': !device.deviceCode,
'error': device.deviceCode && (device.status === '0' || device.status === '5')
}"
@click="setActiveCell(index)"
>
<div class="device-id">
{{ device.deviceCode || '+' }}
<!-- 添加错误状态图标 -->
<i v-if="device.deviceCode && device.status === '0'" class="error-icon fas fa-exclamation-circle"></i>
</div>
<div class="position-indicator">
{{ getPositionLabel(index) }}
@click="setActiveCell(index)"
>
<div class="device-id">
{{ device.deviceCode || '+' }}
<!-- 添加错误状态图标 -->
<i v-if="device.deviceCode && device.status === '0'" class="error-icon fas fa-exclamation-circle"></i>
</div>
<div class="position-indicator">
{{ getPositionLabel(index) }}
</div>
</div>
</div>
</div>
</div>
<!-- 操作按钮区域 -->
<div class="binding-controls">
<button
class="reset-btn"
@click="resetAll"
>
<i class="fas fa-redo"></i> 重置所有
</button>
<button
class="bind-btn"
@click="bindTray"
:disabled="bindButtonDisabled"
>
<i class="fas fa-paper-plane"></i>
{{ trayStatus === '3' ? '提交修复' : '提交绑定' }}
</button>
<!-- 一键解绑按钮 - 仅status=3时显示 -->
<button
v-if="trayStatus === '3'"
class="unbind-btn"
@click="unbindAll"
>
<i class="fas fa-unlink"></i> 一键解绑
</button>
</div>
<!-- 操作按钮区域 -->
<div class="binding-controls">
<button
v-if="trayStatus === '0'"
class="reset-btn"
@click="resetAll"
>
<i class="fas fa-redo"></i> 重置所有
</button>
<button
v-if="trayStatus === '0' || trayStatus === '4'"
class="bind-btn"
@click="bindTray"
:disabled="bindButtonDisabled"
>
<i class="fas fa-paper-plane"></i>
{{ '提交绑定' }}
</button>
<!-- 一键解绑按钮 - 仅status=3时显示 -->
<button
v-if="trayStatus === '3'"
class="unbind-btn"
@click="unbindAll"
>
<i class="fas fa-unlink"></i> 一键解绑
</button>
</div>
<!-- 使用说明区域 -->
<div class="instructions">
<h3><i class="fas fa-lightbulb"></i> 使用说明</h3>
<ul>
<li v-if="trayStatus === '0'"> 点击矩阵中的单元格或按顺序扫描<span class="highlight">设备条码</span>(扫描枪自动识别)</li>
<li v-if="trayStatus === '0'"> 设备条码会自动填充到当前激活的单元格中</li>
<li v-if="trayStatus === '3'"> 请扫描异常设备条码进行修复处理</li>
<li v-if="trayStatus === '3'"> 每修复一个异常设备,待处理数量将减少</li>
<li> 可以手动点击任何单元格进行修改或重新扫描</li>
<li> 完成操作后,点击<span class="highlight">{{ trayStatus === '3' ? '提交修复' : '提交绑定' }}</span>按钮</li>
<li><i class="fas fa-bolt scanner-icon"></i> 提示:使用扫描枪时,请确保输入框获得焦点</li>
</ul>
</div>
<!-- 使用说明区域 -->
<div class="instructions">
<h3><i class="fas fa-lightbulb"></i> 使用说明</h3>
<ul>
<li v-if="trayStatus === '0'"> 点击矩阵中的单元格或按顺序扫描<span class="highlight">设备条码</span>(扫描枪自动识别)</li>
<li v-if="trayStatus === '0'"> 设备条码会自动填充到当前激活的单元格中</li>
<li v-if="trayStatus === '3'"> 请扫描设备条码进行解绑</li>
<li v-if="trayStatus === '3'"> 每解绑一个异常设备,待处理数量将减少</li>
<li> 可以手动点击任何单元格进行修改或重新扫描</li>
<li><i class="fas fa-bolt scanner-icon"></i> 提示:使用扫描枪时,请确保输入框获得焦点</li>
</ul>
</div>
</div>
</template>
<script>
import {getAllBinding, batchAdd, batchUpdateDeviceCode} from "@/api/palletDeviceBinding/binding"
import {
batchAdd,
unbindSingleDevice,
getAllExcludeUnbindingTimeByTrayId, unbindAllDevice, batchUpdateDeviceCodeAndUnbindingTime
} from "@/api/palletDeviceBinding/binding"
import {resetAll} from "@/api/palletDeviceBinding/binding"
export default {
name: "TrayBinding",
......@@ -197,7 +202,7 @@ export default {
// 计算绑定按钮是否禁用
bindButtonDisabled() {
if (this.trayStatus === '0') {
if (this.trayStatus === '0' || this.trayStatus === '4') {
return this.filledCount === 0 || !this.fTrayCode;
} else if (this.trayStatus === '3') {
return this.abnormalCount > 0;
......@@ -211,7 +216,8 @@ export default {
'0': 'success', // 空闲 - 绿色
'1': 'primary', // 运行中 - 黄色
'2': 'danger', // 老化完成 - 红色
'3': 'warning' // 标定完成
'3': 'warning', // 标定完成
'4': 'info' // 标定完成
};
return map[this.trayStatus] || 'info';
},
......@@ -222,7 +228,8 @@ export default {
'0': '空闲',
'1': '运行中',
'2': '老化完成',
'3': '标定完成'
'3': '标定完成',
'4': '已绑定'
};
return map[this.trayStatus] || '未知状态';
},
......@@ -230,17 +237,14 @@ export default {
// 扫描输入框提示语
scanPlaceholder() {
return this.trayStatus === '3'
? '扫描异常设备条码...'
? '解绑设备条码...'
: '扫描设备条码...';
}
},
methods: {
getAllBindingData(trayId) {
const query = {
trayId: trayId
}
this.devices = [];
getAllBinding(query).then(res => {
getAllExcludeUnbindingTimeByTrayId(trayId).then(res => {
if(res.code === 200 && res.data.length > 0) {
this.devices = res.data;
......@@ -308,31 +312,19 @@ export default {
if (this.deviceInput) {
// 标定完成状态下的特殊处理
// 标定完成状态下的特殊处理 - 改为解绑操作
if (this.trayStatus === '3') {
// 检查扫描的设备是否是异常设备
// 检查扫描的设备是否存在
const deviceIndex = this.devices.findIndex(
d => d.deviceCode === this.deviceInput && (d.status === '0' || d.status === '5')
d => d.deviceCode === this.deviceInput
);
if (deviceIndex !== -1) {
// 找到异常设备,进行修复
this.devices[deviceIndex].status = '1'; // 标记为已修复
this.abnormalCount--; // 减少异常设备计数
// 提示修复成功
this.$message.success(`设备 ${this.deviceInput} 修复成功!`);
// 自动移动到下一个单元格
// if (this.activeCell < 71) {
// this.activeCell++;
// } else {
// this.activeCell = 0;
// }
this.activeCell = deviceIndex;
// 找到设备,确认解绑
this.confirmUnbind(deviceIndex);
} else {
// 非异常设备提示
this.$message.warning(`设备 ${this.deviceInput}是异常设备或不存在`);
// 设备不存在提示
this.$message.warning(`设备 ${this.deviceInput}存在或未绑定`);
}
} else {
// 空闲状态下的正常处理
......@@ -350,13 +342,63 @@ export default {
}
},
// 确认解绑设备
confirmUnbind(deviceIndex) {
const device = this.devices[deviceIndex];
this.$confirm(`确认解绑设备 ${device.deviceCode} 吗?`, '解绑确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// 用户确认解绑
this.executeUnbind(deviceIndex);
}).catch(() => {
// 用户取消解绑
this.$message.info('已取消解绑操作');
});
},
// 执行解绑操作
executeUnbind(deviceIndex) {
const device = this.devices[deviceIndex];
// 调用解绑方法,传递设备信息和palletDeviceBindingId
this.unbindDevice(device.deviceCode, device.palletDeviceBindingId, deviceIndex);
},
// 解绑单个设备
unbindDevice(deviceCode, palletDeviceBindingId, deviceIndex) {
// 这里调用您的后台解绑逻辑
// 示例:假设您有一个解绑接口
let palletDeviceBinding = {
deviceCode: deviceCode,
palletDeviceBindingId: palletDeviceBindingId
}
unbindSingleDevice(palletDeviceBinding).then(res => {
if (res.code === 200) {
// 解绑成功后的处理
this.devices[deviceIndex].deviceCode = '';
// 如果是异常设备,减少异常计数
if (this.devices[deviceIndex].status === '0' || this.devices[deviceIndex].status === '5') {
this.abnormalCount--;
}
this.$message.success(`设备 ${deviceCode} 解绑成功`);
} else {
this.$message.error("解绑失败");
}
})
},
// 获取位置标签 (行-列)
getPositionLabel(index) {
const row = Math.floor(index / 9) + 1;
const col = (index % 9) + 1;
return `${row}-${col}`;
},
// 一键解绑所有设备
// 一键解绑所有设备
unbindAll() {
this.$confirm('确定要解绑当前托盘下所有设备吗?', '警告', {
confirmButtonText: '确定',
......@@ -366,25 +408,26 @@ export default {
// 调用解绑接口(假设后端有对应的解绑接口,若无则需根据实际逻辑调整)
// 这里复用现有resetAll接口或替换为实际解绑接口
this.$message.success("好的,已经解绑了");
// resetAll(this.fTrayId).then(res => {
// if (res.code === 200) {
// // 解绑成功后重置设备矩阵
// this.devices = this.devices.map(d => ({ ...d, deviceCode: '', status: '0' }));
// this.abnormalCount = this.devices.length; // 重置异常计数为总设备数
// this.initialAbnormalCount = this.abnormalCount;
// this.deviceInput = '';
// this.activeCell = 0;
// this.$message.success("一键解绑成功");
// } else {
// this.$message.error("解绑失败");
// }
// })
unbindAllDevice(this.fTrayId).then(res => {
if (res.code === 200) {
// 解绑成功后重置设备矩阵
this.devices = this.devices.map(d => ({ ...d, deviceCode: '', status: '1' }));
this.abnormalCount = this.devices.length; // 重置异常计数为总设备数
this.initialAbnormalCount = this.abnormalCount;
this.deviceInput = '';
this.activeCell = 0;
this.trayStatus = '0';
this.$message.success("一键解绑成功");
} else {
this.$message.error("解绑失败");
}
})
}).catch(() => {});
},
// 绑定托盘
bindTray: function () {
if (this.trayStatus === '0') {
if (this.trayStatus === '0' || this.trayStatus === '4') {
// 空闲状态 - 绑定设备
const palletDeviceBindingId = this.devices[0].palletDeviceBindingId;
if (this.filledCount > 0) {
......@@ -397,9 +440,12 @@ export default {
}
})
} else {
batchUpdateDeviceCode(this.devices).then(res => {
batchUpdateDeviceCodeAndUnbindingTime(this.devices).then(res => {
if (res.code === 200) {
this.msgSuccess("绑定成功");
if(this.trayStatus === '0') {
this.trayStatus = '4';
}
} else {
this.msgError("绑定失败");
}
......@@ -407,17 +453,11 @@ export default {
}
}
} else if (this.trayStatus === '3') {
// 标定完成状态 - 提交修复
batchUpdateDeviceCode(this.devices).then(res => {
if (res.code === 200) {
this.msgSuccess("修复信息提交成功");
this.abnormalCount = 0; // 重置异常计数
} else {
this.msgError("提交失败");
}
})
// 标定完成状态 - 不再需要提交修复,改为解绑操作
// 这里可以保留或移除,根据实际需求
}
},
// 重置所有数据
resetAll() {
this.$confirm('确定要重置所有数据吗?', '提示', {
......
......@@ -53,6 +53,7 @@
<el-tag :type="statusTagType(scope.row.fStatus)" v-if="scope.row.fStatus === '1'" class="status-tag">运行中</el-tag>
<el-tag :type="statusTagType(scope.row.fStatus)" v-else-if="scope.row.fStatus === '2'" class="status-tag">老化完成</el-tag>
<el-tag :type="statusTagType(scope.row.fStatus)" v-else-if="scope.row.fStatus === '3'" class="status-tag">标定完成</el-tag>
<el-tag :type="statusTagType(scope.row.fStatus)" v-else-if="scope.row.fStatus === '4'" class="status-tag">已绑定</el-tag>
<el-tag :type="statusTagType(scope.row.fStatus)" v-else class="status-tag">空闲</el-tag>
</template>
</el-table-column>
......@@ -180,6 +181,7 @@ export default {
'2': 'warning',
'3': 'warning',
'1': 'primary',
'4': 'info',
};
return statusMap[status] || 'info';
},
......
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