物联用户权限功能优化
This commit is contained in:
@@ -1,18 +1,13 @@
|
|||||||
package com.njcn.csdevice.api;
|
package com.njcn.csdevice.api;
|
||||||
|
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
|
||||||
import com.njcn.common.pojo.constant.ServerInfo;
|
import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.HttpResultUtil;
|
|
||||||
import com.njcn.csdevice.api.fallback.CsLedgerFeignClientFallbackFactory;
|
import com.njcn.csdevice.api.fallback.CsLedgerFeignClientFallbackFactory;
|
||||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||||
import com.njcn.csdevice.pojo.dto.LineParamDTO;
|
import com.njcn.csdevice.pojo.dto.LineParamDTO;
|
||||||
import com.njcn.csdevice.pojo.param.CsLedgerParam;
|
import com.njcn.csdevice.pojo.param.CsLedgerParam;
|
||||||
import com.njcn.csdevice.pojo.po.CsLedger;
|
import com.njcn.csdevice.pojo.po.CsLedger;
|
||||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -54,5 +49,8 @@ public interface CsLedgerFeignClient {
|
|||||||
@ApiOperation("根据工程获取设备信息")
|
@ApiOperation("根据工程获取设备信息")
|
||||||
HttpResult<List<DevDetailDTO>> getDevInfoByEngineerIds(@RequestBody @Validated List<String> list);
|
HttpResult<List<DevDetailDTO>> getDevInfoByEngineerIds(@RequestBody @Validated List<String> list);
|
||||||
|
|
||||||
|
@PostMapping("/getEngineeringHaveDevs")
|
||||||
|
@ApiOperation("根据工程信息获取有设备的工程")
|
||||||
|
HttpResult<List<DevDetailDTO>> getEngineeringHaveDevs(@RequestBody @Validated List<String> list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,12 @@ public class CsLedgerFeignClientFallbackFactory implements FallbackFactory<CsLed
|
|||||||
log.error("{}异常,降级处理,异常为:{}","根据工程获取设备信息",cause.toString());
|
log.error("{}异常,降级处理,异常为:{}","根据工程获取设备信息",cause.toString());
|
||||||
throw new BusinessException(finalExceptionEnum);
|
throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<List<DevDetailDTO>> getEngineeringHaveDevs(List<String> list) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","根据工程获取设备信息",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,5 +185,15 @@ public class CsLedgerController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, details, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, details, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/getEngineeringHaveDevs")
|
||||||
|
@ApiOperation("根据工程信息获取有设备的工程")
|
||||||
|
@ApiImplicitParam(name = "list", value = "查询条件", required = true)
|
||||||
|
public HttpResult<List<DevDetailDTO>> getEngineeringHaveDevs(@RequestBody @Validated List<String> list){
|
||||||
|
String methodDescribe = getMethodDescribe("getEngineeringHaveDevs");
|
||||||
|
List<DevDetailDTO> details = csLedgerService.getEngineeringHaveDevs(list);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, details, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,4 +89,7 @@ public interface ICsLedgerService extends IService<CsLedger> {
|
|||||||
List<DevDetailDTO> getInfoByIds(List<String> list);
|
List<DevDetailDTO> getInfoByIds(List<String> list);
|
||||||
|
|
||||||
List<DevDetailDTO> getDevInfoByEngineerIds(List<String> list);
|
List<DevDetailDTO> getDevInfoByEngineerIds(List<String> list);
|
||||||
|
|
||||||
|
List<DevDetailDTO> getEngineeringHaveDevs(List<String> list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,10 +36,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.function.Function;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -224,6 +222,7 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CsEngineeringPO> getUnlinkedEngineering(String userId) {
|
public List<CsEngineeringPO> getUnlinkedEngineering(String userId) {
|
||||||
|
List<CsEngineeringPO> result = new ArrayList<>();
|
||||||
List<String> list1 = new ArrayList<>();
|
List<String> list1 = new ArrayList<>();
|
||||||
//根据用户信息获取设备信息
|
//根据用户信息获取设备信息
|
||||||
List<String> devList = csDeviceUserFeignClient.findDevByUserId(userId).getData();
|
List<String> devList = csDeviceUserFeignClient.findDevByUserId(userId).getData();
|
||||||
@@ -236,13 +235,28 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//获取所有工程信息
|
//获取有设备的工程信息
|
||||||
LambdaQueryWrapper<CsEngineeringPO> queryWrapper2 = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<CsEngineeringPO> queryWrapper2 = new LambdaQueryWrapper<>();
|
||||||
queryWrapper2.eq(CsEngineeringPO::getStatus,"1");
|
queryWrapper2.eq(CsEngineeringPO::getStatus,"1");
|
||||||
if (CollectionUtil.isNotEmpty(list1)) {
|
if (CollectionUtil.isNotEmpty(list1)) {
|
||||||
queryWrapper2.notIn(CsEngineeringPO::getId,list1);
|
queryWrapper2.notIn(CsEngineeringPO::getId,list1);
|
||||||
}
|
}
|
||||||
return this.baseMapper.selectList(queryWrapper2);
|
List<CsEngineeringPO> list = this.baseMapper.selectList(queryWrapper2);
|
||||||
|
//剔除没有设备的工程
|
||||||
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
|
Map<String, CsEngineeringPO> map = list.stream().collect(Collectors.toMap(CsEngineeringPO::getId, Function.identity()));
|
||||||
|
List<String> list2 = list.stream().map(CsEngineeringPO::getId).collect(Collectors.toList());
|
||||||
|
List<DevDetailDTO> ledger = csLedgerFeignClient.getEngineeringHaveDevs(list2).getData();
|
||||||
|
if (CollectionUtil.isNotEmpty(ledger)) {
|
||||||
|
ledger.forEach(item->{
|
||||||
|
CsEngineeringPO po = new CsEngineeringPO();
|
||||||
|
po.setId(item.getEngineeringid());
|
||||||
|
po.setName(map.get(item.getEngineeringid()).getName());
|
||||||
|
result.add(po);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -837,6 +837,27 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
|||||||
return details;
|
return details;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DevDetailDTO> getEngineeringHaveDevs(List<String> list) {
|
||||||
|
List<DevDetailDTO> result = new ArrayList<>();
|
||||||
|
list.forEach(item->{
|
||||||
|
LambdaQueryWrapper<CsLedger> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(CsLedger::getPid, item);
|
||||||
|
List<CsLedger> project = this.list(queryWrapper);
|
||||||
|
//工程id
|
||||||
|
List<String> projectIds = project.stream().map(CsLedger::getId).collect(Collectors.toList());
|
||||||
|
LambdaQueryWrapper<CsLedger> queryWrapper2 = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper2.in(CsLedger::getPid, projectIds);
|
||||||
|
List<CsLedger> dev = this.list(queryWrapper2);
|
||||||
|
if (CollectionUtil.isNotEmpty(dev)) {
|
||||||
|
DevDetailDTO dto = new DevDetailDTO();
|
||||||
|
dto.setEngineeringid(item);
|
||||||
|
result.add(dto);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取子节点
|
* 获取子节点
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user