|
@@ -37,7 +37,7 @@ import java.util.stream.Collectors;
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
|
|
|
|
|
|
-@Tag(name = "报表接口")
|
|
|
|
|
|
|
+@Tag(name = "报表设备接口")
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/rq/report")
|
|
@RequestMapping("/rq/report")
|
|
|
@Validated
|
|
@Validated
|
|
@@ -58,6 +58,7 @@ public class IotReportDeviceController {
|
|
|
private final DeptApi deptApi;
|
|
private final DeptApi deptApi;
|
|
|
private final IotDeviceMapper iotDeviceMapper;
|
|
private final IotDeviceMapper iotDeviceMapper;
|
|
|
private final IotProductClassifyMapper iotProductClassifyMapper;
|
|
private final IotProductClassifyMapper iotProductClassifyMapper;
|
|
|
|
|
+ private final DeptUtil deptUtil;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private DeptService deptService;
|
|
private DeptService deptService;
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -65,10 +66,11 @@ public class IotReportDeviceController {
|
|
|
@Resource
|
|
@Resource
|
|
|
private SupplierService supplierService;
|
|
private SupplierService supplierService;
|
|
|
|
|
|
|
|
- public IotReportDeviceController(DeptApi deptApi, IotDeviceMapper iotDeviceMapper, IotProductClassifyMapper iotProductClassifyMapper) {
|
|
|
|
|
|
|
+ public IotReportDeviceController(DeptApi deptApi, IotDeviceMapper iotDeviceMapper, IotProductClassifyMapper iotProductClassifyMapper, DeptUtil deptUtil) {
|
|
|
this.deptApi = deptApi;
|
|
this.deptApi = deptApi;
|
|
|
this.iotDeviceMapper = iotDeviceMapper;
|
|
this.iotDeviceMapper = iotDeviceMapper;
|
|
|
this.iotProductClassifyMapper = iotProductClassifyMapper;
|
|
this.iotProductClassifyMapper = iotProductClassifyMapper;
|
|
|
|
|
+ this.deptUtil = deptUtil;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Operation(summary = "类别统计")
|
|
@Operation(summary = "类别统计")
|
|
@@ -78,10 +80,10 @@ public class IotReportDeviceController {
|
|
|
String companyCode;
|
|
String companyCode;
|
|
|
if (Objects.isNull(iotDevicePageReqVO.getDeptId())){
|
|
if (Objects.isNull(iotDevicePageReqVO.getDeptId())){
|
|
|
Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
|
- companyCode = getCompanyCode(loginUserDeptId);
|
|
|
|
|
- ids = getDeptIds(companyCode);
|
|
|
|
|
|
|
+ companyCode = deptUtil.getCompanyCode(loginUserDeptId);
|
|
|
|
|
+ ids = deptUtil.getDeptIds(companyCode);
|
|
|
} else {
|
|
} else {
|
|
|
- companyCode = getCompanyCode(iotDevicePageReqVO.getDeptId());
|
|
|
|
|
|
|
+ companyCode = deptUtil.getCompanyCode(iotDevicePageReqVO.getDeptId());
|
|
|
ids = deptService.getChildDeptIdListFromCache(iotDevicePageReqVO.getDeptId());
|
|
ids = deptService.getChildDeptIdListFromCache(iotDevicePageReqVO.getDeptId());
|
|
|
ids.add(iotDevicePageReqVO.getDeptId());
|
|
ids.add(iotDevicePageReqVO.getDeptId());
|
|
|
}
|
|
}
|
|
@@ -132,8 +134,8 @@ public class IotReportDeviceController {
|
|
|
Set<Long> ids;
|
|
Set<Long> ids;
|
|
|
if (Objects.isNull(iotDevicePageReqVO.getDeptId())){
|
|
if (Objects.isNull(iotDevicePageReqVO.getDeptId())){
|
|
|
Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
|
- String companyCode = getCompanyCode(loginUserDeptId);
|
|
|
|
|
- ids = getDeptIds(companyCode);
|
|
|
|
|
|
|
+ String companyCode = deptUtil.getCompanyCode(loginUserDeptId);
|
|
|
|
|
+ ids = deptUtil.getDeptIds(companyCode);
|
|
|
} else {
|
|
} else {
|
|
|
ids = deptService.getChildDeptIdListFromCache(iotDevicePageReqVO.getDeptId());
|
|
ids = deptService.getChildDeptIdListFromCache(iotDevicePageReqVO.getDeptId());
|
|
|
ids.add(iotDevicePageReqVO.getDeptId());
|
|
ids.add(iotDevicePageReqVO.getDeptId());
|
|
@@ -149,8 +151,8 @@ public class IotReportDeviceController {
|
|
|
Set<Long> ids;
|
|
Set<Long> ids;
|
|
|
if (Objects.isNull(iotDevicePageReqVO.getDeptId())){
|
|
if (Objects.isNull(iotDevicePageReqVO.getDeptId())){
|
|
|
Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
|
- String companyCode = getCompanyCode(loginUserDeptId);
|
|
|
|
|
- ids = getDeptIds(companyCode);
|
|
|
|
|
|
|
+ String companyCode = deptUtil.getCompanyCode(loginUserDeptId);
|
|
|
|
|
+ ids = deptUtil.getDeptIds(companyCode);
|
|
|
} else {
|
|
} else {
|
|
|
ids = deptService.getChildDeptIdListFromCache(iotDevicePageReqVO.getDeptId());
|
|
ids = deptService.getChildDeptIdListFromCache(iotDevicePageReqVO.getDeptId());
|
|
|
ids.add(iotDevicePageReqVO.getDeptId());
|
|
ids.add(iotDevicePageReqVO.getDeptId());
|
|
@@ -179,8 +181,8 @@ public class IotReportDeviceController {
|
|
|
Set<Long> ids;
|
|
Set<Long> ids;
|
|
|
if (Objects.isNull(pageReqVO.getDeptId())){
|
|
if (Objects.isNull(pageReqVO.getDeptId())){
|
|
|
Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
|
- String companyCode = getCompanyCode(loginUserDeptId);
|
|
|
|
|
- ids = getDeptIds(companyCode);
|
|
|
|
|
|
|
+ String companyCode = deptUtil.getCompanyCode(loginUserDeptId);
|
|
|
|
|
+ ids = deptUtil.getDeptIds(companyCode);
|
|
|
} else {
|
|
} else {
|
|
|
ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
|
|
ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
|
|
|
ids.add(pageReqVO.getDeptId());
|
|
ids.add(pageReqVO.getDeptId());
|
|
@@ -227,80 +229,4 @@ public class IotReportDeviceController {
|
|
|
return success(new PageResult<>(iotDeviceRespVOS, pageResult.getTotal()));
|
|
return success(new PageResult<>(iotDeviceRespVOS, pageResult.getTotal()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- private String getCompanyCode(Long deptId) {
|
|
|
|
|
- DeptRespDTO dept = deptApi.getDeptNoPermission(deptId);
|
|
|
|
|
- String name = dept.getName();
|
|
|
|
|
- String companyCode = "";
|
|
|
|
|
- if (name.contains("瑞恒")) {
|
|
|
|
|
- companyCode = "rh";
|
|
|
|
|
- } else if (name.contains("瑞都")) {
|
|
|
|
|
- companyCode = "rd";
|
|
|
|
|
- } else if (name.contains("瑞鹰")) {
|
|
|
|
|
- companyCode = "ry";
|
|
|
|
|
- } else if (name.contains("科瑞石油技术")) {
|
|
|
|
|
- companyCode = "jt";
|
|
|
|
|
- } else {
|
|
|
|
|
- Long parentId = dept.getParentId();
|
|
|
|
|
- DeptRespDTO dept1 = deptApi.getDeptNoPermission(parentId);
|
|
|
|
|
- String name1 = dept1.getName();
|
|
|
|
|
- if (name1.contains("瑞恒")) {
|
|
|
|
|
- companyCode = "rh";
|
|
|
|
|
- } else if (name1.contains("瑞都")) {
|
|
|
|
|
- companyCode = "rd";
|
|
|
|
|
- } else if (name1.contains("瑞鹰")) {
|
|
|
|
|
- companyCode = "ry";
|
|
|
|
|
- } else if (name1.contains("科瑞石油技术")) {
|
|
|
|
|
- companyCode = "jt";
|
|
|
|
|
- } else {
|
|
|
|
|
- DeptRespDTO dept2 = deptApi.getDeptNoPermission(dept1.getParentId());
|
|
|
|
|
- String name2 = dept2.getName();
|
|
|
|
|
- if (name2.contains("瑞恒")) {
|
|
|
|
|
- companyCode = "rh";
|
|
|
|
|
- } else if (name2.contains("瑞都")) {
|
|
|
|
|
- companyCode = "rd";
|
|
|
|
|
- } else if (name2.contains("瑞鹰")) {
|
|
|
|
|
- companyCode = "ry";
|
|
|
|
|
- } else {
|
|
|
|
|
- DeptRespDTO dept3= deptApi.getDeptNoPermission(dept2.getParentId());
|
|
|
|
|
- String name3 = dept3.getName();
|
|
|
|
|
- if (name3.contains("瑞恒")) {
|
|
|
|
|
- companyCode = "rh";
|
|
|
|
|
- } else if (name3.contains("瑞都")) {
|
|
|
|
|
- companyCode = "rd";
|
|
|
|
|
- } else if (name3.contains("瑞鹰")) {
|
|
|
|
|
- companyCode = "ry";
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return companyCode;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public Set<Long> getDeptIds(String dept) {
|
|
|
|
|
- Set<Long> ids = new HashSet<>();
|
|
|
|
|
- List<DeptRespDTO> depts = new ArrayList<>();
|
|
|
|
|
- if ("rd".equals(dept)) {
|
|
|
|
|
- depts = deptApi.getDeptByName("四川瑞都");
|
|
|
|
|
- } else if ("rh".equals(dept)) {
|
|
|
|
|
- depts = deptApi.getDeptByName("瑞恒兴域");
|
|
|
|
|
- } else if ("ry".equals(dept)) {
|
|
|
|
|
- depts = deptApi.getDeptByName("瑞鹰国际");
|
|
|
|
|
- } else if ("jt".equals(dept)) {
|
|
|
|
|
- depts = deptApi.getDeptByName("科瑞石油技术");
|
|
|
|
|
- } else {
|
|
|
|
|
- Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
|
|
|
- DeptRespDTO dto = deptApi.getDept(loginUserDeptId);
|
|
|
|
|
- depts = deptApi.getDeptByName(dto.getName());
|
|
|
|
|
- }
|
|
|
|
|
- if (CollUtil.isNotEmpty(depts)) {
|
|
|
|
|
- Long deptId = depts.get(0).getId();
|
|
|
|
|
- if (Objects.nonNull(depts.get(0).getId())) {
|
|
|
|
|
- ids = deptService.getChildDeptIdListFromCache(depts.get(0).getId());
|
|
|
|
|
- ids.add(deptId);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return ids;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|