feat(quotation): 添加直销系数配置功能并优化权限列映射查询
- 新增直销系数配置控制器RatioDirectController及相应实体类 - 添加报价直销系数及相关子项的数据模型和数据库映射 - 实现直销系数动态表头获取功能 - 优化权限角色列映射查询SQL,增加表名关联查询 - 修复权限列映射服务中的数据转换逻辑 - 更新代码生成器测试配置,修正生成表名 - 添加lombok链式调用支持到权限角色列映射DTO
This commit is contained in:
parent
cc64cc5a47
commit
1a0cc2ff19
|
|
@ -1,8 +1,10 @@
|
|||
package com.nflg.mobilebroken.common.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PermissionRoleColumnMapDTO {
|
||||
|
||||
private Long id;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
package com.nflg.mobilebroken.common.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class RatioDirectEffectiveDTO {
|
||||
|
||||
/**
|
||||
* 机型id
|
||||
*/
|
||||
private Integer modelId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer userId;
|
||||
|
||||
/**
|
||||
* 标配系数
|
||||
*/
|
||||
private BigDecimal standardRatio;
|
||||
|
||||
/**
|
||||
* 选配系数
|
||||
*/
|
||||
private BigDecimal optionalRatio;
|
||||
|
||||
/**
|
||||
* 上级用户id
|
||||
*/
|
||||
private Integer parentUserId;
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ import java.util.*;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 代理商配置系数
|
||||
* 代理商系数配置
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ratio/agent")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,119 @@
|
|||
package com.nflg.mobilebroken.quotation.controller.admin;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.nflg.mobilebroken.common.constant.Constant;
|
||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||
import com.nflg.mobilebroken.common.pojo.dto.RatioDirectEffectiveDTO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.DynamicHeaderVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ModelPriceVO;
|
||||
import com.nflg.mobilebroken.quotation.controller.ControllerBase;
|
||||
import com.nflg.mobilebroken.repository.entity.AdminUser;
|
||||
import com.nflg.mobilebroken.repository.entity.DictionaryItem;
|
||||
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||
import com.nflg.mobilebroken.repository.service.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 直销系数配置
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ratio/direct")
|
||||
public class RatioDirectController extends ControllerBase {
|
||||
|
||||
@Resource
|
||||
private IDictionaryItemService dictionaryItemService;
|
||||
|
||||
@Resource
|
||||
private IQuotationModelPriceService priceService;
|
||||
|
||||
@Resource
|
||||
private IAdminUserService adminUserService;
|
||||
|
||||
@Resource
|
||||
private ITBaseDepartmentService departmentService;
|
||||
|
||||
@Resource
|
||||
private IQuotationModelRatioDirectService ratioDirectService;
|
||||
|
||||
/**
|
||||
* 获取动态表头
|
||||
* @param userIds 用户id列表
|
||||
*/
|
||||
@GetMapping("/header")
|
||||
public ApiResult<List<DynamicHeaderVO>> getHeaders(@RequestBody @NotEmpty List<Integer> userIds) {
|
||||
List<AdminUser> users = adminUserService.lambdaQuery().in(AdminUser::getId, userIds).list();
|
||||
if (CollectionUtil.isEmpty(users)) {
|
||||
return ApiResult.success(Collections.emptyList());
|
||||
}
|
||||
List<DictionaryItem> categories = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DIRECT_SALES_CATEGORY);
|
||||
List<TBaseDepartment> departments = departmentService.list();
|
||||
List<RatioDirectEffectiveDTO> ratioDirects=ratioDirectService.getEffectives();
|
||||
List<ModelPriceVO> prices = priceService.getAllModelPrice();
|
||||
return ApiResult.success(users.stream()
|
||||
.map(user -> new DynamicHeaderVO()
|
||||
.setProp(user.getId().toString())
|
||||
.setLabel(user.getUserName() + getDepartmentName(
|
||||
departments.stream()
|
||||
.filter(d -> d.getId().equals(user.getDepartmentId()))
|
||||
.findFirst()
|
||||
.orElse(null)
|
||||
)
|
||||
)
|
||||
.setChildren(
|
||||
new ArrayList<>() {
|
||||
{
|
||||
add(new DynamicHeaderVO()
|
||||
.setProp(user.getId() + "standardPrice")
|
||||
.setLabel("标配价" + getCategoryName(
|
||||
categories.stream()
|
||||
.filter(c -> c.getId().equals(user.getCategoryId()))
|
||||
.findFirst()
|
||||
.orElse(null)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
private BigDecimal getUserStandardPrice(Integer userId,List<RatioDirectEffectiveDTO> ratioDirects,List<ModelPriceVO> prices){
|
||||
RatioDirectEffectiveDTO ratioDirect = ratioDirects.stream()
|
||||
.filter(r -> r.getUserId().equals(userId))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (Objects.isNull(ratioDirect)){
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
private String getDepartmentName(TBaseDepartment department) {
|
||||
if (department == null) {
|
||||
return "";
|
||||
}
|
||||
return "(" + department.getDeptName() + ")";
|
||||
}
|
||||
|
||||
private String getCategoryName(DictionaryItem category) {
|
||||
if (category == null) {
|
||||
return "";
|
||||
}
|
||||
return "(" + category.getName() + ")";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package com.nflg.mobilebroken.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 报价-直销系数
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("quotation_model_ratio_direct")
|
||||
public class QuotationModelRatioDirect implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 年份
|
||||
*/
|
||||
private String year;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 状态,0:草稿;1:已发布;2:已废弃
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 新增人id
|
||||
*/
|
||||
private Integer createById;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package com.nflg.mobilebroken.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 报价-直销系数-子项
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("quotation_model_ratio_direct_item")
|
||||
public class QuotationModelRatioDirectItem implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 系数id
|
||||
*/
|
||||
private Long ratioId;
|
||||
|
||||
/**
|
||||
* 机型id
|
||||
*/
|
||||
private Integer modelId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer userId;
|
||||
|
||||
/**
|
||||
* 标配系数
|
||||
*/
|
||||
private BigDecimal standardRatio;
|
||||
|
||||
/**
|
||||
* 选配系数
|
||||
*/
|
||||
private BigDecimal optionalRatio;
|
||||
|
||||
/**
|
||||
* 是否有效
|
||||
*/
|
||||
private Boolean enable;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.nflg.mobilebroken.repository.mapper;
|
||||
|
||||
import com.nflg.mobilebroken.repository.entity.QuotationModelRatioDirectItem;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 报价-直销系数-子项 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
public interface QuotationModelRatioDirectItemMapper extends BaseMapper<QuotationModelRatioDirectItem> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.nflg.mobilebroken.repository.mapper;
|
||||
|
||||
import com.nflg.mobilebroken.common.pojo.dto.RatioDirectEffectiveDTO;
|
||||
import com.nflg.mobilebroken.repository.entity.QuotationModelRatioDirect;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 报价-直销系数 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
public interface QuotationModelRatioDirectMapper extends BaseMapper<QuotationModelRatioDirect> {
|
||||
|
||||
List<RatioDirectEffectiveDTO> getEffectives();
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.nflg.mobilebroken.repository.service;
|
||||
|
||||
import com.nflg.mobilebroken.repository.entity.QuotationModelRatioDirectItem;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 报价-直销系数-子项 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
public interface IQuotationModelRatioDirectItemService extends IService<QuotationModelRatioDirectItem> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.nflg.mobilebroken.repository.service;
|
||||
|
||||
import com.nflg.mobilebroken.common.pojo.dto.RatioDirectEffectiveDTO;
|
||||
import com.nflg.mobilebroken.repository.entity.QuotationModelRatioDirect;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 报价-直销系数 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
public interface IQuotationModelRatioDirectService extends IService<QuotationModelRatioDirect> {
|
||||
|
||||
List<RatioDirectEffectiveDTO> getEffectives();
|
||||
}
|
||||
|
|
@ -7,11 +7,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.nflg.mobilebroken.common.pojo.dto.PermissionRoleColumnMapDTO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.PermissionRoleColumnMapItemVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.PermissionRoleColumnMapVO;
|
||||
import com.nflg.mobilebroken.repository.entity.AdminPermissionColumn;
|
||||
import com.nflg.mobilebroken.repository.entity.AdminPermissionRoleColumnMap;
|
||||
import com.nflg.mobilebroken.repository.mapper.AdminPermissionRoleColumnMapMapper;
|
||||
import com.nflg.mobilebroken.repository.service.IAdminPermissionColumnService;
|
||||
import com.nflg.mobilebroken.repository.service.IAdminPermissionRoleColumnMapService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
|
@ -27,6 +31,9 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
public class AdminPermissionRoleColumnMapServiceImpl extends ServiceImpl<AdminPermissionRoleColumnMapMapper, AdminPermissionRoleColumnMap> implements IAdminPermissionRoleColumnMapService {
|
||||
|
||||
@Resource
|
||||
private IAdminPermissionColumnService permissionColumnService;
|
||||
|
||||
@Override
|
||||
public List<PermissionRoleColumnMapVO> getList(Long id) {
|
||||
List<PermissionRoleColumnMapDTO> all = baseMapper.getColumns();
|
||||
|
|
@ -34,6 +41,27 @@ public class AdminPermissionRoleColumnMapServiceImpl extends ServiceImpl<AdminPe
|
|||
if (CollectionUtil.isEmpty(datas)) {
|
||||
return convert(all);
|
||||
}
|
||||
List<AdminPermissionColumn> columns = permissionColumnService.list();
|
||||
// List<PermissionRoleColumnMapDTO> tmps = new ArrayList<>();
|
||||
// datas.forEach(data -> {
|
||||
// List<String> cols = StrUtil.split(data.getColName(), ",");
|
||||
// cols.forEach(col -> {
|
||||
// tmps.add(
|
||||
// new PermissionRoleColumnMapDTO()
|
||||
// .setId(data.getId())
|
||||
// .setTableId(data.getTableId())
|
||||
// .setTableName(data.getTableName())
|
||||
// .setColName(col)
|
||||
// .setColDesc(
|
||||
// columns.stream()
|
||||
// .filter(c -> Objects.equals(c.getTableId(), data.getTableId()) && Objects.equals(c.getColName(), col))
|
||||
// .findFirst()
|
||||
// .map(AdminPermissionColumn::getColDesc)
|
||||
// .orElse("")
|
||||
// )
|
||||
// );
|
||||
// });
|
||||
// });
|
||||
datas.forEach(data -> {
|
||||
List<PermissionRoleColumnMapDTO> vos = all.stream()
|
||||
.filter(d -> Objects.equals(d.getTableId(), data.getTableId()))
|
||||
|
|
@ -48,7 +76,7 @@ public class AdminPermissionRoleColumnMapServiceImpl extends ServiceImpl<AdminPe
|
|||
});
|
||||
}
|
||||
});
|
||||
return convert(datas);
|
||||
return convert(all);
|
||||
}
|
||||
|
||||
private List<PermissionRoleColumnMapVO> convert(List<PermissionRoleColumnMapDTO> datas) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.nflg.mobilebroken.repository.service.impl;
|
||||
|
||||
import com.nflg.mobilebroken.repository.entity.QuotationModelRatioDirectItem;
|
||||
import com.nflg.mobilebroken.repository.mapper.QuotationModelRatioDirectItemMapper;
|
||||
import com.nflg.mobilebroken.repository.service.IQuotationModelRatioDirectItemService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 报价-直销系数-子项 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
@Service
|
||||
public class QuotationModelRatioDirectItemServiceImpl extends ServiceImpl<QuotationModelRatioDirectItemMapper, QuotationModelRatioDirectItem> implements IQuotationModelRatioDirectItemService {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.nflg.mobilebroken.repository.service.impl;
|
||||
|
||||
import com.nflg.mobilebroken.common.pojo.dto.RatioDirectEffectiveDTO;
|
||||
import com.nflg.mobilebroken.repository.entity.QuotationModelRatioDirect;
|
||||
import com.nflg.mobilebroken.repository.mapper.QuotationModelRatioDirectMapper;
|
||||
import com.nflg.mobilebroken.repository.service.IQuotationModelRatioDirectService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 报价-直销系数 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2026
|
||||
*/
|
||||
@Service
|
||||
public class QuotationModelRatioDirectServiceImpl extends ServiceImpl<QuotationModelRatioDirectMapper, QuotationModelRatioDirect> implements IQuotationModelRatioDirectService {
|
||||
|
||||
@Override
|
||||
public List<RatioDirectEffectiveDTO> getEffectives() {
|
||||
return baseMapper.getEffectives();
|
||||
}
|
||||
}
|
||||
|
|
@ -3,13 +3,15 @@
|
|||
<mapper namespace="com.nflg.mobilebroken.repository.mapper.AdminPermissionRoleColumnMapMapper">
|
||||
|
||||
<select id="getList" resultType="com.nflg.mobilebroken.common.pojo.dto.PermissionRoleColumnMapDTO">
|
||||
SELECT *
|
||||
FROM admin_permission_role_column_map
|
||||
where role_id = #{id}
|
||||
SELECT aprcm.id,aprcm.col_name,aprcm.table_id,apt.table_desc as 'table_name'
|
||||
FROM admin_permission_role_column_map aprcm
|
||||
left join admin_permission_table apt on aprcm.table_id=apt.id
|
||||
where aprcm.role_id = #{id}
|
||||
</select>
|
||||
<select id="getColumns" resultType="com.nflg.mobilebroken.common.pojo.dto.PermissionRoleColumnMapDTO">
|
||||
SELECT c.table_id, t.table_desc as 'table_name', c.col_name, c.col_desc
|
||||
FROM admin_permission_table t
|
||||
INNER JOIN admin_permission_column c ON t.id = c.table_id
|
||||
INNER JOIN admin_permission_column c ON t.id = c.table_id
|
||||
order by c.id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nflg.mobilebroken.repository.mapper.QuotationModelRatioDirectItemMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nflg.mobilebroken.repository.mapper.QuotationModelRatioDirectMapper">
|
||||
|
||||
<select id="getEffectives" resultType="com.nflg.mobilebroken.common.pojo.dto.RatioDirectEffectiveDTO">
|
||||
SELECT qmrdi.model_id,qmrdi.user_id,qmrdi.standard_ratio,qmrdi.optional_ratio,qmrd.create_by_id as 'parentUserId'
|
||||
FROM quotation_model_ratio_direct qmrd
|
||||
INNER JOIN quotation_model_ratio_direct_item qmrdi ON qmrdi.ratio_id=qmrd.id
|
||||
WHERE qmrd.status=1
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -33,7 +33,7 @@ public class CodeGeneratorTest {
|
|||
, Paths.get(System.getProperty("user.dir")) + "/src/main/resources/mapper"))
|
||||
)
|
||||
.strategyConfig(builder -> {
|
||||
builder.addInclude("quotation_model_ratio_agent_item") //只生成指定表
|
||||
builder.addInclude("quotation_model_ratio_direct_item") //只生成指定表
|
||||
.entityBuilder()
|
||||
.enableLombok()
|
||||
.enableChainModel()
|
||||
|
|
|
|||
Loading…
Reference in New Issue