Commit 8dcea44a authored by wanghao's avatar wanghao

1 托盘信息维护开发

parent face7351
...@@ -109,5 +109,5 @@ netty: ...@@ -109,5 +109,5 @@ netty:
robot: robot:
arm: arm:
udp: udp:
ip: 192.168.2.14 ip: 127.0.0.1
port: 6000 port: 6000
\ No newline at end of file
...@@ -109,5 +109,5 @@ netty: ...@@ -109,5 +109,5 @@ netty:
robot: robot:
arm: arm:
udp: udp:
ip: 192.168.2.16 ip: 127.0.0.1
port: 6000 port: 6000
\ No newline at end of file
...@@ -106,5 +106,5 @@ netty: ...@@ -106,5 +106,5 @@ netty:
robot: robot:
arm: arm:
udp: udp:
ip: 192.168.2.16 ip: 127.0.0.1
port: 6000 port: 6000
\ No newline at end of file
...@@ -40,6 +40,8 @@ public interface TStoreyInfoMapper ...@@ -40,6 +40,8 @@ public interface TStoreyInfoMapper
*/ */
public List<TStoreyInfo> selectTStoreyInfoList(TStoreyInfo tStoreyInfo); public List<TStoreyInfo> selectTStoreyInfoList(TStoreyInfo tStoreyInfo);
public List<TStoreyInfo> selectByEquipmentIds(@Param("list") List<Long> fEquipmentIds);
public List<TStoreyInfo> queryByDepartmentId(Long fEquipmentId); public List<TStoreyInfo> queryByDepartmentId(Long fEquipmentId);
/** /**
...@@ -60,6 +62,8 @@ public interface TStoreyInfoMapper ...@@ -60,6 +62,8 @@ public interface TStoreyInfoMapper
*/ */
public int updateTStoreyInfo(TStoreyInfo tStoreyInfo); public int updateTStoreyInfo(TStoreyInfo tStoreyInfo);
public int updateBatch(@Param("storeyInfos") List<TStoreyInfo> storeyInfos);
/** /**
* 删除老化层信息 * 删除老化层信息
* *
......
...@@ -87,14 +87,15 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService ...@@ -87,14 +87,15 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
List<RobotArmCommand> loadingCommands = List<RobotArmCommand> loadingCommands =
robotArmCommandMapper.selectPendingLoadingCommands(); robotArmCommandMapper.selectPendingLoadingCommands();
if (!loadingCommands.isEmpty()) { if (!loadingCommands.isEmpty()) {
// 传送带检测先去掉
boolean[] roboticArmEntryConveyorData = Modbus4jUtils.getRoboticArmEntryConveyorData(); // boolean[] roboticArmEntryConveyorData = Modbus4jUtils.getRoboticArmEntryConveyorData();
log.info("机械臂入口 conveyor 0状态: " + roboticArmEntryConveyorData[0]); // log.info("机械臂入口 conveyor 0状态: " + roboticArmEntryConveyorData[0]);
log.info("机械臂入口 conveyor 1状态: " + roboticArmEntryConveyorData[1]); // log.info("机械臂入口 conveyor 1状态: " + roboticArmEntryConveyorData[1]);
if(roboticArmEntryConveyorData[1]) { // if(roboticArmEntryConveyorData[1]) {
sendCommand(loadingCommands.get(0), "LOAD"); // sendCommand(loadingCommands.get(0), "LOAD");
return; // return;
} // }
sendCommand(loadingCommands.get(0), "LOAD");
} }
// 2. 处理待执行的下料指令 // 2. 处理待执行的下料指令
...@@ -123,10 +124,7 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService ...@@ -123,10 +124,7 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
SocketAddress address = getRobotAddress(); SocketAddress address = getRobotAddress();
udpCommandSender.sendCommandWithId( udpCommandSender.sendCommandWithId(
address, address,
command.getRobotArmCommandId(), command.getCommand()
commandType,
command.getTrayCode(),
command.getStoreyCode()
); );
// 注册指令跟踪 // 注册指令跟踪
...@@ -259,6 +257,8 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService ...@@ -259,6 +257,8 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
throw new RuntimeException("当前托盘正在执行指令"); throw new RuntimeException("当前托盘正在执行指令");
} }
TStoreyInfo tStoreyInfo = storeyInfoMapper.selectNearestFreeStorey();
robotArmCommand.setCommand(tStoreyInfo.getBlankingCommand());
robotArmCommand.setCreateTime(DateUtils.getNowDate()); robotArmCommand.setCreateTime(DateUtils.getNowDate());
return robotArmCommandMapper.insertRobotArmCommand(robotArmCommand); return robotArmCommandMapper.insertRobotArmCommand(robotArmCommand);
...@@ -293,7 +293,7 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService ...@@ -293,7 +293,7 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
if(tStoreyInfo != null) { if(tStoreyInfo != null) {
robotArmCommand.setStatus("1"); robotArmCommand.setStatus("1");
robotArmCommand.setStoreyCode(tStoreyInfo.getfStoreyCode()); robotArmCommand.setStoreyCode(tStoreyInfo.getfStoreyCode());
robotArmCommand.setCommand(tStoreyInfo.getFeedingCommand());
tTrayInfo.setfStoreyCode(tStoreyInfo.getfStoreyCode()); tTrayInfo.setfStoreyCode(tStoreyInfo.getfStoreyCode());
tTrayInfo.setfBindingTime(new Date()); tTrayInfo.setfBindingTime(new Date());
tTrayInfoMapper.updateTTrayInfo(tTrayInfo); tTrayInfoMapper.updateTTrayInfo(tTrayInfo);
......
...@@ -93,51 +93,6 @@ public class SysUserServiceImpl implements ISysUserService ...@@ -93,51 +93,6 @@ public class SysUserServiceImpl implements ISysUserService
@Override @Override
public SysUser selectUserById(Long userId) public SysUser selectUserById(Long userId)
{ {
// List<TEquipmentInfo> equipmentInfos1 = equipmentInfoMapper.selectTEquipmentInfoList(new TEquipmentInfo());
// List<TStoreyInfo> tStoreyInfos = tStoreyInfoMapper.selectTStoreyInfoList(new TStoreyInfo());
//
// if (tStoreyInfos.size() < 16) {
// TStoreyInfo storeyInfo;
// List<TStoreyInfo> storeyInfoList = new ArrayList<>();
//
// for (TEquipmentInfo tEquipmentInfo : equipmentInfos1) {
// String ip = tEquipmentInfo.getfIp();
// if (ip == null || !ip.matches("\\d+\\.\\d+\\.\\d+\\.\\d+")) {
// continue;
// }
//
// String[] split = ip.split("\\.");
// if (split.length != 4) {
// continue;
// }
//
// try {
// int start = Integer.parseInt(split[3]) + 9; // 起始值(如IP最后一段为81,则start=90)
// String baseIp = split[0] + "." + split[1] + "." + split[2] + ".";
// int code = 1;
//
// // 核心修改:循环10次(i从start递减到start-9,共10个值)
// for (int i = start; i >= start - 9; i--) {
// storeyInfo = new TStoreyInfo();
// storeyInfo.setfEquipmentId(tEquipmentInfo.getfEquipmentId());
// storeyInfo.setfStoreyCode(tEquipmentInfo.getfEquipmentCode() + "-" + code);
// storeyInfo.setfIp(baseIp + i); // 生成IP:如192.168.2.90、192.168.2.89...192.168.2.81
// storeyInfo.setfPort("501,502,503");
// storeyInfo.setfStatus("0");
// storeyInfo.setfCreateTime(new Date());
// storeyInfoList.add(storeyInfo);
// code++;
// }
// } catch (NumberFormatException e) {
// continue;
// }
// }
//
// if (!storeyInfoList.isEmpty()) {
// tStoreyInfoMapper.insertBatch(storeyInfoList);
// }
// }
return userMapper.selectUserById(userId); return userMapper.selectUserById(userId);
} }
......
package com.zehong.system.service.impl; package com.zehong.system.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List; import java.util.List;
import com.zehong.common.utils.DateUtils; import com.zehong.common.utils.DateUtils;
...@@ -41,6 +44,91 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService ...@@ -41,6 +44,91 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
return tStoreyInfoMapper.selectTStoreyInfoById(fStoreyId); return tStoreyInfoMapper.selectTStoreyInfoById(fStoreyId);
} }
/**
* 更新南边指令
*/
private void updateNCommand() {
List<Long> equipmentIds = Arrays.asList(18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L);
List<TStoreyInfo> tStoreyInfos = tStoreyInfoMapper.selectByEquipmentIds(equipmentIds);
if(tStoreyInfos.size() > 0) {
for (TStoreyInfo tStoreyInfo : tStoreyInfos) {
String s = tStoreyInfo.getfStoreyCode();
Long aLong = tStoreyInfo.getfEquipmentId();
String[] split = s.split("-");
String feedingCommand = "NSL" + (aLong - 17L) + split[1];
String blankingCommand = "NXL" + (aLong - 17L) + split[1];
tStoreyInfo.setFeedingCommand(feedingCommand);
tStoreyInfo.setBlankingCommand(blankingCommand);
}
tStoreyInfoMapper.updateBatch(tStoreyInfos);
}
}
/**
* 更新北边指令
*/
private void updateBCommand(){
List<Long> equipmentIds = Arrays.asList(3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L);
List<TStoreyInfo> tStoreyInfos = tStoreyInfoMapper.selectByEquipmentIds(equipmentIds);
if(tStoreyInfos.size() > 0) {
for (TStoreyInfo tStoreyInfo : tStoreyInfos) {
String s = tStoreyInfo.getfStoreyCode();
String[] split = s.split("-");
String feedingCommand = "BSL" + split[0] + split[1];
String blankingCommand = "BXL" + split[0] + split[1];
tStoreyInfo.setFeedingCommand(feedingCommand);
tStoreyInfo.setBlankingCommand(blankingCommand);
}
tStoreyInfoMapper.updateBatch(tStoreyInfos);
}
}
private void initStoreyInfo() {
List<TEquipmentInfo> equipmentInfos1 = equipmentInfoMapper.selectTEquipmentInfoList(new TEquipmentInfo());
List<TStoreyInfo> tStoreyInfos = tStoreyInfoMapper.selectTStoreyInfoList(new TStoreyInfo());
if (tStoreyInfos.size() < 16) {
TStoreyInfo storeyInfo;
List<TStoreyInfo> storeyInfoList = new ArrayList<>();
for (TEquipmentInfo tEquipmentInfo : equipmentInfos1) {
String ip = tEquipmentInfo.getfIp();
if (ip == null || !ip.matches("\\d+\\.\\d+\\.\\d+\\.\\d+")) {
continue;
}
String[] split = ip.split("\\.");
if (split.length != 4) {
continue;
}
try {
int start = Integer.parseInt(split[3]) + 9; // 起始值(如IP最后一段为81,则start=90)
String baseIp = split[0] + "." + split[1] + "." + split[2] + ".";
int code = 1;
// 核心修改:循环10次(i从start递减到start-9,共10个值)
for (int i = start; i >= start - 9; i--) {
storeyInfo = new TStoreyInfo();
storeyInfo.setfEquipmentId(tEquipmentInfo.getfEquipmentId());
storeyInfo.setfStoreyCode(tEquipmentInfo.getfEquipmentCode() + "-" + code);
storeyInfo.setfIp(baseIp + i); // 生成IP:如192.168.2.90、192.168.2.89...192.168.2.81
storeyInfo.setfPort("501,502,503");
storeyInfo.setfStatus("0");
storeyInfo.setfCreateTime(new Date());
storeyInfoList.add(storeyInfo);
code++;
}
} catch (NumberFormatException e) {
continue;
}
}
if (!storeyInfoList.isEmpty()) {
tStoreyInfoMapper.insertBatch(storeyInfoList);
}
}
}
/** /**
* 查询老化层信息 * 查询老化层信息
* *
......
...@@ -70,11 +70,8 @@ public class UdpCommandSender { ...@@ -70,11 +70,8 @@ public class UdpCommandSender {
/** /**
* 发送带指令ID的命令 * 发送带指令ID的命令
*/ */
public void sendCommandWithId(SocketAddress address, Long commandId, public void sendCommandWithId(SocketAddress address, String command) {
String commandType, String trayCode, String storeyCode) { sendCommand(address, command);
String message = String.format("CMD_ID:%d#%s#%s#%s",
commandId, commandType, trayCode, storeyCode);
sendCommand(address, message);
} }
public void sendCommandThrowError(String message) throws IOException { public void sendCommandThrowError(String message) throws IOException {
......
...@@ -42,6 +42,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -42,6 +42,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join t_equipment_info equipmentInfo on storeyInfo.f_equipment_id = equipmentInfo.f_equipment_id left join t_equipment_info equipmentInfo on storeyInfo.f_equipment_id = equipmentInfo.f_equipment_id
</sql> </sql>
<select id="selectByEquipmentIds" parameterType="list" resultMap="TStoreyInfoResult">
<include refid="selectTStoreyInfoVo"/>
where storeyInfo.f_equipment_id in
<foreach item="item" collection="list" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectTStoreyInfoList" parameterType="TStoreyInfo" resultMap="TStoreyInfoResult"> <select id="selectTStoreyInfoList" parameterType="TStoreyInfo" resultMap="TStoreyInfoResult">
<include refid="selectTStoreyInfoVo"/> <include refid="selectTStoreyInfoVo"/>
<where> <where>
...@@ -73,13 +81,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -73,13 +81,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectNearestFreeStorey" resultMap="TStoreyInfoResult"> <select id="selectNearestFreeStorey" resultMap="TStoreyInfoResult">
SELECT SELECT
f_storey_id, f_equipment_id, f_storey_code, f_ip, f_status, f_port, f_storey_id, f_equipment_id, f_storey_code, f_ip, f_status, f_port,
f_aging_start_time, f_update_time, f_create_time, f_alarm_timel, f_blanking_command, f_feeding_command f_aging_start_time, f_update_time, f_create_time, f_alarm_time, f_blanking_command, f_feeding_command
FROM ( FROM (
SELECT SELECT
*, *,
CASE CASE
WHEN cabinet_num BETWEEN 1 AND 18 THEN (cabinet_num - 1) * 10 + layer_num WHEN cabinet_num BETWEEN 1 AND 15 THEN (cabinet_num - 1) * 10 + layer_num
WHEN cabinet_num BETWEEN 19 AND 36 THEN (cabinet_num - 19) * 10 + layer_num WHEN cabinet_num BETWEEN 16 AND 36 THEN (cabinet_num - 16) * 10 + layer_num
END AS distance END AS distance
FROM ( FROM (
SELECT SELECT
...@@ -131,6 +139,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -131,6 +139,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
</insert> </insert>
<update id="updateBatch" parameterType="list">
<foreach collection="storeyInfos" item="item" index="index" separator=";">
update t_storey_info
<trim prefix="SET" suffixOverrides=",">
<if test="item.blankingCommand != null">f_blanking_command = #{item.blankingCommand},</if>
<if test="item.feedingCommand != null">f_feeding_command = #{item.feedingCommand},</if>
</trim>
where f_storey_id = #{item.fStoreyId}
</foreach>
</update>
<update id="updateTStoreyInfo" parameterType="TStoreyInfo"> <update id="updateTStoreyInfo" parameterType="TStoreyInfo">
update t_storey_info update t_storey_info
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
......
...@@ -244,7 +244,6 @@ export default { ...@@ -244,7 +244,6 @@ export default {
loadTray() { loadTray() {
this.$message.success("下料操作已执行"); this.$message.success("下料操作已执行");
const robotArmCommand = { const robotArmCommand = {
trayCode: this.trayInfo.fTrayCode, trayCode: this.trayInfo.fTrayCode,
storeyCode: this.trayInfo.storeyCode, storeyCode: this.trayInfo.storeyCode,
......
...@@ -64,9 +64,14 @@ ...@@ -64,9 +64,14 @@
<el-table-column label="端口号" align="center" prop="fPort" /> <el-table-column label="端口号" align="center" prop="fPort" />
<el-table-column label="状态" align="center" prop="fStatus" > <el-table-column label="状态" align="center" prop="fStatus" >
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag v-if ="scope.row.fStatus === '0'">空闲</el-tag> <!-- 空闲状态 - 灰色(info) -->
<el-tag v-else-if ="scope.row.fStatus === '1'">故障</el-tag> <el-tag type="info" v-if="scope.row.fStatus === '0'">空闲</el-tag>
<el-tag v-else-if ="scope.row.fStatus === '2'">断电</el-tag> <!-- 运行状态 - 绿色(success) -->
<el-tag type="success" v-else-if="scope.row.fStatus === '1'">运行</el-tag>
<!-- 故障状态 - 红色(danger) -->
<el-tag type="danger" v-else-if="scope.row.fStatus === '2'">故障</el-tag>
<!-- 断电状态 - 橙色(warning) -->
<el-tag type="warning" v-else-if="scope.row.fStatus === '3'">断电</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="报警时间" align="center" prop="fAlarmTime" width="180"> <el-table-column label="报警时间" align="center" prop="fAlarmTime" width="180">
......
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