Commit 81db12e6 authored by wanghao's avatar wanghao

1 功能模块 清理数据实现

parent 754d5d57
...@@ -163,6 +163,16 @@ public class PalletDeviceBindingController extends BaseController ...@@ -163,6 +163,16 @@ public class PalletDeviceBindingController extends BaseController
return palletDeviceBindingService.unbindAllDeviceNoUploadMes(trayId); return palletDeviceBindingService.unbindAllDeviceNoUploadMes(trayId);
} }
/**
* 根据托盘编号清理数据
* @param trayCode s
* @return l
*/
@GetMapping("/clearDataByTrayCode/{trayCode}")
public AjaxResult clearDataByTrayCode(@PathVariable("trayCode")String trayCode) {
return palletDeviceBindingService.clearDataByTrayCode(trayCode);
}
/** /**
* 删除托盘绑定的设备列 * 删除托盘绑定的设备列
*/ */
......
...@@ -30,7 +30,6 @@ public interface PalletDeviceBindingMapper ...@@ -30,7 +30,6 @@ public interface PalletDeviceBindingMapper
public void updateStoreCodeByTrayId(@Param("fTrayId") Long fTrayId, @Param("storeCode")String storeCode, public void updateStoreCodeByTrayId(@Param("fTrayId") Long fTrayId, @Param("storeCode")String storeCode,
@Param("productStandardInspectionNumber") String productStandardInspectionNumber); @Param("productStandardInspectionNumber") String productStandardInspectionNumber);
/** /**
* 查询托盘绑定的设备列列表 * 查询托盘绑定的设备列列表
* *
......
...@@ -41,6 +41,8 @@ public interface RobotArmCommandMapper ...@@ -41,6 +41,8 @@ public interface RobotArmCommandMapper
public List<RobotArmCommand> findByType(String type); public List<RobotArmCommand> findByType(String type);
public List<RobotArmCommand> selectIsRunningCommandByTrayCode(String trayCode);
/** /**
* 新增机械臂指令 * 新增机械臂指令
* *
...@@ -57,6 +59,8 @@ public interface RobotArmCommandMapper ...@@ -57,6 +59,8 @@ public interface RobotArmCommandMapper
*/ */
public int updateRobotArmCommand(RobotArmCommand robotArmCommand); public int updateRobotArmCommand(RobotArmCommand robotArmCommand);
public int batchUpdateStatus(@Param("status") String status,@Param("list") List<Long> ids);
/** /**
* 更新执行中状态为完成状态 * 更新执行中状态为完成状态
......
...@@ -27,6 +27,8 @@ public interface TTrayInfoMapper ...@@ -27,6 +27,8 @@ public interface TTrayInfoMapper
public int initStatusByTrayId(Long trayId); public int initStatusByTrayId(Long trayId);
public int clearStoreyCodeByTrayId(Long trayId);
/** /**
* 查询托盘信息列表 * 查询托盘信息列表
* *
......
...@@ -65,6 +65,8 @@ public interface IPalletDeviceBindingService ...@@ -65,6 +65,8 @@ public interface IPalletDeviceBindingService
public AjaxResult unbindAllDeviceNoUploadMes(Long trayId); public AjaxResult unbindAllDeviceNoUploadMes(Long trayId);
public AjaxResult clearDataByTrayCode(String trayCode);
/** /**
* 批量删除托盘绑定的设备列 * 批量删除托盘绑定的设备列
* *
......
...@@ -9,10 +9,10 @@ import com.zehong.common.utils.DateUtils; ...@@ -9,10 +9,10 @@ import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils; import com.zehong.common.utils.StringUtils;
import com.zehong.common.utils.http.HttpUtils; import com.zehong.common.utils.http.HttpUtils;
import com.zehong.system.domain.*; import com.zehong.system.domain.*;
import com.zehong.system.mapper.PalletDeviceBindingMapper; import com.zehong.system.mapper.*;
import com.zehong.system.mapper.ProductStandardInspectionMapper;
import com.zehong.system.mapper.TTrayInfoMapper;
import com.zehong.system.service.*; import com.zehong.system.service.*;
import com.zehong.system.task.DeviceTaskScheduler;
import org.quartz.SchedulerException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -47,6 +47,15 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi ...@@ -47,6 +47,15 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
@Resource @Resource
private TTrayInfoMapper tTrayInfoMapper; private TTrayInfoMapper tTrayInfoMapper;
@Resource
private TStoreyInfoMapper tStoreyInfoMapper;
@Resource
private DeviceTaskScheduler deviceTaskScheduler;
@Resource
private RobotArmCommandMapper robotArmCommandMapper;
@Resource @Resource
private ProductStandardInspectionMapper productStandardInspectionMapper; private ProductStandardInspectionMapper productStandardInspectionMapper;
...@@ -251,6 +260,56 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi ...@@ -251,6 +260,56 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
return palletDeviceBindingMapper.deletePalletDeviceBindingById(palletDeviceBindingId); return palletDeviceBindingMapper.deletePalletDeviceBindingById(palletDeviceBindingId);
} }
/**
* 清理数据
*
* @param trayCode 托盘编号
* @return 结果
*/
@Override
public AjaxResult clearDataByTrayCode(String trayCode) {
if(StringUtils.isBlank(trayCode)){
return AjaxResult.error("参数错误");
}
TTrayInfo tTrayInfo = tTrayInfoMapper.selectTTrayInfoByCode(trayCode);
if(tTrayInfo == null){
return AjaxResult.error("无此托盘");
}
if("0".equals(tTrayInfo.getfStatus()) || "3".equals(tTrayInfo.getfStatus())) {
return AjaxResult.error("空闲 或 标定完成 状态不许清理数据");
}
List<RobotArmCommand> robotArmCommands = robotArmCommandMapper.selectIsRunningCommandByTrayCode(trayCode);
if(robotArmCommands.size() != 0) {
List<Long> collect = robotArmCommands.stream().map(RobotArmCommand::getRobotArmCommandId).collect(Collectors.toList());
robotArmCommandMapper.batchUpdateStatus("4",collect);
}
String storeyCode = tTrayInfo.getfStoreyCode();
if(StringUtils.isNotBlank(storeyCode)) {
TStoreyInfo tStoreyInfo = tStoreyInfoMapper.selectTStoreyInfoByCode(storeyCode);
try {
deviceTaskScheduler.cleanExistingTasks(tStoreyInfo.getfStoreyId());
} catch (SchedulerException e) {
throw new RuntimeException(e);
}
tStoreyInfoMapper.unbindByCode(trayCode);
}
// 解绑设备
palletDeviceBindingMapper.unbindAllDevice(tTrayInfo.getfTrayId());
// 初始托盘状态
tTrayInfoMapper.clearStoreyCodeByTrayId(tTrayInfo.getfTrayId());
return AjaxResult.success();
}
/** /**
* 批量解绑所有设备(不处理上传数据) * 批量解绑所有设备(不处理上传数据)
* *
......
...@@ -33,6 +33,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -33,6 +33,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectRobotArmCommandVo"/> <include refid="selectRobotArmCommandVo"/>
where f_type = #{type} and f_status != '4' where f_type = #{type} and f_status != '4'
</select> </select>
<select id="selectIsRunningCommandByTrayCode" parameterType="string" resultMap="RobotArmCommandResult">
<include refid="selectRobotArmCommandVo"/>
where f_tray_code = #{trayCode} and f_status != '4'
</select>
<select id="selectRobotArmCommandList" parameterType="RobotArmCommand" resultMap="RobotArmCommandResult"> <select id="selectRobotArmCommandList" parameterType="RobotArmCommand" resultMap="RobotArmCommandResult">
<include refid="selectRobotArmCommandVo"/> <include refid="selectRobotArmCommandVo"/>
...@@ -136,6 +140,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -136,6 +140,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SET f_status = '2' SET f_status = '2'
WHERE f_status = '1' and f_end_execution_time IS NOT NULL WHERE f_status = '1' and f_end_execution_time IS NOT NULL
</update> </update>
<update id="batchUpdateStatus">
UPDATE t_robot_arm_command
SET f_status = #{status}
WHERE f_robot_arm_command_id IN
<foreach item="item" collection="list" separator="," open="(" close=")">
#{item}
</foreach>
</update>
<!-- 获取待执行的上料指令 --> <!-- 获取待执行的上料指令 -->
<select id="selectPendingLoadingCommands" resultMap="RobotArmCommandResult"> <select id="selectPendingLoadingCommands" resultMap="RobotArmCommandResult">
......
...@@ -116,6 +116,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -116,6 +116,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
set f_status = '0' set f_status = '0'
where f_tray_id = #{fTrayId} where f_tray_id = #{fTrayId}
</update> </update>
<update id="clearStoreyCodeByTrayId" parameterType="long">
update t_tray_info
set f_storey_code = null,
f_status = '0',
f_unbinding_time = null,
f_binding_time = null
where f_tray_id = #{fTrayId}
</update>
<update id="updateTTrayInfo" parameterType="TTrayInfo"> <update id="updateTTrayInfo" parameterType="TTrayInfo">
update t_tray_info update t_tray_info
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
......
...@@ -99,6 +99,14 @@ export function batchUpdateDeviceCodeAndUnbindingTime(data) { ...@@ -99,6 +99,14 @@ export function batchUpdateDeviceCodeAndUnbindingTime(data) {
}) })
} }
export function clearDataByTrayCode(trayCode){
return request({
url: '/palletDevice/binding/clearDataByTrayCode/' + trayCode,
method: 'get'
})
}
// 删除托盘绑定的设备列 // 删除托盘绑定的设备列
export function delBinding(palletDeviceBindingId) { export function delBinding(palletDeviceBindingId) {
return request({ return request({
......
<template>
<el-card class="clean-data-card" shadow="hover">
<div class="clean-data-container">
<el-input
v-model="trayCode"
placeholder="请输入托盘编号"
clearable
class="input-tray"
/>
<el-button
type="primary"
@click="handleClean"
:loading="loading"
>
清理数据
</el-button>
</div>
</el-card>
</template>
<script>
import {clearDataByTrayCode} from "@/api/palletDeviceBinding/binding"
export default {
name: 'CleanData',
data() {
return {
trayCode: '', // 绑定的托盘编号
loading: false // 按钮 loading 状态
};
},
methods: {
// 点击清理按钮
handleClean() {
if (!this.trayCode.trim()) {
this.$message.warning('请输入托盘编号');
return;
}
// 弹出确认框
this.$confirm(`确认清理托盘 ${this.trayCode} 的数据?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// 用户点击确定,开始清理
this.loading = true;
clearDataByTrayCode(this.trayCode)
.then(() => {
this.$message.success('数据清理成功');
// 可选:清理成功后重置输入框
// this.trayCode = '';
})
.finally(() => {
this.loading = false;
});
}).catch(() => {
// 用户点击取消
this.$message.info('已取消清理');
});
},
}
};
</script>
<style scoped>
.clean-data-card {
width: 500px; /* 固定卡片宽度 */
margin: 20px auto; /* 水平居中,上下留一点边距 */
}
.clean-data-container {
display: flex;
align-items: center;
gap: 12px;
}
.input-tray {
flex: 1;
}
</style>
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