提交 44cf4776 authored 作者: 吕本才's avatar 吕本才

1、修改报表分组列表查询接口

上级 b0321c2f
package com.link.report.controller.query;
import com.link.report.pojo.request.CustomerReportQueryListVo;
import com.link.report.pojo.response.CustomerReportGroupResDto;
import com.link.report.service.CustomerReportGroupService;
import com.sfa.common.core.domain.R;
......@@ -23,10 +24,10 @@ public class CustomerReportGroupQueryController {
@Autowired
CustomerReportGroupService customerReportGroupService;
@RequiresPermissions("bi:customerReport:list")
@RequiresPermissions("bi:supply:list")
@GetMapping("/group/list")
public R<List<CustomerReportGroupResDto>> queryList() {
List<CustomerReportGroupResDto> dtos = customerReportGroupService.queryList();
public R<List<CustomerReportGroupResDto>> queryList(CustomerReportQueryListVo vo) {
List<CustomerReportGroupResDto> dtos = customerReportGroupService.queryList(vo);
return R.ok(dtos);
}
}
package com.link.report.controller.query;
import com.link.report.pojo.request.CustomerReportQueryListVo;
import com.link.report.pojo.response.CustomerReportListDto;
import com.link.report.service.CustomerReportService;
import com.sfa.common.core.domain.R;
import com.sfa.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
......@@ -22,7 +23,7 @@ public class CustomerReportQueryController {
@Autowired
CustomerReportService customerReportService;
@RequiresPermissions("bi:customerReport:list")
@RequiresPermissions("bi:supply:list")
@GetMapping("/list")
public R<List<CustomerReportListDto>> queryList() {
List<CustomerReportListDto> customerReportListDtos = customerReportService.queryCustomerReportList();
......
......@@ -6,6 +6,7 @@ import com.link.report.service.ReportShareService;
import com.sfa.common.core.domain.R;
import com.sfa.common.core.web.controller.BaseController;
import com.sfa.common.datascope.annotation.DataScope;
import com.sfa.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -34,6 +35,7 @@ public class ReportShareQueryController extends BaseController {
*/
@DataScope(deptAlias = "d", userAlias = "u")
@GetMapping("/list")
@RequiresPermissions("bi:supply:list")
public R<List<ReportShareBiListDto>> selectList(ReportShareListVo reportShareListVo) {
List<ReportShareBiListDto> reportShareBiListDtos = reportShareService.selectList(reportShareListVo);
return R.ok(reportShareBiListDtos);
......
package com.link.report.domain.dao;
import com.link.report.domain.wq.CustomerGroupQueryWq;
import com.link.report.pojo.response.CustomerGroupDto;
import java.util.List;
public interface CustomerGroupDao {
List<CustomerGroupDto> queryList(CustomerGroupQueryWq wq);
}
package com.link.report.domain.dao.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.link.report.domain.dao.CustomerGroupDao;
import com.link.report.domain.entity.CustomerGroup;
import com.link.report.domain.mapper.CustomerGroupMapper;
import com.link.report.domain.wq.CustomerGroupQueryWq;
import com.link.report.pojo.response.CustomerGroupDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
* 报表分享数据
*/
@Component
public class CustomerGroupDaoImpl implements CustomerGroupDao {
@Autowired
private CustomerGroupMapper groupMapper;
@Override
public List<CustomerGroupDto> queryList(CustomerGroupQueryWq wq) {
Wrapper<CustomerGroup> wraper = new LambdaQueryWrapper<CustomerGroup>()
.eq(ObjectUtil.isNotEmpty(wq.getCategoryName()), CustomerGroup::getCategoryName, wq.getCategoryName());
List<CustomerGroup> customerGroups = groupMapper.selectList(wraper);
List<CustomerGroupDto> result = new ArrayList<>();
for (CustomerGroup customerGroup : customerGroups) {
CustomerGroupDto dto = new CustomerGroupDto();
dto.setGroupId(customerGroup.getId());
dto.setGroupName(customerGroup.getName());
dto.setCatalogName(customerGroup.getCategoryName());
result.add(dto);
}
return result;
}
}
package com.link.report.domain.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
/**
* 对应数据库自定义分组表 customer_group 的 Java Bean 类
*/
@TableName(value ="customer_group")
@Data
public class CustomerGroup {
/**
* 主键
*/
private String id;
/**
* 分组名称
*/
private String name;
/**
* 说明
*/
private String remark;
/**
* 分类名称
*/
private String categoryName;
/**
* 创建人
*/
private String createBy;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改人
*/
private String updateBy;
/**
* 修改时间
*/
private Date updateTime;
/**
* 删除标识,0 表示正常,1 表示已删除
*/
private Integer delFlag;
/**
* 多租户标识
*/
private String tenantId;
/**
* 乐观锁版本
*/
private Integer updateCount;
}
......@@ -9,6 +9,7 @@ import java.util.Date;
public class CustomerReportGroup {
private String id;
private String reportId;
private Integer reportType;
private String groupId;
private String createBy;
private Date createTime;
......
package com.link.report.domain.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.link.report.domain.entity.CustomerGroup;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CustomerGroupMapper extends BaseMapper<CustomerGroup> {
}
package com.link.report.domain.wq;
import lombok.Data;
@Data
public class CustomerGroupQueryWq {
private String categoryName;
}
......@@ -9,5 +9,5 @@ import lombok.Data;
*/
@Data
public class CustomerReportQueryListVo {
private String categoryName;
}
package com.link.report.pojo.response;
import lombok.Data;
@Data
public class CustomerGroupDto {
private String groupId;
private String groupName;
private String catalogName;
}
......@@ -4,9 +4,10 @@ import lombok.Data;
@Data
public class CustomerReportGroupQueryListDto {
private String reportId;
private String groupId;
private String groupName;
private String reportId;
private String reportName;
private Integer reportType;
private String previewUrl;
}
package com.link.report.service;
import com.link.report.pojo.request.CustomerReportGroupVo;
import com.link.report.pojo.request.CustomerReportQueryListVo;
import com.link.report.pojo.response.CustomerReportGroupResDto;
import java.util.List;
public interface CustomerReportGroupService {
List<CustomerReportGroupResDto> queryList();
List<CustomerReportGroupResDto> queryList(CustomerReportQueryListVo vo);
void save(List<CustomerReportGroupVo> customerReportAddVo);
}
package com.link.report.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import com.link.report.domain.dao.CustomerGroupDao;
import com.link.report.domain.dao.CustomerReportGroupDao;
import com.link.report.domain.entity.CustomerReportGroup;
import com.link.report.domain.wq.CustomerGroupQueryWq;
import com.link.report.pojo.request.CustomerReportGroupVo;
import com.link.report.pojo.request.CustomerReportQueryListVo;
import com.link.report.pojo.response.CustomerGroupDto;
import com.link.report.pojo.response.CustomerReportGroupQueryListDto;
import com.link.report.pojo.response.CustomerReportGroupResDto;
import com.link.report.pojo.response.ReportItemsDto;
......@@ -16,52 +19,56 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 报表分享数据
*/
@Service
public class CustomerReportGroupServiceImpl implements CustomerReportGroupService {
public class CustomerReportGroupServiceImpl implements CustomerReportGroupService {
@Autowired
private CustomerReportGroupDao customerReportGroupDao;
@Autowired
private CustomerGroupDao customerGroupDao;
@Override
public List<CustomerReportGroupResDto> queryList() {
List<CustomerReportGroupQueryListDto> list = customerReportGroupDao.queryList();
// 根据dtos 依照groupId,作为key,转换成 Map结构
Map<String, List<CustomerReportGroupQueryListDto>> groupedMap = list.stream()
.collect(Collectors.groupingBy(CustomerReportGroupQueryListDto::getGroupId));
public List<CustomerReportGroupResDto> queryList(CustomerReportQueryListVo vo) {
CustomerGroupQueryWq wq = new CustomerGroupQueryWq();
wq.setCategoryName(vo.getCategoryName());
// 先查询分组
List<CustomerGroupDto> groupDtos = customerGroupDao.queryList(wq);
List<CustomerReportGroupQueryListDto> list = customerReportGroupDao.queryList();
// 转换成list结构
List<CustomerReportGroupResDto> result = new ArrayList<>();
for (CustomerReportGroupQueryListDto dto : list) {
List<CustomerReportGroupResDto> result = new ArrayList<>();
for (CustomerGroupDto dto : groupDtos) {
// 先看分组
CustomerReportGroupResDto resDto = new CustomerReportGroupResDto();
resDto.setGroupId(dto.getGroupId());
resDto.setGroupName(dto.getGroupName());
List<CustomerReportGroupQueryListDto> groupListDtos = groupedMap.get(dto.getGroupId());
if(ObjectUtil.isNotEmpty(groupListDtos)){
List<ReportItemsDto> itemsDtos = new ArrayList<>();
// 转换成ReportShareBiListDto
for (CustomerReportGroupQueryListDto groupListDto : groupListDtos) {
List<ReportItemsDto> itemsDtos = new ArrayList<>();
// 在看报表
for (CustomerReportGroupQueryListDto reportGroupQueryListDto : list) {
if (reportGroupQueryListDto.getGroupId().equals(dto.getGroupId())) {
// 转换成ReportShareBiListDto
ReportItemsDto itemsDto = new ReportItemsDto();
itemsDto.setReportId(groupListDto.getReportId());
itemsDto.setReportName(groupListDto.getReportName());
itemsDto.setPreviewUrl(groupListDto.getPreviewUrl());
itemsDto.setReportId(reportGroupQueryListDto.getReportId());
itemsDto.setReportName(reportGroupQueryListDto.getReportName());
itemsDto.setPreviewUrl(reportGroupQueryListDto.getPreviewUrl());
itemsDtos.add(itemsDto);
}
resDto.setItems(itemsDtos);
}
resDto.setItems(itemsDtos);
result.add(resDto);
}
return result;
}
/**
* 新增或者修改
*
* @param customerReportGroupVo
*/
@Transactional(rollbackFor = Exception.class)
......@@ -72,7 +79,7 @@ public class CustomerReportGroupServiceImpl implements CustomerReportGroupServic
customerReportGroupDao.deleteByCreatorId(userId);
// 新增
List<CustomerReportGroup> items = new ArrayList<>();
List<CustomerReportGroup> items = new ArrayList<>();
for (CustomerReportGroupVo vo : customerReportGroupVo) {
List<ReportItemsDto> itemsDtos = vo.getItems();
for (ReportItemsDto item : itemsDtos) {
......@@ -81,7 +88,8 @@ public class CustomerReportGroupServiceImpl implements CustomerReportGroupServic
dto.setId(IdUtil.getSnowflakeNextIdStr());
dto.setGroupId(vo.getId());
dto.setReportId(item.getReportId());
dto.setCreateBy(String.valueOf(userId));
dto.setReportType(item.getReportType());
dto.setCreateBy(String.valueOf(userId));
dto.setTenantId(String.valueOf(userId));
items.add(dto);
}
......
......@@ -7,6 +7,7 @@
INSERT INTO customer_report_group (
id,
report_id,
report_type,
group_id,
create_by,
create_time,
......@@ -20,6 +21,7 @@
(
#{item.id},
#{item.reportId},
#{item.reportType},
#{item.groupId},
#{item.createBy},
#{item.createTime},
......@@ -35,16 +37,18 @@
<select id="queryReportGroupList" resultType="com.link.report.pojo.response.CustomerReportGroupQueryListDto">
<!-- 自定义报表关联 -->
select distinct groupId ,groupName,reportId,reportName,previewUrl,reportType from (
SELECT
crg.report_id as reportId,
crg.group_id as groupId,
cg.id as groupId,
cg.name as groupName,
crg.report_type as reportType,
crg.report_id as reportId,
cr.name as reportName,
cr.preview_url as previewUrl
FROM
customer_report_group crg
join customer_report cr on crg.report_id = cr.id
join customer_group cg on crg.group_id = cg.id
customer_group cg
join customer_report_group crg on crg.group_id = cg.id
join customer_report cr on crg.report_id = cr.id and crg.report_type = cr.report_type
<where>
<if test="userId != null and userId != ''">
......@@ -54,20 +58,24 @@
<!-- 积木报表关联 -->
union
SELECT
crg.report_id as reportId,
crg.group_id as groupId,
cg.id as groupId,
cg.name as groupName,
crg.report_type as reportType,
jr.id as reportId,
jr.name as reportName,
jrs.preview_url as previewUrl
FROM
customer_report_group crg
customer_group cg
join customer_report_group crg on crg.group_id = cg.id and crg.report_type = 1
join jimu_report jr on crg.report_id = jr.id
join customer_group cg on crg.group_id = cg.id
join jimu_report_share jrs on jr.id = jrs.report_id
<where>
<if test="userId!= null and userId!= ''">
AND crg.create_by = #{userId}
</if>
</where>
) tmp
</select>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论