Commit 29df78b7 by 杨卫

feat:1047852:d+后台事项新增,我的事项列表

1 parent 2df60bb3
package cn.com.glsx.dj.peanalysis.dto.analysis;
import cn.com.glsx.dj.peanalysis.validator.InList;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.List;
/**
* 事项新增
* @author yangwei
* @version 1.0
* @since 2025/12/17 20:47
*/
@Data
public class MerchantBiMatterAddDTO implements Serializable {
private static final long serialVersionUID = -2215128813775122151L;
/** 门店编号 */
@NotBlank(message = "门店编号不能为空")
private String storeNo;
/** 门店名称 */
@NotBlank(message = "门店名称不能为空")
private String storeName;
/** bi侧业务类型,1.延保 2.轻改 3.权益 4.二手车 */
@NotBlank(message = "业务类型不能为空")
@InList(values = {"1", "2", "3", "4"}, message = "业务类型错误")
private String businessType;
/** 创建人 */
@NotBlank(message = "创建人不能为空")
private String creator;
/** 创建人唯一标识,小程序登录人uuid */
@NotBlank(message = "创建人唯一标识不能为空")
private String creatorUnique;
/** 事项描述 */
@NotBlank(message = "事项描述不能为空")
@Size(max = 200, message = "事项描述长度不能超过{max}")
private String description;
/** 线上运营 */
@Valid
@NotEmpty(message = "线上运营不能为空")
private List<MerchantBiMatterDTO.@Valid OperatorDTO> onlineOperator;
/** 区域运营 */
@Valid
@NotEmpty(message = "区域运营不能为空")
private List<MerchantBiMatterDTO.@Valid OperatorDTO> areaOperator;
}
...@@ -3,6 +3,7 @@ package cn.com.glsx.dj.peanalysis.dto.analysis; ...@@ -3,6 +3,7 @@ package cn.com.glsx.dj.peanalysis.dto.analysis;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -72,11 +73,13 @@ public class MerchantBiMatterDTO implements Serializable { ...@@ -72,11 +73,13 @@ public class MerchantBiMatterDTO implements Serializable {
/** /**
* 员工uuid * 员工uuid
*/ */
@NotBlank(message = "员工uuid不能为空")
private String uuid; private String uuid;
/** /**
* 运营人员名称 * 运营人员名称
*/ */
@NotBlank(message = "运营人员名称不能为空")
private String username; private String username;
} }
} }
...@@ -17,7 +17,7 @@ public class MerchantBiMatterSingleIdDTO implements Serializable { ...@@ -17,7 +17,7 @@ public class MerchantBiMatterSingleIdDTO implements Serializable {
private static final long serialVersionUID = 6250618373748657760L; private static final long serialVersionUID = 6250618373748657760L;
/** /**
* 主键id * 事项主键id
*/ */
@NotNull(message = "id不能为空") @NotNull(message = "id不能为空")
private Long id; private Long id;
......
package cn.com.glsx.dj.peanalysis.dto.analysis;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* BI-我的事项响应对象
* @author yangwei
* @version 1.0
* @since 2025/12/12 14:54
*/
@Data
public class MyMerchantBiMatterDTO implements Serializable {
private static final long serialVersionUID = 3348346879157326029L;
/** 主键id */
private Long id;
/** 门店编号 */
private String storeNo;
/** bi侧业务类型,1.延保 2.轻改 3.权益 4.二手车 */
private String businessType;
/** 门店名称 */
private String storeName;
/** 创建人 */
private String creator;
/** 创建时间 */
private Date createdAt;
/** 1.代处理 2.已处理 */
private Integer status;
/** 事项描述 */
private String description;
/** 线上运营 */
private List<MerchantBiMatterDTO.OperatorDTO> onlineOperator;
/** 区域运营 */
private List<MerchantBiMatterDTO.OperatorDTO> areaOperator;
}
package cn.com.glsx.dj.peanalysis.dto.analysis;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 我的事项管理查询请求对象
* @author yangwei
* @version 1.0
* @since 2025/12/17 22:02
*/
@Data
public class MyMerchantBiMatterQryDTO implements Serializable {
private static final long serialVersionUID = -2131438956530507394L;
/**
* 门店名称,模糊搜索
*/
private String storeName;
/**
* 事项状态
* @see cn.com.glsx.dj.peanalysis.enums.MerchantBiMatterStatusEnum
*/
private Integer status;
/**
* 操作人
*/
@NotBlank(message = "操作人不能为空")
private String operator;
}
...@@ -19,4 +19,13 @@ public enum MerchantBiMatterStatusEnum { ...@@ -19,4 +19,13 @@ public enum MerchantBiMatterStatusEnum {
private final Integer code; private final Integer code;
private final String desc; private final String desc;
public static String getDescByCode(Integer code) {
for (MerchantBiMatterStatusEnum value : MerchantBiMatterStatusEnum.values()) {
if (value.getCode().equals(code)) {
return value.getDesc();
}
}
return null;
}
} }
...@@ -27,7 +27,7 @@ public interface BiAnalyseBackgroundRemote { ...@@ -27,7 +27,7 @@ public interface BiAnalyseBackgroundRemote {
@ApiMethod("BI-门店毛利额详情") @ApiMethod("BI-门店毛利额详情")
@ApiParam(name = "merchantProfitRecordSingleIdDTO", notes = "查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "merchantProfitRecordSingleIdDTO", notes = "查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("门店毛利额列表") @ApiResponse("门店毛利额详情")
RpcResponse<MerchantProfitRecordDetailDTO> merchantProfitRecordDetail(MerchantProfitRecordSingleIdDTO merchantProfitRecordSingleIdDTO); RpcResponse<MerchantProfitRecordDetailDTO> merchantProfitRecordDetail(MerchantProfitRecordSingleIdDTO merchantProfitRecordSingleIdDTO);
@ApiMethod("BI-门店毛利额新增") @ApiMethod("BI-门店毛利额新增")
......
...@@ -2,6 +2,8 @@ package cn.com.glsx.dj.peanalysis.mapper; ...@@ -2,6 +2,8 @@ package cn.com.glsx.dj.peanalysis.mapper;
import cn.com.glsx.dj.peanalysis.dto.analysis.MerchantBiMatterBaseQryDTO; import cn.com.glsx.dj.peanalysis.dto.analysis.MerchantBiMatterBaseQryDTO;
import cn.com.glsx.dj.peanalysis.dto.analysis.MerchantBiMatterDTO; import cn.com.glsx.dj.peanalysis.dto.analysis.MerchantBiMatterDTO;
import cn.com.glsx.dj.peanalysis.dto.analysis.MyMerchantBiMatterDTO;
import cn.com.glsx.dj.peanalysis.dto.analysis.MyMerchantBiMatterQryDTO;
import cn.com.glsx.dj.peanalysis.dto.req.MerchantBiMatterSearchReq; import cn.com.glsx.dj.peanalysis.dto.req.MerchantBiMatterSearchReq;
import cn.com.glsx.dj.peanalysis.model.MerchantBiMatter; import cn.com.glsx.dj.peanalysis.model.MerchantBiMatter;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
...@@ -20,4 +22,6 @@ public interface MerchantBiMatterMapper extends OreMapper<MerchantBiMatter> { ...@@ -20,4 +22,6 @@ public interface MerchantBiMatterMapper extends OreMapper<MerchantBiMatter> {
List<MerchantBiMatter> findMerchantBiMatter(@Param("condition") MerchantBiMatterSearchReq req); List<MerchantBiMatter> findMerchantBiMatter(@Param("condition") MerchantBiMatterSearchReq req);
List<MerchantBiMatterDTO> selectList(MerchantBiMatterBaseQryDTO condition); List<MerchantBiMatterDTO> selectList(MerchantBiMatterBaseQryDTO condition);
List<MyMerchantBiMatterDTO> selectMyBiMatterList(MyMerchantBiMatterQryDTO condition);
} }
\ No newline at end of file \ No newline at end of file
...@@ -39,6 +39,7 @@ import tk.mybatis.mapper.entity.Example; ...@@ -39,6 +39,7 @@ import tk.mybatis.mapper.entity.Example;
import javax.validation.groups.Default; import javax.validation.groups.Default;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* BI指标分析后台 * BI指标分析后台
...@@ -437,25 +438,7 @@ public class BiAnalyseBackgroundService { ...@@ -437,25 +438,7 @@ public class BiAnalyseBackgroundService {
} }
List<Long> merchantBiMatterIds = result.stream().map(MerchantBiMatterDTO::getId).collect(Collectors.toList()); List<Long> merchantBiMatterIds = result.stream().map(MerchantBiMatterDTO::getId).collect(Collectors.toList());
Example example = new Example(MerchantBiMatterOperator.class); Map<Long, Map<Byte, List<MerchantBiMatterDTO.OperatorDTO>>> biIdMapRoleType = getMerchantBiMatterOperator(merchantBiMatterIds);
example.createCriteria()
.andIn("biId", merchantBiMatterIds)
.andEqualTo("deleted_flag", BaseModel.DeletedFlagEnum.N.name());
List<MerchantBiMatterOperator> merchantBiMatterOperators = merchantBiMatterOperatorMapper.selectByExample(example);
Map<Long, Map<Byte, List<MerchantBiMatterDTO.OperatorDTO>>> biIdMapRoleType = Optional.ofNullable(merchantBiMatterOperators)
.orElseGet(ArrayList::new)
.stream()
.collect(Collectors.groupingBy(
MerchantBiMatterOperator::getBiId,
Collectors.groupingBy(
MerchantBiMatterOperator::getRoleType,
Collectors.mapping(
ele -> MerchantBiMatterDTO.OperatorDTO.builder().uuid(ele.getUserUuid()).username(ele.getUserName()).build(),
Collectors.toList()
)
)
));
// 处理区域运营和线上运营 // 处理区域运营和线上运营
result.forEach(ele -> { result.forEach(ele -> {
Optional.ofNullable(biIdMapRoleType.get(ele.getId())) Optional.ofNullable(biIdMapRoleType.get(ele.getId()))
...@@ -511,4 +494,150 @@ public class BiAnalyseBackgroundService { ...@@ -511,4 +494,150 @@ public class BiAnalyseBackgroundService {
} }
/**
* BI-事项管理新增
* @author yangwei
* @since 2025/12/17 17:28
* @param request 请求参数
*/
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void merchantBiMatterAdd(MerchantBiMatterAddDTO request) {
BeanValidationUtils.validateAndThrow(request, Default.class);
Date now = new Date();
MerchantBiMatter merchantBiMatter = BeanUtil.copyProperties(request, MerchantBiMatter.class);
merchantBiMatter.setCreatedAt(now);
merchantBiMatter.setStatus(MerchantBiMatterStatusEnum.WAIT_PROCESS.getCode());
merchantBiMatter.setDeletedFlag(BaseModel.DeletedFlagEnum.N.name());
merchantBiMatterMapper.insert(merchantBiMatter);
// 维护运营人员
List<MerchantBiMatterOperator> biMatterOperators = Stream.concat(
request.getOnlineOperator().stream().map(ele -> biMatterOperatorBuilder(ele, merchantBiMatter.getId(), request.getCreator(), now, MerchantBiMatterOperatorRoleTypeEnum.ONLINE_OPERATOR)),
request.getAreaOperator().stream().map(ele -> biMatterOperatorBuilder(ele, merchantBiMatter.getId(), request.getCreator(), now, MerchantBiMatterOperatorRoleTypeEnum.AREA_OPERATOR))
).collect(Collectors.toList());
merchantBiMatterOperatorMapper.insertList(biMatterOperators);
// todo 向关联的区域运营和线上运营推送消息
}
/**
* 事项管理运营人员
* @author yangwei
* @since 2025/12/17 17:28
* @param ele 请求参数
* @param biId 事项id
* @param creator 创建人
* @param now 创建时间
* @param roleType 角色类型
*/
public MerchantBiMatterOperator biMatterOperatorBuilder(MerchantBiMatterDTO.OperatorDTO ele,
Long biId,
String creator,
Date now,
MerchantBiMatterOperatorRoleTypeEnum roleType) {
MerchantBiMatterOperator merchantBiMatterOperator = BeanUtil.copyProperties(ele, MerchantBiMatterOperator.class);
merchantBiMatterOperator.setBiId(biId);
merchantBiMatterOperator.setRoleType(roleType.getCode());
merchantBiMatterOperator.setDeletedFlag(BaseModel.DeletedFlagEnum.N.name());
merchantBiMatterOperator.setCreatedBy(creator);
merchantBiMatterOperator.setCreatedDate(now);
return merchantBiMatterOperator;
}
/**
* 事项管理详情
* @author yangwei
* @since 2025/12/17 17:28
* @param request 请求参数
*/
public MerchantBiMatterDTO biMatterOperatorDetail(MerchantBiMatterSingleIdDTO request) {
BeanValidationUtils.validateAndThrow(request, Default.class);
MerchantBiMatter merchantBiMatter = Optional.ofNullable(merchantBiMatterMapper.selectByPrimaryKey(request.getId()))
.orElseThrow(() -> new RpcServiceException(BiErrorEnum.MERCHANT_BI_MATTER_NOT_EXIST));
MerchantBiMatterDTO result = BeanUtil.copyProperties(merchantBiMatter, MerchantBiMatterDTO.class);
Example example = new Example(MerchantBiMatterOperator.class);
example.createCriteria()
.andEqualTo("biId", request.getId())
.andEqualTo("deletedFlag", BaseModel.DeletedFlagEnum.N.name());
List<MerchantBiMatterOperator> merchantBiMatterOperators = merchantBiMatterOperatorMapper.selectByExample(example);
Map<Byte, List<MerchantBiMatterDTO.OperatorDTO>> roleTypeMapOperator = Optional.ofNullable(merchantBiMatterOperators).orElseGet(ArrayList::new)
.stream()
.collect(Collectors.groupingBy(
MerchantBiMatterOperator::getRoleType,
Collectors.mapping(
ele -> MerchantBiMatterDTO.OperatorDTO.builder().uuid(ele.getUserUuid()).username(ele.getUserName()).build(),
Collectors.toList()
)
));
result.setOnlineOperator(roleTypeMapOperator.get(MerchantBiMatterOperatorRoleTypeEnum.ONLINE_OPERATOR.getCode()));
result.setAreaOperator(roleTypeMapOperator.get(MerchantBiMatterOperatorRoleTypeEnum.AREA_OPERATOR.getCode()));
return result;
}
/**
* 我的事项列表
* @author yangwei
* @since 2025/12/18 0:12
* @param condition 请求参数
* @return com.github.pagehelper.Page<cn.com.glsx.dj.peanalysis.dto.analysis.MyMerchantBiMatterDTO>
*/
public Page<MyMerchantBiMatterDTO> myMerchantBiMatterPage(RpcPagination<MyMerchantBiMatterQryDTO> condition) {
PageUtils.handlerPage(condition);
Page<MyMerchantBiMatterDTO> page = PageHelper.startPage(condition.getPageNum(), condition.getPageSize());
merchantBiMatterMapper.selectMyBiMatterList(condition.getCondition());
List<MyMerchantBiMatterDTO> result = page.getResult();
if (CollUtil.isEmpty(result)) {
return page;
}
List<Long> merchantBiMatterIds = result.stream().map(MyMerchantBiMatterDTO::getId).collect(Collectors.toList());
Map<Long, Map<Byte, List<MerchantBiMatterDTO.OperatorDTO>>> biIdMapRoleType = getMerchantBiMatterOperator(merchantBiMatterIds);
// 处理区域运营和线上运营
result.forEach(ele -> {
Optional.ofNullable(biIdMapRoleType.get(ele.getId()))
.map(map -> map.get(MerchantBiMatterOperatorRoleTypeEnum.ONLINE_OPERATOR.getCode()))
.ifPresent(ele::setOnlineOperator);
Optional.ofNullable(biIdMapRoleType.get(ele.getId()))
.map(map -> map.get(MerchantBiMatterOperatorRoleTypeEnum.AREA_OPERATOR.getCode()))
.ifPresent(ele::setAreaOperator);
});
return page;
}
/**
* 获取事项的运营人员
* @author yangwei
* @since 2025/12/18 0:09
* @param merchantBiMatterIds bi事项id
* @return java.util.Map<java.lang.Long,java.util.Map<java.lang.Byte,java.util.List<cn.com.glsx.dj.peanalysis.dto.analysis.MerchantBiMatterDTO.OperatorDTO>>>
*/
private Map<Long, Map<Byte, List<MerchantBiMatterDTO.OperatorDTO>>> getMerchantBiMatterOperator(List<Long> merchantBiMatterIds) {
Example example = new Example(MerchantBiMatterOperator.class);
example.createCriteria()
.andIn("biId", merchantBiMatterIds)
.andEqualTo("deleted_flag", BaseModel.DeletedFlagEnum.N.name());
List<MerchantBiMatterOperator> merchantBiMatterOperators = merchantBiMatterOperatorMapper.selectByExample(example);
return Optional.ofNullable(merchantBiMatterOperators)
.orElseGet(ArrayList::new)
.stream()
.collect(Collectors.groupingBy(
MerchantBiMatterOperator::getBiId,
Collectors.groupingBy(
MerchantBiMatterOperator::getRoleType,
Collectors.mapping(
ele -> MerchantBiMatterDTO.OperatorDTO.builder().uuid(ele.getUserUuid()).username(ele.getUserName()).build(),
Collectors.toList()
)
)
));
}
} }
...@@ -18,7 +18,7 @@ public class PageUtils { ...@@ -18,7 +18,7 @@ public class PageUtils {
/** /**
* 最大分页大小 * 最大分页大小
*/ */
private static final int MAX_PAGE_SIZE = 100000; private static final int MAX_PAGE_SIZE = 300000;
/** /**
* 第一页 * 第一页
......
...@@ -82,4 +82,28 @@ ...@@ -82,4 +82,28 @@
order by status asc, created_at desc order by status asc, created_at desc
</select> </select>
<select id="selectMyBiMatterList"
resultType="cn.com.glsx.dj.peanalysis.dto.analysis.MyMerchantBiMatterDTO">
select
id as id,
store_no as storeNo,
business_type as businessType,
store_name as storeName,
creator,
created_at as createdAt,
status,
description
from dj_merchant_bi_matter t1
where deleted_flag = 'N'
and (exists (select 1 from dj_merchant_bi_matter_operator t2 where t1.id = t2.bi_id and t2.user_uuid = #{operator} ) or
exists (select 1 from dj_merchant_bi_matter t3 where t1.id = t3.id and t3.creator_unique = #{operator}))
<if test="status != null">
and status = #{status}
</if>
<if test="storeName != null and storeName != ''">
and store_name like concat('%',#{storeName},'%')
</if>
order by status asc, created_at desc
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
  • @wangxw1
    commented
    Master

    Auto Review Result:

    代码审查报告

    问题描述和优化建议

    1. 功能实现的正确性与健壮性

      • 问题:MerchantBiMatterAddDTO 和 MyMerchantBiMatterDTO 中的 businessType 字段使用了硬编码的字符串值(如 "1", "2", "3", "4")。这可能会导致在其他地方使用这些值时出现不一致的问题。
      • 优化建议:建议将这些硬编码的值提取到一个枚举类中,以提高代码的可维护性和一致性。
    2. 安全性与潜在风险

      • 问题:虽然当前代码没有明显的安全漏洞,但为了防止未来的潜在风险,建议对所有从外部接收的数据进行严格的验证和清理。
      • 优化建议:确保所有的输入数据都经过验证,避免 SQL 注入、XSS 攻击等安全问题。可以考虑使用更严格的输入验证规则和数据清洗机制。
    3. 是否符合最佳实践

      • 问题:MerchantBiMatterAddDTO 和 MyMerchantBiMatterDTO 中的字段注释较为简单,缺乏详细的解释。
      • 优化建议:增加字段注释的详细程度,以便其他开发者更好地理解每个字段的用途和约束条件。
      • 问题:PageUtils 类中的 MAX_PAGE_SIZE 设置为 300000,这个值可能过大,容易导致内存溢出。
      • 优化建议:根据实际业务需求调整 MAX_PAGE_SIZE 的值,确保不会因为单次请求的数据量过大而导致系统性能下降或崩溃。
    4. 性能与资源利用效率

      • 问题:BiAnalyseBackgroundService 中的 myMerchantBiMatterPage 方法在处理大量数据时可能存在性能瓶颈。
      • 优化建议:可以考虑使用数据库的索引优化查询,或者在应用层进行数据分页和缓存,减少数据库的压力。
    5. Commits信息的清晰性与准确性

      • 问题:提交信息 "feat:1047852:d+后台事项新增,我的事项列表" 不够清晰,无法明确知道具体的变更内容。
      • 优化建议:提交信息应该更加具体,明确指出新增的功能点和修改的内容,例如:"feat:1047852 - 添加后台事项新增功能及我的事项列表查询接口"。

    评分明细

    1. 功能实现的正确性与健壮性:35分(扣5分因硬编码值)
    2. 安全性与潜在风险:28分(扣2分因未提及安全验证机制)
    3. 是否符合最佳实践:17分(扣3分因注释不够详细;扣2分因 MAX_PAGE_SIZE 值过大)
    4. 性能与资源利用效率:4分(扣1分因可能存在的性能瓶颈)
    5. Commits信息的清晰性与准确性:4分(扣1分因提交信息不够清晰)

    总分

    总分:89分


    以上是针对此次代码提交的详细评审意见,希望对您有所帮助。如果有任何疑问或需要进一步讨论的地方,请随时联系我。

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!