|
|
|
|
@@ -3,26 +3,30 @@ package com.njcn.csdevice.service.impl;
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.njcn.common.pojo.exception.BusinessException;
|
|
|
|
|
import com.njcn.csdevice.enums.LineBaseEnum;
|
|
|
|
|
import com.njcn.csdevice.mapper.CsLedgerMapper;
|
|
|
|
|
import com.njcn.csdevice.mapper.*;
|
|
|
|
|
import com.njcn.csdevice.pojo.param.CsLedgerParam;
|
|
|
|
|
import com.njcn.csdevice.pojo.po.AppProjectPO;
|
|
|
|
|
import com.njcn.csdevice.pojo.po.AppTopologyDiagramPO;
|
|
|
|
|
import com.njcn.csdevice.pojo.po.CsEngineeringPO;
|
|
|
|
|
import com.njcn.csdevice.pojo.po.CsLedger;
|
|
|
|
|
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
|
|
|
|
import com.njcn.csdevice.service.ICsEngineeringUserService;
|
|
|
|
|
import com.njcn.csdevice.service.ICsLedgerService;
|
|
|
|
|
import com.njcn.oss.utils.FileStorageUtil;
|
|
|
|
|
import com.njcn.redis.utils.RedisUtil;
|
|
|
|
|
import com.njcn.system.api.AreaFeignClient;
|
|
|
|
|
import com.njcn.system.pojo.po.Area;
|
|
|
|
|
import com.njcn.web.utils.RequestUtil;
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
import org.bouncycastle.cert.ocsp.Req;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -38,6 +42,13 @@ import java.util.stream.Collectors;
|
|
|
|
|
public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> implements ICsLedgerService {
|
|
|
|
|
|
|
|
|
|
private final ICsEngineeringUserService csEngineeringUserService;
|
|
|
|
|
private final AreaFeignClient areaFeignClient;
|
|
|
|
|
private final RedisUtil redisUtil;
|
|
|
|
|
private final AppTopologyDiagramMapper appTopologyDiagramMapper;
|
|
|
|
|
private final AppProjectMapper appProjectMapper;
|
|
|
|
|
private final CsEngineeringMapper csEngineeringMapper;
|
|
|
|
|
|
|
|
|
|
private final FileStorageUtil fileStorageUtil;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<CsLedgerVO> getLedgerTree() {
|
|
|
|
|
@@ -136,11 +147,66 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
|
|
|
|
return this.lambdaQuery().eq(CsLedger::getId,id).one();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<CsLedgerVO> getProjectTree() {
|
|
|
|
|
List<CsLedgerVO> engineeringList = new ArrayList<>();
|
|
|
|
|
List<CsLedgerVO> allList = this.baseMapper.getAll();
|
|
|
|
|
//fixme 这边先根据登录的用户名称来区分是否展示所有的台账信息
|
|
|
|
|
if (Objects.equals(RequestUtil.getUsername(),"root") || Objects.equals(RequestUtil.getUsername(),"njcnser")){
|
|
|
|
|
engineeringList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
|
|
|
|
} else {
|
|
|
|
|
List<CsEngineeringPO> engineering = csEngineeringUserService.getEngineeringByUser();
|
|
|
|
|
engineeringList = allList.stream().filter(item->engineering.stream().map(CsEngineeringPO::getId).collect(Collectors.toList()).contains(item.getId())).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
|
|
|
|
QueryWrapper<AppTopologyDiagramPO> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.eq("status","1");
|
|
|
|
|
List<AppTopologyDiagramPO> appTopologyDiagramPOS = appTopologyDiagramMapper.selectList(queryWrapper);
|
|
|
|
|
projectList.forEach(temp->{
|
|
|
|
|
AppProjectPO appProjectPO = appProjectMapper.selectById(temp.getId());
|
|
|
|
|
temp.setArea(appProjectPO.getArea());
|
|
|
|
|
temp.setRemark(appProjectPO.getDescription());
|
|
|
|
|
List<CsLedgerVO> collect = appTopologyDiagramPOS.stream().filter(appTopologyDiagramPO -> Objects.equals(appTopologyDiagramPO.getProjectId(), temp.getId()))
|
|
|
|
|
.map(po -> {
|
|
|
|
|
CsLedgerVO vo = new CsLedgerVO();
|
|
|
|
|
vo.setId(po.getId());
|
|
|
|
|
vo.setPid(po.getProjectId());
|
|
|
|
|
vo.setName(po.getName());
|
|
|
|
|
vo.setPath(fileStorageUtil.getFileUrl(po.getFilePath()));
|
|
|
|
|
return vo;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
temp.setChildren(collect);
|
|
|
|
|
});
|
|
|
|
|
engineeringList.forEach(eng -> {
|
|
|
|
|
|
|
|
|
|
CsEngineeringPO csEngineeringPO = csEngineeringMapper.selectById(eng.getId());
|
|
|
|
|
eng.setArea(this.getAreaById(csEngineeringPO.getProvince())+this.getAreaById(csEngineeringPO.getCity()));
|
|
|
|
|
eng.setRemark(csEngineeringPO.getDescription());
|
|
|
|
|
eng.setChildren(getChildren(eng, projectList));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return engineeringList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取子节点
|
|
|
|
|
*/
|
|
|
|
|
public List<CsLedgerVO> getChildren(CsLedgerVO item, List<CsLedgerVO> all) {
|
|
|
|
|
return all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
public String getAreaById(String id){
|
|
|
|
|
|
|
|
|
|
String areaName =redisUtil.getStringByKey (id);
|
|
|
|
|
areaName = Optional.ofNullable (areaName).orElseGet (() ->{
|
|
|
|
|
Area data = areaFeignClient.selectIdArea (id).getData ( );
|
|
|
|
|
redisUtil.saveByKey (id,data.getName ());
|
|
|
|
|
return data.getName ();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return areaName;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|