| | |
| | | String ip = ipAddress.equals("0:0:0:0:0:0:0:1") ? "127.0.0.1" : ipAddress; |
| | | List<Device> device = baseMapper.selectList(Wrappers.<Device>lambdaQuery() |
| | | .eq(Device::getIp, ip)); |
| | | if(device.size() > 1) { |
| | | throw new ErrorException("IP:" + ip + "配置了设备多个设备,无法进行数采!"); |
| | | } |
| | | if (ObjectUtils.isEmpty(device)) { |
| | | throw new ErrorException("未给该IP:" + ip + "配置设备,无法进行数采!"); |
| | | } |
| | | List<String> inspectionItemSubclass = baseMapper.getInspectionItemSubclass(id); |
| | | Map<String, String> hashMap = new HashMap<>(); |
| | | device.forEach(i -> { |
| | | if (ObjectUtils.isEmpty(i.getFileType()) || ObjectUtils.isEmpty(i.getCollectUrl())) { |
| | | throw new ErrorException("未给该:" + i.getDeviceName() + "设备配置采集路径或文件后缀!"); |
| | | } |
| | | List<DataConfig> list = dataConfigService.list(Wrappers.<DataConfig>lambdaQuery() |
| | | .eq(DataConfig::getDeviceId, i.getId()) |
| | | .in(DataConfig::getInsProductItem, inspectionItemSubclass) |
| | | .orderBy(false, false, DataConfig::getId)); |
| | | hashMap.putAll(DataAcquisition.dataAcquisitionEntrance(request, list, i, entrustCode, sampleCode, ip)); |
| | | List<Map<String, Object>> inspectionItemSubclass = baseMapper.getInspectionItemSubclass(id); |
| | | if (ObjectUtils.isEmpty(device.get(0).getFileType()) || ObjectUtils.isEmpty(device.get(0).getCollectUrl())) { |
| | | throw new ErrorException("未给该:" + device.get(0).getDeviceName() + "设备配置采集路径或文件后缀!"); |
| | | } |
| | | List<DataConfig> list1 = new ArrayList<>(); |
| | | inspectionItemSubclass.forEach(i -> { |
| | | List<DataConfig> list = dataConfigService.list(Wrappers.<DataConfig>lambdaQuery() |
| | | .eq(DataConfig::getDeviceId, device.get(0).getId()) |
| | | .eq(DataConfig::getInspectionItem, i.get("inspection_item")) |
| | | .eq(DataConfig::getInspectionItemSubclass, i.get("inspection_item_subclass")) |
| | | .orderBy(false, false, DataConfig::getId)); |
| | | list1.addAll(list); |
| | | }); |
| | | String frequency = DataAcquisition.createFrequency(entrustCode, sampleCode); |
| | | hashMap.put("frequency", frequency); |
| | | return Result.success(hashMap); |
| | | Map<String, String> map = DataAcquisition.dataAcquisitionEntrance(list1, device.get(0), entrustCode, sampleCode, ip); |
| | | if (ObjectUtils.isNotEmpty(map)) { |
| | | String frequency = DataAcquisition.createFrequency(entrustCode, sampleCode); |
| | | map.put("frequency", frequency); |
| | | } |
| | | return Result.success(map); |
| | | } |
| | | } |