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);
/** /**
* 查询托盘绑定的设备列列表 * 查询托盘绑定的设备列列表
* *
......
...@@ -6,15 +6,15 @@ import org.apache.ibatis.annotations.Param; ...@@ -6,15 +6,15 @@ import org.apache.ibatis.annotations.Param;
/** /**
* 机械臂指令Mapper接口 * 机械臂指令Mapper接口
* *
* @author zehong * @author zehong
* @date 2025-08-04 * @date 2025-08-04
*/ */
public interface RobotArmCommandMapper public interface RobotArmCommandMapper
{ {
/** /**
* 查询机械臂指令 * 查询机械臂指令
* *
* @param robotArmCommandId 机械臂指令ID * @param robotArmCommandId 机械臂指令ID
* @return 机械臂指令 * @return 机械臂指令
*/ */
...@@ -29,7 +29,7 @@ public interface RobotArmCommandMapper ...@@ -29,7 +29,7 @@ public interface RobotArmCommandMapper
public RobotArmCommand findByTrayAndStatus(@Param("trayCode") String trayCode, @Param("status") String status); public RobotArmCommand findByTrayAndStatus(@Param("trayCode") String trayCode, @Param("status") String status);
/** /**
* 查询机械臂指令列表 * 查询机械臂指令列表
* *
* @param robotArmCommand 机械臂指令 * @param robotArmCommand 机械臂指令
* @return 机械臂指令集合 * @return 机械臂指令集合
*/ */
...@@ -41,9 +41,11 @@ public interface RobotArmCommandMapper ...@@ -41,9 +41,11 @@ public interface RobotArmCommandMapper
public List<RobotArmCommand> findByType(String type); public List<RobotArmCommand> findByType(String type);
public List<RobotArmCommand> selectIsRunningCommandByTrayCode(String trayCode);
/** /**
* 新增机械臂指令 * 新增机械臂指令
* *
* @param robotArmCommand 机械臂指令 * @param robotArmCommand 机械臂指令
* @return 结果 * @return 结果
*/ */
...@@ -51,12 +53,14 @@ public interface RobotArmCommandMapper ...@@ -51,12 +53,14 @@ public interface RobotArmCommandMapper
/** /**
* 修改机械臂指令 * 修改机械臂指令
* *
* @param robotArmCommand 机械臂指令 * @param robotArmCommand 机械臂指令
* @return 结果 * @return 结果
*/ */
public int updateRobotArmCommand(RobotArmCommand robotArmCommand); public int updateRobotArmCommand(RobotArmCommand robotArmCommand);
public int batchUpdateStatus(@Param("status") String status,@Param("list") List<Long> ids);
/** /**
* 更新执行中状态为完成状态 * 更新执行中状态为完成状态
...@@ -80,7 +84,7 @@ public interface RobotArmCommandMapper ...@@ -80,7 +84,7 @@ public interface RobotArmCommandMapper
List<RobotArmCommand> selectPendingLoadUnloadCommands(); List<RobotArmCommand> selectPendingLoadUnloadCommands();
/** /**
* 删除机械臂指令 * 删除机械臂指令
* *
* @param robotArmCommandId 机械臂指令ID * @param robotArmCommandId 机械臂指令ID
* @return 结果 * @return 结果
*/ */
...@@ -88,7 +92,7 @@ public interface RobotArmCommandMapper ...@@ -88,7 +92,7 @@ public interface RobotArmCommandMapper
/** /**
* 批量删除机械臂指令 * 批量删除机械臂指令
* *
* @param robotArmCommandIds 需要删除的数据ID * @param robotArmCommandIds 需要删除的数据ID
* @return 结果 * @return 结果
*/ */
......
...@@ -5,15 +5,15 @@ import com.zehong.system.domain.TTrayInfo; ...@@ -5,15 +5,15 @@ import com.zehong.system.domain.TTrayInfo;
/** /**
* 托盘信息Mapper接口 * 托盘信息Mapper接口
* *
* @author zehong * @author zehong
* @date 2025-06-06 * @date 2025-06-06
*/ */
public interface TTrayInfoMapper public interface TTrayInfoMapper
{ {
/** /**
* 查询托盘信息 * 查询托盘信息
* *
* @param fTrayId 托盘信息ID * @param fTrayId 托盘信息ID
* @return 托盘信息 * @return 托盘信息
*/ */
...@@ -27,9 +27,11 @@ public interface TTrayInfoMapper ...@@ -27,9 +27,11 @@ public interface TTrayInfoMapper
public int initStatusByTrayId(Long trayId); public int initStatusByTrayId(Long trayId);
public int clearStoreyCodeByTrayId(Long trayId);
/** /**
* 查询托盘信息列表 * 查询托盘信息列表
* *
* @param tTrayInfo 托盘信息 * @param tTrayInfo 托盘信息
* @return 托盘信息集合 * @return 托盘信息集合
*/ */
...@@ -37,7 +39,7 @@ public interface TTrayInfoMapper ...@@ -37,7 +39,7 @@ public interface TTrayInfoMapper
/** /**
* 新增托盘信息 * 新增托盘信息
* *
* @param tTrayInfo 托盘信息 * @param tTrayInfo 托盘信息
* @return 结果 * @return 结果
*/ */
...@@ -47,7 +49,7 @@ public interface TTrayInfoMapper ...@@ -47,7 +49,7 @@ public interface TTrayInfoMapper
/** /**
* 修改托盘信息 * 修改托盘信息
* *
* @param tTrayInfo 托盘信息 * @param tTrayInfo 托盘信息
* @return 结果 * @return 结果
*/ */
...@@ -64,7 +66,7 @@ public interface TTrayInfoMapper ...@@ -64,7 +66,7 @@ public interface TTrayInfoMapper
public int unbindByCode(TTrayInfo tTrayInfo); public int unbindByCode(TTrayInfo tTrayInfo);
/** /**
* 删除托盘信息 * 删除托盘信息
* *
* @param fTrayId 托盘信息ID * @param fTrayId 托盘信息ID
* @return 结果 * @return 结果
*/ */
...@@ -72,7 +74,7 @@ public interface TTrayInfoMapper ...@@ -72,7 +74,7 @@ public interface TTrayInfoMapper
/** /**
* 批量删除托盘信息 * 批量删除托盘信息
* *
* @param fTrayIds 需要删除的数据ID * @param fTrayIds 需要删除的数据ID
* @return 结果 * @return 结果
*/ */
......
...@@ -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();
}
/** /**
* 批量解绑所有设备(不处理上传数据) * 批量解绑所有设备(不处理上传数据)
* *
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zehong.system.mapper.RobotArmCommandMapper"> <mapper namespace="com.zehong.system.mapper.RobotArmCommandMapper">
<resultMap type="RobotArmCommand" id="RobotArmCommandResult"> <resultMap type="RobotArmCommand" id="RobotArmCommandResult">
<result property="robotArmCommandId" column="f_robot_arm_command_id" /> <result property="robotArmCommandId" column="f_robot_arm_command_id" />
<result property="trayCode" column="f_tray_code" /> <result property="trayCode" column="f_tray_code" />
...@@ -33,10 +33,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -33,10 +33,14 @@ 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"/>
<where> <where>
<if test="trayCode != null and trayCode != ''"> and f_tray_code = #{trayCode}</if> <if test="trayCode != null and trayCode != ''"> and f_tray_code = #{trayCode}</if>
<if test="storeyCode != null and storeyCode != ''"> and f_storey_code = #{storeyCode}</if> <if test="storeyCode != null and storeyCode != ''"> and f_storey_code = #{storeyCode}</if>
<if test="type != null and type != ''"> and f_type = #{type}</if> <if test="type != null and type != ''"> and f_type = #{type}</if>
...@@ -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">
...@@ -175,9 +187,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -175,9 +187,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<delete id="deleteRobotArmCommandByIds" parameterType="String"> <delete id="deleteRobotArmCommandByIds" parameterType="String">
delete from t_robot_arm_command where f_robot_arm_command_id in delete from t_robot_arm_command where f_robot_arm_command_id in
<foreach item="robotArmCommandId" collection="array" open="(" separator="," close=")"> <foreach item="robotArmCommandId" collection="array" open="(" separator="," close=")">
#{robotArmCommandId} #{robotArmCommandId}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>
\ No newline at end of file
...@@ -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