| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean initSites(DeviceSiteParame param) { |
| | | if (param.getFlagInit() != null && param.getFlagInit() == 1) { |
| | | List<DeviceSite> list = this.list(new LambdaQueryWrapper<DeviceSite>().select(DeviceSite::getId).last("limit 1")); |
| | | // List<DeviceSite> list = this.list(new LambdaQueryWrapper<DeviceSite>().select(DeviceSite::getId).last("limit 1")); |
| | | List<DeviceSite> list = this.list(new LambdaQueryWrapper<DeviceSite>()); |
| | | if (!list.isEmpty()) { |
| | | if (!this.remove(new LambdaQueryWrapper<>())) { |
| | | throw new CoolException("初始化失败: 删除站点失败!!"); |
| | |
| | | String targetVal = truncate(row.getTarget().trim(), TARGET_MAX_LENGTH); |
| | | String commonName = StringUtils.isNotBlank(param.getName()) ? param.getName().trim() : null; |
| | | String commonLabel = StringUtils.isNotBlank(param.getLabel()) ? param.getLabel().trim() : null; |
| | | ds.setType(String.valueOf(typeId)) |
| | | .setSite(siteName) |
| | | .setDevice(param.getDeviceType()) |
| | | .setDeviceSite(deviceSiteName) |
| | | .setTarget(targetVal) |
| | | .setDeviceCode(param.getDeviceCode()) |
| | | .setAreaIdStart(param.getAreaIdStart()) |
| | | .setAreaIdEnd(param.getAreaIdEnd()) |
| | | .setChannel(ch) |
| | | .setName(commonName != null ? commonName : (deviceSiteName + "-" + siteName + "-" + targetVal + "-" + ch)) |
| | | .setLabel(commonLabel); |
| | | // ds.setType(String.valueOf(typeId)) |
| | | // .setSite(siteName) |
| | | // .setDevice(param.getDeviceType()) |
| | | // .setDeviceSite(deviceSiteName) |
| | | // .setTarget(targetVal) |
| | | // .setDeviceCode(param.getDeviceCode()) |
| | | //// .setAreaIdStart(param.getAreaIdStart()) |
| | | //// .setAreaIdEnd(param.getAreaIdEnd()) |
| | | // .setChannel(ch) |
| | | // .setName(commonName != null ? commonName : (deviceSiteName + "-" + siteName + "-" + targetVal + "-" + ch)) |
| | | // .setLabel(commonLabel); |
| | | deviceSites.add(ds); |
| | | } |
| | | } |