| | |
| | | package com.vincent.rsf.server.manager.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.manager.controller.params.DeviceSiteParame; |
| | |
| | | @Override |
| | | public boolean initSites(DeviceSiteParame param) { |
| | | if (param.getFlagInit() == 1) { |
| | | if (!this.remove(new LambdaQueryWrapper<>())) { |
| | | throw new CoolException("初始化失败: 删除站点失败!!"); |
| | | List<DeviceSite> list = this.list(new LambdaQueryWrapper<DeviceSite>().select(DeviceSite::getId).last("limit 1")); |
| | | if (!list.isEmpty()) { |
| | | if (!this.remove(new LambdaQueryWrapper<>())) { |
| | | throw new CoolException("初始化失败: 删除站点失败!!"); |
| | | } |
| | | } |
| | | } |
| | | if (Objects.isNull(param.getDeviceSites()) || param.getDeviceSites().isEmpty()) { |
| | | if (Objects.isNull(param.getDeviceSites()) || StringUtils.isBlank(param.getDeviceSites())) { |
| | | throw new CoolException("初始化失败: 设备作业站点不能为空!!"); |
| | | } |
| | | if (Objects.isNull(param.getSites()) || param.getSites().isEmpty()) { |
| | | if (Objects.isNull(param.getSites()) || StringUtils.isBlank(param.getSites())) { |
| | | throw new CoolException("初始化失败: 作业站点不能为空!!"); |
| | | } |
| | | if (Objects.isNull(param.getTypeIds()) || param.getTypeIds().isEmpty()) { |
| | | throw new CoolException("初始化失败: 作业类型不能为空!!"); |
| | | } |
| | | List<String> sites = Arrays.asList(StringUtils.split(param.getSites(), ",")); |
| | | List<String> dvSites = Arrays.asList(StringUtils.split(param.getDeviceSites(), ",")); |
| | | List<DeviceSite> deviceSites = new ArrayList<>(); |
| | | for (String site : param.getSites()) { |
| | | for (String deviceSite : param.getDeviceSites()) { |
| | | for (String site : sites) { |
| | | for (String deviceSite : dvSites) { |
| | | for (Long id : param.getTypeIds()) { |
| | | DeviceSite site1 = new DeviceSite(); |
| | | site1.setType(id + "") |