| | |
| | | import com.battery.business.service.ITDetectionCabinetService; |
| | | import com.battery.device.api.discovery.DeviceDiscoveryCandidateStore; |
| | | import com.battery.device.api.discovery.DeviceDiscoveryCandidateStore.CabinetCandidate; |
| | | import com.battery.device.api.discovery.DeviceDiscoveryCandidateStore.ChannelCandidate; |
| | | import com.battery.device.api.model.DeviceWorkStatus; |
| | | |
| | | /** |
| | |
| | | value.setDevid(channel.identity().devid()); |
| | | value.setSubdevid(channel.identity().subdevid()); |
| | | value.setChlid(channel.identity().chlid()); |
| | | value.setDisplayNo(channel.identity().subdevid() + "-" + channel.identity().chlid()); |
| | | value.setDisplayNo(channelDisplayNo(channel)); |
| | | value.setOnlineStatus(channel.online() ? "ONLINE" : "OFFLINE"); |
| | | value.setWorkStatus(persistedWorkStatus(channel.workStatus(), channel.online())); |
| | | value.setLastSeenAtUtc(null); |
| | |
| | | candidate.online()); |
| | | candidate.channels().forEach(channel -> detectionCabinetMapper.updateRegisteredChannelObservation( |
| | | candidate.adapterCode(), channel.identity().devtype(), channel.identity().devid(), |
| | | channel.identity().subdevid(), channel.identity().chlid(), channel.online() ? "ONLINE" : "OFFLINE", |
| | | channel.identity().subdevid(), channel.identity().chlid(), channelDisplayNo(channel), |
| | | channel.online() ? "ONLINE" : "OFFLINE", |
| | | channel.online() ? persistedWorkStatus(channel.workStatus(), true) : "UNOBSERVABLE", |
| | | channel.observedAt(), channel.online())); |
| | | return rows; |
| | |
| | | return adapterCode + "-" + devtype + "-" + devid; |
| | | } |
| | | |
| | | /** |
| | | * 通道在界面上的显示号:来源自己有叫法就用它(操作员拿它跟厂商软件对上), |
| | | * 否则回退到身份里的「单元-通道」。显示号只是展示,不参与通道身份。 |
| | | */ |
| | | static String channelDisplayNo(ChannelCandidate channel) |
| | | { |
| | | String declared = channel.sourceDisplayNo(); |
| | | return declared == null || declared.isBlank() |
| | | ? channel.identity().subdevid() + "-" + channel.identity().chlid() : declared.trim(); |
| | | } |
| | | |
| | | /** 将设备观测状态转换为最终数据库允许的通道事实状态。 */ |
| | | private String persistedWorkStatus(DeviceWorkStatus status, boolean online) |
| | | { |