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

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

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