Commit f83e45b7 authored by wanghao's avatar wanghao

1 老化过程中 获取卡号,获取IOT状态调整中

parent fdcf679d
...@@ -226,8 +226,6 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi ...@@ -226,8 +226,6 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
if(i <= 0) { if(i <= 0) {
throw new RuntimeException("添加失败"); throw new RuntimeException("添加失败");
} }
eventPublisher.publishEvent(new ReceivedNbCodeEvent(this, null,palletDeviceBindingList.get(0).getTrayId()));
return palletDeviceBindingList; return palletDeviceBindingList;
} }
...@@ -266,7 +264,6 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi ...@@ -266,7 +264,6 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
tTrayInfoMapper.updateToBoundWhenStateIsIdle(palletDeviceBindingList.get(0).getTrayId()); tTrayInfoMapper.updateToBoundWhenStateIsIdle(palletDeviceBindingList.get(0).getTrayId());
palletDeviceBindingMapper.batchUpdateDeviceCodeAndUnbindingTime(palletDeviceBindingList); palletDeviceBindingMapper.batchUpdateDeviceCodeAndUnbindingTime(palletDeviceBindingList);
eventPublisher.publishEvent(new ReceivedNbCodeEvent(this, null,palletDeviceBindingList.get(0).getTrayId()));
log.info("主线程时间:{}",DateUtils.getTime()); log.info("主线程时间:{}",DateUtils.getTime());
return 1; return 1;
} }
......
...@@ -6,6 +6,7 @@ import java.net.SocketAddress; ...@@ -6,6 +6,7 @@ import java.net.SocketAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import com.serotonin.modbus4j.ModbusMaster; import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.exception.ModbusInitException; import com.serotonin.modbus4j.exception.ModbusInitException;
...@@ -24,6 +25,7 @@ import com.zehong.system.service.websocket.RobotArmWebSocketHandler; ...@@ -24,6 +25,7 @@ import com.zehong.system.service.websocket.RobotArmWebSocketHandler;
import com.zehong.system.task.event.CheckPowerOnCommandEvent; import com.zehong.system.task.event.CheckPowerOnCommandEvent;
import com.zehong.system.task.event.IotStatusEvent; import com.zehong.system.task.event.IotStatusEvent;
import com.zehong.system.task.event.PowerOffCommandEvent; import com.zehong.system.task.event.PowerOffCommandEvent;
import com.zehong.system.task.event.ReceivedNbCodeEvent;
import com.zehong.system.udp.UdpCommandSender; import com.zehong.system.udp.UdpCommandSender;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -463,7 +465,7 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService ...@@ -463,7 +465,7 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
} }
@Override @Override
@Transactional @Transactional(rollbackFor = Exception.class)
public int addManualCommand(RobotArmCommand robotArmCommand) { public int addManualCommand(RobotArmCommand robotArmCommand) {
robotArmCommand.setCreateTime(DateUtils.getNowDate()); robotArmCommand.setCreateTime(DateUtils.getNowDate());
...@@ -490,7 +492,10 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService ...@@ -490,7 +492,10 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
if(i1 == 0) { if(i1 == 0) {
throw new RuntimeException("托盘未绑定设备"); throw new RuntimeException("托盘未绑定设备");
} }
// 待上传的话板子必须有NB码
if(StringUtils.isNotBlank(productStandardInspection.getHasUpload()) && "1".equals(productStandardInspection.getHasUpload())){
eventPublisher.publishEvent(new ReceivedNbCodeEvent(this, null,tTrayInfo.getfTrayId()));
}
// 20251104 上料 不需要看托盘状态了 // 20251104 上料 不需要看托盘状态了
// 20251210 上料 又需要看托盘状态了 // 20251210 上料 又需要看托盘状态了
if(!"4".equals(tTrayInfo.getfStatus())) { if(!"4".equals(tTrayInfo.getfStatus())) {
...@@ -559,6 +564,10 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService ...@@ -559,6 +564,10 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
if(i1 == 0) { if(i1 == 0) {
throw new RuntimeException("托盘未绑定设备"); throw new RuntimeException("托盘未绑定设备");
} }
// 待上传的话板子必须有NB码
if(StringUtils.isNotBlank(productStandardInspection.getHasUpload()) && "1".equals(productStandardInspection.getHasUpload())){
eventPublisher.publishEvent(new ReceivedNbCodeEvent(this, null,tTrayInfo.getfTrayId()));
}
// 20251104 上料 不需要看托盘状态了 // 20251104 上料 不需要看托盘状态了
// 20251210 上料 又需要看托盘状态了 // 20251210 上料 又需要看托盘状态了
......
...@@ -183,16 +183,7 @@ public class AgingStageOneProcessJob implements Job { ...@@ -183,16 +183,7 @@ public class AgingStageOneProcessJob implements Job {
binding.setWriteSelfCheckStatus(i); binding.setWriteSelfCheckStatus(i);
} }
// 设置卡号
StringBuilder simCardNoBuilder = new StringBuilder();
for (int i = 16; i <= 35; i++) {
int i1 = result[i];
String hex = Integer.toHexString(i1).toUpperCase();
simCardNoBuilder.append(hex);
}
String simCardNo = simCardNoBuilder.toString();
binding.setSimCardNo(simCardNo);
// 6. 更新数据库 // 6. 更新数据库
palletDeviceBindingMapper.updatePalletDeviceBinding(binding); palletDeviceBindingMapper.updatePalletDeviceBinding(binding);
......
...@@ -209,29 +209,30 @@ public class AgingStageThreeProcessJob implements Job { ...@@ -209,29 +209,30 @@ public class AgingStageThreeProcessJob implements Job {
if(result[12] == 1 && binding.getModuleStatus() == 0){ if(result[12] == 1 && binding.getModuleStatus() == 0){
binding.setModuleStatus(1); binding.setModuleStatus(1);
} }
if(result[13] == 1 && binding.getSimCardStatus() == 0){
binding.setSimCardStatus(1);
}
// 带上传的 才去读网络状态 SIM卡状态
if("1".equals(hasUpload)) { if("1".equals(hasUpload)) {
if(result[14] == 1 && binding.getNetworkStatus() == 0){ if(result[14] == 1 && binding.getNetworkStatus() == 0){
binding.setNetworkStatus(1); binding.setNetworkStatus(1);
} }
if(result[13] == 1 && binding.getSimCardStatus() == 0){
binding.setSimCardStatus(1);
// 设置卡号
StringBuilder simCardNoBuilder = new StringBuilder();
for (int i = 16; i <= 35; i++) {
int i1 = result[i];
String hex = Integer.toHexString(i1).toUpperCase();
simCardNoBuilder.append(hex);
}
String simCardNo = simCardNoBuilder.toString();
binding.setSimCardNo(simCardNo);
}
} }
if("5".equals(binding.getDeviceStatus())) { if("5".equals(binding.getDeviceStatus())) {
binding.setWriteTimeStatus("0"); binding.setWriteTimeStatus("0");
} }
// 设置卡号
StringBuilder simCardNoBuilder = new StringBuilder();
for (int i = 16; i <= 35; i++) {
int i1 = result[i];
String hex = Integer.toHexString(i1).toUpperCase();
simCardNoBuilder.append(hex);
}
String simCardNo = simCardNoBuilder.toString();
binding.setSimCardNo(simCardNo);
// 5. 更新数据库 // 5. 更新数据库
palletDeviceBindingMapper.updatePalletDeviceBinding(binding); palletDeviceBindingMapper.updatePalletDeviceBinding(binding);
......
...@@ -228,18 +228,28 @@ public class AgingStageTwoProcessJob implements Job { ...@@ -228,18 +228,28 @@ public class AgingStageTwoProcessJob implements Job {
} else { } else {
binding.setModuleStatus(0); binding.setModuleStatus(0);
} }
if(result[13] == 1) {
binding.setSimCardStatus(1);
} else {
binding.setSimCardStatus(0);
}
// 带上传的 才去读网络状态 SIM卡状态
if("1".equals(hasUpload)) { if("1".equals(hasUpload)) {
if(result[14] == 1) { if(result[14] == 1) {
binding.setNetworkStatus(1); binding.setNetworkStatus(1);
} else { } else {
binding.setNetworkStatus(0); binding.setNetworkStatus(0);
} }
if(result[13] == 1) {
binding.setSimCardStatus(1);
// 设置卡号
StringBuilder simCardNoBuilder = new StringBuilder();
for (int i = 16; i <= 35; i++) {
int i1 = result[i];
String hex = Integer.toHexString(i1).toUpperCase();
simCardNoBuilder.append(hex);
}
String simCardNo = simCardNoBuilder.toString();
binding.setSimCardNo(simCardNo);
} else {
binding.setSimCardStatus(0);
}
} }
// 重用之前的master连接进行写操作 // 重用之前的master连接进行写操作
...@@ -250,15 +260,6 @@ public class AgingStageTwoProcessJob implements Job { ...@@ -250,15 +260,6 @@ public class AgingStageTwoProcessJob implements Job {
binding.setWriteSelfCheckStatus(i); binding.setWriteSelfCheckStatus(i);
} }
// 设置卡号
StringBuilder simCardNoBuilder = new StringBuilder();
for (int i = 16; i <= 35; i++) {
int i1 = result[i];
String hex = Integer.toHexString(i1).toUpperCase();
simCardNoBuilder.append(hex);
}
String simCardNo = simCardNoBuilder.toString();
binding.setSimCardNo(simCardNo);
// 5. 更新数据库 // 5. 更新数据库
palletDeviceBindingMapper.updatePalletDeviceBinding(binding); palletDeviceBindingMapper.updatePalletDeviceBinding(binding);
......
...@@ -238,7 +238,7 @@ public class AllCommandHandler { ...@@ -238,7 +238,7 @@ public class AllCommandHandler {
// 2. 按主板码分组,并过滤掉无效数据(同时提前处理无需调接口的) // 2. 按主板码分组,并过滤掉无效数据(同时提前处理无需调接口的)
// // 只留 nbCode 有效的 // 网络状态为 1 // // 只留 nbCode 有效的 // 网络状态为 1
Map<String, List<PalletDeviceBinding>> groupByMotherboard = bindings.stream() Map<String, List<PalletDeviceBinding>> groupByMotherboard = bindings.stream()
.filter(b -> StringUtils.isNotBlank(b.getNbCode()) && b.getNetworkStatus() == 1) .filter(b -> StringUtils.isNotBlank(b.getNbCode()) && b.getNetworkStatus() != null && b.getNetworkStatus() == 1)
.collect(Collectors.groupingBy(PalletDeviceBinding::getMotherboardCode)); .collect(Collectors.groupingBy(PalletDeviceBinding::getMotherboardCode));
// 处理 nbCode 为空的(直接设状态为 2,加入待更新列表) // 处理 nbCode 为空的(直接设状态为 2,加入待更新列表)
...@@ -323,10 +323,8 @@ public class AllCommandHandler { ...@@ -323,10 +323,8 @@ public class AllCommandHandler {
} }
// 将状态设置给该组所有设备,并加入待更新列表 // 将状态设置给该组所有设备,并加入待更新列表
for (PalletDeviceBinding device : sameBoardDevices) { palletDeviceBinding.setIotStatus(statusToSet);
device.setIotStatus(statusToSet); needUpdateList.add(palletDeviceBinding);
needUpdateList.add(device);
}
} }
// 7. 批量持久化所有改动(一次性提交) // 7. 批量持久化所有改动(一次性提交)
......
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