|
|
@ -4,22 +4,23 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.qs.serve.common.model.dto.TreeNode; |
|
|
|
import com.qs.serve.common.util.*; |
|
|
|
import com.qs.serve.modules.bms.entity.BmsRegion2; |
|
|
|
import com.qs.serve.modules.bms.entity.BmsRegionUser; |
|
|
|
import com.qs.serve.modules.bms.entity.BmsSupplier; |
|
|
|
import com.qs.serve.modules.bms.common.FactoryIdOperation; |
|
|
|
import com.qs.serve.modules.bms.entity.*; |
|
|
|
import com.qs.serve.modules.bms.entity.vo.BmsRegionTreeVo; |
|
|
|
import com.qs.serve.modules.bms.mapper.BmsChannelPointMapper; |
|
|
|
import com.qs.serve.modules.bms.mapper.BmsFactoryMapper; |
|
|
|
import com.qs.serve.modules.bms.service.BmsFactoryService; |
|
|
|
import com.qs.serve.modules.bms.service.BmsRegionUserService; |
|
|
|
import com.qs.serve.modules.sys.entity.SysUser; |
|
|
|
import com.qs.serve.modules.sys.service.SysUserService; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.qs.serve.modules.bms.entity.BmsRegion; |
|
|
|
import com.qs.serve.modules.bms.service.BmsRegionService; |
|
|
|
import com.qs.serve.modules.bms.mapper.BmsRegionMapper; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -36,10 +37,17 @@ public class BmsRegionServiceImpl extends ServiceImpl<BmsRegionMapper,BmsRegion> |
|
|
|
private BmsRegionUserService bmsRegionUserService; |
|
|
|
private SysUserService sysUserService; |
|
|
|
private BmsChannelPointMapper bmsChannelPointMapper; |
|
|
|
private BmsFactoryService bmsFactoryService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean saveBmsRegion(BmsRegion param){ |
|
|
|
param = this.flushLevel(param); |
|
|
|
|
|
|
|
LambdaQueryWrapper<BmsFactory> lqw = new LambdaQueryWrapper<>(); |
|
|
|
lqw.orderByAsc(BmsFactory::getCode); |
|
|
|
String[] FactoryIds = bmsFactoryService.list(lqw).stream().map(a->a.getId()).toArray(String[]::new); |
|
|
|
|
|
|
|
param.setFactoryIds(FactoryIds); |
|
|
|
return this.save(param); |
|
|
|
} |
|
|
|
|
|
|
@ -218,5 +226,40 @@ public class BmsRegionServiceImpl extends ServiceImpl<BmsRegionMapper,BmsRegion> |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void updateAllFactoryIdsByFactoryId(String id, String addOrDel){ |
|
|
|
List<BmsRegion> regionList = this.list(); |
|
|
|
|
|
|
|
LambdaQueryWrapper<BmsFactory> lqw = new LambdaQueryWrapper<>(); |
|
|
|
lqw.orderByAsc(BmsFactory::getCode); |
|
|
|
String[] FactoryIds = bmsFactoryService.list(lqw).stream().map(a->a.getId()).toArray(String[]::new); |
|
|
|
|
|
|
|
for(BmsRegion region:regionList){ |
|
|
|
if(CollectionUtil.isNotEmpty(region.getFactoryIds())) { |
|
|
|
if (addOrDel.equals(FactoryIdOperation.Add)) { |
|
|
|
region = AddOneFactoryIds(region, id); |
|
|
|
} else { |
|
|
|
region = delOneFactoryIds(region, id); |
|
|
|
} |
|
|
|
}else { |
|
|
|
region.setFactoryIds(FactoryIds); |
|
|
|
} |
|
|
|
} |
|
|
|
this.updateBatchById(regionList); |
|
|
|
} |
|
|
|
|
|
|
|
private BmsRegion delOneFactoryIds(BmsRegion region,String id){ |
|
|
|
String[] newIds = Arrays.stream(region.getFactoryIds()) |
|
|
|
.filter(e -> !e.equals(id)).toArray(String[]::new); |
|
|
|
region.setFactoryIds(newIds); |
|
|
|
return region; |
|
|
|
} |
|
|
|
|
|
|
|
private BmsRegion AddOneFactoryIds(BmsRegion region,String id){ |
|
|
|
List<String> newIds = new ArrayList<>(Arrays.asList(region.getFactoryIds())); |
|
|
|
newIds.add(id); |
|
|
|
region.setFactoryIds(newIds.stream().toArray(String[]::new)); |
|
|
|
return region; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|