提交 751376de authored 作者: 吕本才's avatar 吕本才

1、增加分组保存、删除接口,2、优化之前的接口 3、

上级 db376f16
......@@ -74,7 +74,11 @@
<groupId>com.wangxiaolu.sfa</groupId>
<artifactId>wangxiaolu-sfa-common-log</artifactId>
</dependency>
<!-- RuoYi Api System -->
<dependency>
<groupId>com.wangxiaolu.sfa</groupId>
<artifactId>wangxiaolu-sfa-api-system</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
......
package com.link.report.controller.core;
import com.link.report.pojo.request.CustomerReportAddVo;
import com.link.report.service.CustomerGroupService;
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.*;
/**
* @author : liqiulin
* @date : 2024-12-04 15
* @describe : 自定义报表管理
*/
@RestController
@RequestMapping("/customer/core")
public class CustomerGroupCoreController {
@Autowired
CustomerGroupService groupService;
@RequiresPermissions("bi:supply:list")
@PostMapping("/group/insertOrUpdate")
public R save(@RequestBody CustomerReportAddVo customerReportAddVo) {
groupService.save(customerReportAddVo);
return R.ok();
}
@RequiresPermissions("bi:supply:list")
@DeleteMapping("/group/delete")
public R delete(CustomerReportAddVo customerReportAddVo) {
groupService.delete(customerReportAddVo);
return R.ok();
}
@RequiresPermissions("bi:supply:list")
@GetMapping("/group/convert")
public R convert() {
groupService.convert();
return R.ok();
}
}
package com.link.report.controller.query;
import com.link.report.pojo.request.ReportShareListVo;
import com.link.report.pojo.response.CustomerReportListDto;
import com.link.report.service.CustomerReportService;
import com.sfa.common.core.domain.R;
......@@ -25,8 +26,8 @@ public class CustomerReportQueryController {
@RequiresPermissions("bi:supply:list")
@GetMapping("/list")
public R<List<CustomerReportListDto>> queryList() {
List<CustomerReportListDto> customerReportListDtos = customerReportService.queryCustomerReportList();
public R<List<CustomerReportListDto>> queryList(ReportShareListVo reportShareListVo) {
List<CustomerReportListDto> customerReportListDtos = customerReportService.queryCustomerReportList(reportShareListVo);
return R.ok(customerReportListDtos);
}
}
package com.link.report.domain.dao;
import com.link.report.domain.wq.CustomerGroupQueryWq;
import com.link.report.pojo.request.CustomerReportAddVo;
import com.link.report.pojo.response.CustomerGroupDto;
import java.util.List;
public interface CustomerGroupDao {
List<CustomerGroupDto> queryList(CustomerGroupQueryWq wq);
void insert(CustomerReportAddVo customerReportAddVo);
void update(CustomerReportAddVo customerReportAddVo);
void delete(String groupId);
}
......@@ -2,15 +2,18 @@ package com.link.report.domain.dao;
import com.link.report.domain.entity.CustomerReportGroup;
import com.link.report.pojo.response.CustomerReportGroupQueryListDto;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface CustomerReportGroupDao {
List<CustomerReportGroup> list();
List<CustomerReportGroupQueryListDto> queryList();
void deleteByCreatorId(Long userId);
void batchInsert(List<CustomerReportGroup> items);
void update(CustomerReportGroup customerReportGroup);
}
......@@ -7,7 +7,9 @@ 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.request.CustomerReportAddVo;
import com.link.report.pojo.response.CustomerGroupDto;
import com.sfa.common.core.utils.bean.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -27,7 +29,9 @@ public class CustomerGroupDaoImpl implements CustomerGroupDao {
public List<CustomerGroupDto> queryList(CustomerGroupQueryWq wq) {
Wrapper<CustomerGroup> wraper = new LambdaQueryWrapper<CustomerGroup>()
.eq(ObjectUtil.isNotEmpty(wq.getCategoryName()), CustomerGroup::getCategoryName, wq.getCategoryName());
.eq(ObjectUtil.isNotEmpty(wq.getCreateUserId()), CustomerGroup::getCreateUserId, wq.getCreateUserId())
.eq(ObjectUtil.isNotEmpty(wq.getCategoryName()), CustomerGroup::getCategoryName, wq.getCategoryName())
.in(ObjectUtil.isNotEmpty(wq.getGroupIds()), CustomerGroup::getId, wq.getGroupIds());
List<CustomerGroup> customerGroups = groupMapper.selectList(wraper);
List<CustomerGroupDto> result = new ArrayList<>();
for (CustomerGroup customerGroup : customerGroups) {
......@@ -39,4 +43,27 @@ public class CustomerGroupDaoImpl implements CustomerGroupDao {
}
return result;
}
@Override
public void insert(CustomerReportAddVo customerReportAddVo) {
CustomerGroup customerGroup = BeanUtils.transitionDto(customerReportAddVo, CustomerGroup.class);
customerGroup.setName(customerReportAddVo.getGroupName());
customerGroup.setCategoryName(customerReportAddVo.getCategoryName());
groupMapper.insert(customerGroup);
}
@Override
public void update(CustomerReportAddVo customerReportAddVo) {
CustomerGroup customerGroup = BeanUtils.transitionDto(customerReportAddVo, CustomerGroup.class);
customerGroup.setId(customerReportAddVo.getGroupId());
customerGroup.setName(customerReportAddVo.getGroupName());
customerGroup.setCategoryName(customerReportAddVo.getCategoryName());
groupMapper.updateById(customerGroup);
}
@Override
public void delete(String groupId) {
groupMapper.deleteById(groupId);
}
}
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.CustomerReportDao;
......@@ -26,7 +27,6 @@ public class CustomerReportDaoImpl implements CustomerReportDao {
@Override
public void insert(CustomerReportAddWq wq) {
CustomerReport entity = BeanUtils.transitionDto(wq, CustomerReport.class);
customerReportMapper.insert(entity);
}
......@@ -39,7 +39,8 @@ public class CustomerReportDaoImpl implements CustomerReportDao {
@Override
public List<CustomerReportListDto> queryCustomerReportList(CustomerReportQueryWq wq) {
Wrapper<CustomerReport> qw = new LambdaQueryWrapper<>();
Wrapper<CustomerReport> qw = new LambdaQueryWrapper<CustomerReport>()
.eq(ObjectUtil.isNotEmpty(wq.getCategoryName()),CustomerReport::getCategoryName, wq.getCategoryName());
// 按照条件查询
List<CustomerReport> customerReports = customerReportMapper.selectList(qw);
List<CustomerReportListDto> list = new ArrayList<>();
......
......@@ -18,24 +18,33 @@ import java.util.List;
public class CustomerReportGroupDaoImpl implements CustomerReportGroupDao {
@Autowired
private CustomerReportGroupMapper reportGroupMapper;
@Override
public List<CustomerReportGroupQueryListDto> queryList() {
public List<CustomerReportGroup> list() {
// 更加登录人id查询
Long userId = SecurityUtils.getLoginUser().getUserid();
List<CustomerReportGroupQueryListDto> list = reportGroupMapper.queryReportGroupList(String.valueOf(userId));
List<CustomerReportGroup> list = reportGroupMapper.selectList(new LambdaQueryWrapper<>());
return list;
}
@Override
public List<CustomerReportGroupQueryListDto> queryList() {
Long userId = SecurityUtils.getUserId();
// 更加登录人id查询
List<CustomerReportGroupQueryListDto> list = reportGroupMapper.queryReportGroupList(userId);
return list;
}
@Override
public void deleteByCreatorId(Long userId) {
reportGroupMapper.delete(new LambdaQueryWrapper<CustomerReportGroup>()
.eq(CustomerReportGroup::getCreateBy,userId));
.eq(CustomerReportGroup::getCreateUserId, userId));
}
@Override
public void batchInsert(List<CustomerReportGroup> items) {
reportGroupMapper.batchInsert(items);
}
@Override
public void update(CustomerReportGroup customerReportGroup) {
reportGroupMapper.updateById(customerReportGroup);
}
}
package com.link.report.domain.entity;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
......@@ -45,6 +46,7 @@ public class CustomerGroup {
/**
* 删除标识,0 表示正常,1 表示已删除
*/
@TableLogic
private Integer delFlag;
/**
* 多租户标识
......@@ -54,4 +56,6 @@ public class CustomerGroup {
* 乐观锁版本
*/
private Integer updateCount;
private Long createUserId;
private Long updateUserId;
}
......@@ -9,6 +9,8 @@ import java.util.Date;
public class CustomerReport {
private String id;
private String code;
private String categoryName;
private String name;
private String previewUrl;
private String remark;
......@@ -22,4 +24,6 @@ public class CustomerReport {
private Integer delFlag;
private String tenantId;
private Integer updateCount;
private Long createUserId;
private Long updateUserId;
}
......@@ -18,4 +18,6 @@ public class CustomerReportGroup {
private Integer delFlag;
private String tenantId;
private Integer updateCount;
private Long createUserId;
private Long updateUserId;
}
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.link.report.domain.entity.CustomerReportGroup;
import com.link.report.pojo.response.CustomerReportGroupQueryListDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -12,5 +13,5 @@ public interface CustomerReportGroupMapper extends BaseMapper<CustomerReportGrou
void batchInsert(List<CustomerReportGroup> items);
List<CustomerReportGroupQueryListDto> queryReportGroupList(String userId);
List<CustomerReportGroupQueryListDto> queryReportGroupList(@Param("userId") Long userId);
}
......@@ -2,8 +2,12 @@ package com.link.report.domain.wq;
import lombok.Data;
import java.util.List;
@Data
public class CustomerGroupQueryWq {
private String categoryName;
private List<String> groupIds;
private Long createUserId;
}
......@@ -7,4 +7,5 @@ public class CustomerReportQueryWq {
private String id;
private String name;
private String previewUrl;
private String categoryName;
}
package com.link.report.pojo.request;
import lombok.Data;
/**
* @author : lvbencai
* @date : 2025年03月19日12:09:19
* @describe : 自定义报表查询条件
*/
@Data
public class CustomerGroupAddVo {
private String id;
private String name;
}
......@@ -9,7 +9,12 @@ import lombok.Data;
*/
@Data
public class CustomerReportAddVo {
private String id;
private String name;
private String previewUrl;
private String groupId;
private String groupName;
private String categoryName;
private Long createUserId;
private Long updateUserId;
private String createBy;
private String updateBy;
}
......@@ -9,5 +9,5 @@ import lombok.Data;
*/
@Data
public class CustomerReportQueryListVo {
private String categoryName = "供应链报表";
private String categoryName ;
}
......@@ -7,5 +7,4 @@ public class CustomerGroupDto {
private String groupId;
private String groupName;
private String catalogName;
}
package com.link.report.service;
import com.link.report.pojo.request.CustomerReportAddVo;
public interface CustomerGroupService {
void save(CustomerReportAddVo customerReportAddVo);
void delete(CustomerReportAddVo customerReportAddVo);
void convert();
}
package com.link.report.service;
import com.link.report.pojo.request.CustomerReportAddVo;
import com.link.report.pojo.request.ReportShareListVo;
import com.link.report.pojo.response.CustomerReportListDto;
import java.util.List;
......@@ -8,6 +9,5 @@ import java.util.List;
public interface CustomerReportService {
void save(CustomerReportAddVo customerReportAddVo);
List<CustomerReportListDto> queryCustomerReportList();
List<CustomerReportListDto> queryCustomerReportList(ReportShareListVo reportShareListVo);
}
package com.link.report.service.impl;
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.CustomerReportAddVo;
import com.link.report.pojo.response.CustomerGroupDto;
import com.link.report.service.CustomerGroupService;
import com.sfa.common.core.constant.SecurityConstants;
import com.sfa.common.core.domain.R;
import com.sfa.common.security.utils.SecurityUtils;
import com.sfa.system.api.RemoteUserService;
import com.sfa.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 报表分享数据
*/
@Service
public class CustomerGroupServiceImpl implements CustomerGroupService {
@Autowired
private CustomerGroupDao groupDao;
@Autowired
private CustomerReportGroupDao reportGroupDao;
@Autowired
private RemoteUserService remoteUserService;
@Override
public void save(CustomerReportAddVo customerReportAddVo) {
Long userId = SecurityUtils.getUserId();
String userName = SecurityUtils.getUsername();
customerReportAddVo.setCreateBy(userName);
customerReportAddVo.setCreateUserId(userId);
customerReportAddVo.setUpdateBy(userName);
customerReportAddVo.setUpdateUserId(userId);
if (ObjectUtil.isNotEmpty(customerReportAddVo.getGroupId())) {
groupDao.update(customerReportAddVo);
} else {
groupDao.insert(customerReportAddVo);
}
}
@Override
public void delete(CustomerReportAddVo customerReportAddVo) {
groupDao.delete(customerReportAddVo.getGroupId());
}
@Override
public void convert() {
// 查询出当前有多少关联分组的
List<CustomerReportGroup> list = reportGroupDao.list();
List<String> groupIds = list.stream().map(CustomerReportGroup::getGroupId).collect(Collectors.toList());
// 根据groupIds
CustomerGroupQueryWq wq = new CustomerGroupQueryWq();
wq.setGroupIds(groupIds);
List<CustomerGroupDto> groupDtos = groupDao.queryList(wq);
// 转成map key 为groupid value 为CustomerGroupDto对象
Map<String, CustomerGroupDto> dtoMap = groupDtos.stream().collect(Collectors.toMap(CustomerGroupDto::getGroupId, item -> item));
// 创建 不同人的分组信息
for (int i = 0; i < list.size(); i++) {
//获取组id
CustomerReportGroup customerReportGroup = list.get(i);
String groupId = customerReportGroup.getGroupId();
// groupDtos中找到匹配的数据
CustomerGroupDto customerGroupDto = dtoMap.get(groupId);
if (ObjectUtil.isNotEmpty(customerGroupDto)) {
// 匹配到了
CustomerReportAddVo customerReportAddVo = new CustomerReportAddVo();
customerReportAddVo.setCategoryName(customerGroupDto.getCatalogName());
customerReportAddVo.setGroupName(customerGroupDto.getGroupName());
customerReportAddVo.setCreateBy(customerReportGroup.getCreateBy());
customerReportAddVo.setUpdateBy(customerReportGroup.getUpdateBy());
R<LoginUser> userResult =remoteUserService.getUserInfo(customerReportGroup.getCreateBy(), SecurityConstants.INNER) ;
Long userid = userResult.getData().getSysUser().getUserId();
customerReportAddVo.setCreateUserId(userid);
customerReportAddVo.setUpdateUserId(userid);
groupDao.insert(customerReportAddVo);
// 修改数据
customerReportGroup.setGroupId(customerReportAddVo.getGroupId());
// 更新 分组id
reportGroupDao.update(customerReportGroup);
}
}
}
}
......@@ -36,7 +36,8 @@ public class CustomerReportGroupServiceImpl implements CustomerReportGroupServic
@Override
public List<CustomerReportGroupResDto> queryList(CustomerReportQueryListVo vo) {
CustomerGroupQueryWq wq = new CustomerGroupQueryWq();
wq.setCategoryName(vo.getCategoryName());
// wq.setCategoryName(vo.getCategoryName());
wq.setCreateUserId(SecurityUtils.getLoginUser().getUserid());
// 先查询分组
List<CustomerGroupDto> groupDtos = customerGroupDao.queryList(wq);
List<CustomerReportGroupQueryListDto> list = customerReportGroupDao.queryList();
......@@ -63,8 +64,6 @@ public class CustomerReportGroupServiceImpl implements CustomerReportGroupServic
resDto.setItems(itemsDtos);
result.add(resDto);
}
return result;
}
......@@ -77,7 +76,6 @@ public class CustomerReportGroupServiceImpl implements CustomerReportGroupServic
@Override
public void save(List<CustomerReportGroupVo> customerReportGroupVo) {
// 新增或者修改 先删除后新增
Long userId = SecurityUtils.getLoginUser().getUserid();
customerReportGroupDao.deleteByCreatorId(userId);
......@@ -92,7 +90,10 @@ public class CustomerReportGroupServiceImpl implements CustomerReportGroupServic
dto.setGroupId(vo.getGroupId());
dto.setReportId(item.getReportId());
dto.setReportType(item.getReportType());
dto.setCreateBy(String.valueOf(userId));
dto.setCreateBy(SecurityUtils.getUsername());
dto.setCreateUserId(userId);
dto.setUpdateBy(SecurityUtils.getUsername());
dto.setUpdateUserId(userId);
dto.setTenantId(String.valueOf(userId));
items.add(dto);
}
......
......@@ -5,6 +5,7 @@ import com.link.report.domain.dao.CustomerReportDao;
import com.link.report.domain.wq.CustomerReportAddWq;
import com.link.report.domain.wq.CustomerReportQueryWq;
import com.link.report.pojo.request.CustomerReportAddVo;
import com.link.report.pojo.request.ReportShareListVo;
import com.link.report.pojo.response.CustomerReportListDto;
import com.link.report.service.CustomerReportService;
import com.sfa.common.core.utils.bean.BeanUtils;
......@@ -34,8 +35,9 @@ public class CustomerReportServiceImpl implements CustomerReportService {
}
@Override
public List<CustomerReportListDto> queryCustomerReportList( ) {
public List<CustomerReportListDto> queryCustomerReportList(ReportShareListVo reportShareListVo) {
CustomerReportQueryWq wq = new CustomerReportQueryWq();
wq.setCategoryName(reportShareListVo.getCategoryName());
List<CustomerReportListDto> list = customerReportDao.queryCustomerReportList(wq);
return list;
}
......
......@@ -34,7 +34,7 @@ public class JimuReportTokenServiceImpl implements JmReportTokenServiceI {
*/
@Override
public String getToken(HttpServletRequest request) {
String token = "";
String token = "";
if (request != null) {
token = request.getParameter("token");
if (ObjectUtil.isEmpty(token)) {
......@@ -66,10 +66,10 @@ public class JimuReportTokenServiceImpl implements JmReportTokenServiceI {
LoginUser loginUser = tokenService.getLoginUser(s);
Set<String> roles = loginUser.getRoles();
// it可以设计任何报表
if (!ObjectUtil.isAllNotEmpty( loginUser.getSysUser(),loginUser.getSysUser().getDept()
,loginUser.getSysUser().getDept().getDeptName()) &&
if (!ObjectUtil.isAllNotEmpty(loginUser.getSysUser(), loginUser.getSysUser().getDept()
, loginUser.getSysUser().getDept().getDeptName()) &&
// 信息中心可以编辑所有报表
loginUser.getSysUser().getDept().getDeptName().contains("信息技术中心")) {
loginUser.getSysUser().getDept().getDeptName().contains("信息技术中心")) {
roles.add("admin");
}
return roles.toArray(new String[0]);
......@@ -88,7 +88,6 @@ public class JimuReportTokenServiceImpl implements JmReportTokenServiceI {
}
/**
* 自定义请求头
*/
......@@ -117,16 +116,9 @@ public class JimuReportTokenServiceImpl implements JmReportTokenServiceI {
//都不具备则不能访问
return "NO";
}
//具备admin或者管理员权限才可访问所有报表
// if (SecurityUtils.isAdmin(loginUser.getUserid())
// || loginUser.getRoles().contains("it")
// // 信息中心可以编辑所有报表
// || loginUser.getSysUser().getDept().getDeptName().contains("信息技术中心")) {
// return "1";
// }
Long deptId = loginUser.getSysUser().getDept().getDeptId();
return String.valueOf(deptId);
}
}
@Override
public Map<String, Object> getUserInfo(String token) {
......@@ -154,12 +146,12 @@ public class JimuReportTokenServiceImpl implements JmReportTokenServiceI {
return new String[0];
}
Set<String> permissions = loginUser.getPermissions();
if(ObjectUtil.isNotEmpty(permissions)){
permissions.add("drag:datasource:testConnection");
if (ObjectUtil.isNotEmpty(permissions)) {
permissions.add("drag:datasource:testConnection");
permissions.add("onl:drag:clear:recoverry");
permissions.add("drag:analysis:sql");
permissions.add("drag:design:getTotalData");
return permissions .toArray(new String[0]);
return permissions.toArray(new String[0]);
}
return new String[0];
......
......@@ -10,8 +10,10 @@
report_type,
group_id,
create_by,
create_user_id,
create_time,
update_by,
update_user_id,
update_time,
del_flag,
tenant_id,
......@@ -24,8 +26,10 @@
#{item.reportType},
#{item.groupId},
#{item.createBy},
#{item.createUserId},
#{item.createTime},
#{item.updateBy},
#{item.updateUserId},
#{item.updateTime},
#{item.delFlag},
#{item.tenantId},
......@@ -51,8 +55,9 @@
join customer_report cr on crg.report_id = cr.id and crg.report_type = cr.report_type
<where>
cg.del_flag = 0
<if test="userId != null and userId != ''">
AND crg.create_by = #{userId}
AND cg.create_user_id = #{userId}
</if>
</where>
<!-- 积木报表关联 -->
......@@ -73,7 +78,7 @@
join jimu_report_share jrs on jr.id = jrs.report_id
<where>
<if test="userId!= null and userId!= ''">
AND crg.create_by = #{userId}
AND crg.create_user_id = #{userId}
</if>
</where>
) tmp
......
......@@ -19,12 +19,6 @@
<select id="selectShareList" resultType="com.link.report.pojo.response.ReportShareBiListDto">
select jrs.id,jrs.report_id as reportId ,
jrs.preview_url as previewUrl,
<!-- jrs.preview_lock as previewLock,
jrs.last_update_time as lastUpdateTime,
jrs.term_of_validity as termOfValidity,
jrs.status as status,
jrs.preview_lock_status as previewLockStatus,
jrs.share_token as shareToken,-->
jr.name as reportName,
1 as reportType
from jimu_report_share jrs
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论