| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean initSites(DeviceSiteParame param) { |
| | | if (param.getFlagInit() == 1) { |
| | | List<DeviceSite> list = this.list(new LambdaQueryWrapper<DeviceSite>().select(DeviceSite::getId).last("limit 1")); |
| | |
| | | List<String> targets = Arrays.asList(StringUtils.split(param.getTarget(), ",")); |
| | | List<DeviceSite> deviceSites = new ArrayList<>(); |
| | | for (String site : sites) { |
| | | BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, site)); |
| | | BasStation basStation = basStationService.getById(site); |
| | | if (null == basStation) { |
| | | throw new CoolException("初始化失败: 站点未找到!!"); |
| | | } |
| | | for (String deviceSite : dvSites) { |
| | | BasStation basStation2 = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, deviceSite)); |
| | | BasStation basStation2 = basStationService.getById(deviceSite); |
| | | if (null == basStation2) { |
| | | throw new CoolException("初始化失败: 作业站点未找到!!"); |
| | | } |
| | |
| | | for (String target : targets) { |
| | | DeviceSite site1 = new DeviceSite(); |
| | | site1.setType(id + "") |
| | | .setSite(site) |
| | | .setSite(basStation.getStationName()) |
| | | .setDevice(param.getDeviceType()) |
| | | .setDeviceSite(deviceSite) |
| | | .setDeviceSite(basStation2.getStationName()) |
| | | .setTarget(target) |
| | | .setDeviceCode(param.getDeviceCode()) |
| | | .setAreaIdStart(param.getAreaIdStart()) |
| | | .setAreaIdEnd(param.getAreaIdEnd()) |
| | | .setChannel(param.getChannel()) |
| | | ; |
| | | deviceSites.add(site1); |