Commit 97b58372 by zhouhaibao

[+]bi报表新增埋点

1 parent 5de1ccac
package cn.com.glsx.dj.peanalysis.model;
import java.util.Date;
import javax.persistence.*;
import lombok.Builder;
@Table(name = "bi_dynamic_record")
@Builder
public class BIDynamicRecord implements java.io.Serializable{
/**
* id
*/
@Id
private Integer id;
/**
* 用户账号ID
*/
@Column(name = "customer_account_id")
private String customerAccountId;
/**
* 用户名
*/
@Column(name = "customer_account_name")
private String customerAccountName;
/**
* 用户手机号码
*/
@Column(name = "customer_mobile")
private String customerMobile;
/**
* 页面id
*/
@Column(name = "goods_type")
private Byte goodsType;
/**
* 进入时间
*/
@Column(name = "enter_date")
private Date enterDate;
/**
* 离开时间
*/
@Column(name = "leave_date")
private Date leaveDate;
/**
* 浏览时长/秒
*/
@Column(name = "browse_duration")
private Integer browseDuration;
/**
* 创建人
*/
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标识(D:已删除;N:未删除)
*/
@Column(name = "deleted_flag")
private String deletedFlag;
/**
* 获取id
*
* @return id - id
*/
public Integer getId() {
return id;
}
/**
* 设置id
*
* @param id id
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取用户名
*
* @return customer_account_name - 用户名
*/
public String getCustomerAccountName() {
return customerAccountName;
}
/**
* 设置用户名
*
* @param customerAccountName 用户名
*/
public void setCustomerAccountName(String customerAccountName) {
this.customerAccountName = customerAccountName == null ? null : customerAccountName.trim();
}
/**
* 获取用户手机号码
*
* @return customer_mobile - 用户手机号码
*/
public String getCustomerMobile() {
return customerMobile;
}
/**
* 设置用户手机号码
*
* @param customerMobile 用户手机号码
*/
public void setCustomerMobile(String customerMobile) {
this.customerMobile = customerMobile == null ? null : customerMobile.trim();
}
/**
* 获取页面id
*
* @return goods_type - 页面id
*/
public Byte getGoodsType() {
return goodsType;
}
/**
* 设置页面id
*
* @param goodsType 页面id
*/
public void setGoodsType(Byte goodsType) {
this.goodsType = goodsType;
}
/**
* 获取进入时间
*
* @return enter_date - 进入时间
*/
public Date getEnterDate() {
return enterDate;
}
/**
* 设置进入时间
*
* @param enterDate 进入时间
*/
public void setEnterDate(Date enterDate) {
this.enterDate = enterDate;
}
/**
* 获取离开时间
*
* @return leave_date - 离开时间
*/
public Date getLeaveDate() {
return leaveDate;
}
/**
* 设置离开时间
*
* @param leaveDate 离开时间
*/
public void setLeaveDate(Date leaveDate) {
this.leaveDate = leaveDate;
}
/**
* 获取浏览时长/秒
*
* @return browse_duration - 浏览时长/秒
*/
public Integer getBrowseDuration() {
return browseDuration;
}
/**
* 设置浏览时长/秒
*
* @param browseDuration 浏览时长/秒
*/
public void setBrowseDuration(Integer browseDuration) {
this.browseDuration = browseDuration;
}
/**
* 获取创建人
*
* @return created_by - 创建人
*/
public String getCreatedBy() {
return createdBy;
}
/**
* 设置创建人
*
* @param createdBy 创建人
*/
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy == null ? null : createdBy.trim();
}
/**
* 获取创建时间
*
* @return created_date - 创建时间
*/
public Date getCreatedDate() {
return createdDate;
}
/**
* 设置创建时间
*
* @param createdDate 创建时间
*/
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
/**
* 获取修改人
*
* @return updated_by - 修改人
*/
public String getUpdatedBy() {
return updatedBy;
}
/**
* 设置修改人
*
* @param updatedBy 修改人
*/
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy == null ? null : updatedBy.trim();
}
/**
* 获取修改时间
*
* @return updated_date - 修改时间
*/
public Date getUpdatedDate() {
return updatedDate;
}
/**
* 设置修改时间
*
* @param updatedDate 修改时间
*/
public void setUpdatedDate(Date updatedDate) {
this.updatedDate = updatedDate;
}
/**
* 获取删除标识(D:已删除;N:未删除)
*
* @return deleted_flag - 删除标识(D:已删除;N:未删除)
*/
public String getDeletedFlag() {
return deletedFlag;
}
/**
* 设置删除标识(D:已删除;N:未删除)
*
* @param deletedFlag 删除标识(D:已删除;N:未删除)
*/
public void setDeletedFlag(String deletedFlag) {
this.deletedFlag = deletedFlag == null ? null : deletedFlag.trim();
}
public String getCustomerAccountId() {
return customerAccountId;
}
public void setCustomerAccountId(String customerAccountId) {
this.customerAccountId = customerAccountId;
}
}
\ No newline at end of file \ No newline at end of file
...@@ -8,6 +8,7 @@ import cn.com.glsx.dj.peanalysis.dto.req.output.RegionalOutputReq; ...@@ -8,6 +8,7 @@ import cn.com.glsx.dj.peanalysis.dto.req.output.RegionalOutputReq;
import cn.com.glsx.dj.peanalysis.dto.req.output.SceneBaseReq; import cn.com.glsx.dj.peanalysis.dto.req.output.SceneBaseReq;
import cn.com.glsx.dj.peanalysis.dto.req.output.TotalOutputReq; import cn.com.glsx.dj.peanalysis.dto.req.output.TotalOutputReq;
import cn.com.glsx.dj.peanalysis.dto.res.output.*; import cn.com.glsx.dj.peanalysis.dto.res.output.*;
import cn.com.glsx.dj.peanalysis.model.BIDynamicRecord;
import cn.com.glsx.dj.peanalysis.model.ProvinceRganization; import cn.com.glsx.dj.peanalysis.model.ProvinceRganization;
import cn.com.glsx.framework.core.annotation.ApiMethod; import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiService; import cn.com.glsx.framework.core.annotation.ApiService;
...@@ -40,4 +41,6 @@ public interface BusinessAnalysisRemote { ...@@ -40,4 +41,6 @@ public interface BusinessAnalysisRemote {
RpcResponse<List<StoreDetailResponse>> listStoreDetails(BaseReq req); RpcResponse<List<StoreDetailResponse>> listStoreDetails(BaseReq req);
RpcResponse<Boolean> insertDynamicRecord(BIDynamicRecord req);
} }
package cn.com.glsx.dj.peanalysis.mapper;
import cn.com.glsx.dj.peanalysis.model.BIDynamicRecord;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
@Mapper
public interface BIDynamicRecordMapper extends OreMapper<BIDynamicRecord> {
}
\ No newline at end of file \ No newline at end of file
...@@ -7,6 +7,7 @@ import cn.com.glsx.dj.peanalysis.dto.req.output.RegionalOutputReq; ...@@ -7,6 +7,7 @@ import cn.com.glsx.dj.peanalysis.dto.req.output.RegionalOutputReq;
import cn.com.glsx.dj.peanalysis.dto.req.output.SceneBaseReq; import cn.com.glsx.dj.peanalysis.dto.req.output.SceneBaseReq;
import cn.com.glsx.dj.peanalysis.dto.req.output.TotalOutputReq; import cn.com.glsx.dj.peanalysis.dto.req.output.TotalOutputReq;
import cn.com.glsx.dj.peanalysis.dto.res.output.*; import cn.com.glsx.dj.peanalysis.dto.res.output.*;
import cn.com.glsx.dj.peanalysis.model.BIDynamicRecord;
import cn.com.glsx.dj.peanalysis.model.ProvinceRganization; import cn.com.glsx.dj.peanalysis.model.ProvinceRganization;
import cn.com.glsx.dj.peanalysis.service.BusinessAnalysisService; import cn.com.glsx.dj.peanalysis.service.BusinessAnalysisService;
import cn.com.glsx.dj.peanalysis.service.ProvinceRganizationService; import cn.com.glsx.dj.peanalysis.service.ProvinceRganizationService;
...@@ -123,4 +124,15 @@ public class BusinessAnalysisRemoteImpl implements BusinessAnalysisRemote{ ...@@ -123,4 +124,15 @@ public class BusinessAnalysisRemoteImpl implements BusinessAnalysisRemote{
} }
} }
@Override
public RpcResponse<Boolean> insertDynamicRecord(BIDynamicRecord req) {
try {
businessAnalysisService.insertDynamicRecord(req);
return RpcResponse.success(true);
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
} }
...@@ -16,8 +16,10 @@ import cn.com.glsx.dj.peanalysis.dto.res.output.StoreDetailResponse; ...@@ -16,8 +16,10 @@ import cn.com.glsx.dj.peanalysis.dto.res.output.StoreDetailResponse;
import cn.com.glsx.dj.peanalysis.dto.res.output.StoreSummaryResponse; import cn.com.glsx.dj.peanalysis.dto.res.output.StoreSummaryResponse;
import cn.com.glsx.dj.peanalysis.dto.res.output.TotalOutputResponse; import cn.com.glsx.dj.peanalysis.dto.res.output.TotalOutputResponse;
import cn.com.glsx.dj.peanalysis.enums.LoginRoleEnum; import cn.com.glsx.dj.peanalysis.enums.LoginRoleEnum;
import cn.com.glsx.dj.peanalysis.mapper.BIDynamicRecordMapper;
import cn.com.glsx.dj.peanalysis.mapper.BusinessIntelligenceMapper; import cn.com.glsx.dj.peanalysis.mapper.BusinessIntelligenceMapper;
import cn.com.glsx.dj.peanalysis.mapper.ServiceMerchantMapper; import cn.com.glsx.dj.peanalysis.mapper.ServiceMerchantMapper;
import cn.com.glsx.dj.peanalysis.model.BIDynamicRecord;
import cn.com.glsx.dj.peanalysis.model.EmployeeDTO; import cn.com.glsx.dj.peanalysis.model.EmployeeDTO;
import cn.com.glsx.dj.peanalysis.model.MetricsResult; import cn.com.glsx.dj.peanalysis.model.MetricsResult;
import cn.com.glsx.dj.peanalysis.model.StoreInfo; import cn.com.glsx.dj.peanalysis.model.StoreInfo;
...@@ -50,6 +52,7 @@ import java.util.ArrayList; ...@@ -50,6 +52,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
...@@ -167,6 +170,9 @@ public class BusinessAnalysisService { ...@@ -167,6 +170,9 @@ public class BusinessAnalysisService {
@Autowired @Autowired
private BiAnalyseBackgroundService biAnalyseBackgroundService; private BiAnalyseBackgroundService biAnalyseBackgroundService;
@Autowired
private BIDynamicRecordMapper biDynamicRecordMapper;
/** /**
* 查询全业务总览数据 * 查询全业务总览数据
* *
...@@ -1590,11 +1596,7 @@ public class BusinessAnalysisService { ...@@ -1590,11 +1596,7 @@ public class BusinessAnalysisService {
private List<StoreInfo> findHHStoreInfo(List<Integer> collected) { private List<StoreInfo> findHHStoreInfo(List<Integer> collected) {
List<StoreInfo> result = serviceMerchantMapper.findYydList(collected); List<StoreInfo> result = serviceMerchantMapper.findYydList(collected);
if (CollectionUtils.isEmpty(result)) { if (CollectionUtils.isEmpty(result)) {
StoreInfo storeInfo = new StoreInfo(); return Collections.emptyList();
storeInfo.setStoreId(44218339);
storeInfo.setLuxury(true);
storeInfo.setTechnicianCount(2);
return Arrays.asList(storeInfo);
} else { } else {
List<Integer> yydMerchantIds = result.stream().map(StoreInfo::getYydStoreId).distinct() List<Integer> yydMerchantIds = result.stream().map(StoreInfo::getYydStoreId).distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
...@@ -1749,7 +1751,8 @@ public class BusinessAnalysisService { ...@@ -1749,7 +1751,8 @@ public class BusinessAnalysisService {
String property = environment.getProperty("direct.sale.merchantId"); String property = environment.getProperty("direct.sale.merchantId");
List<Integer> zyMerchantIds = businessIntelligenceMapper.getZyMerchantIds(property); List<Integer> zyMerchantIds = businessIntelligenceMapper.getZyMerchantIds(property);
if (CollectionUtils.isEmpty(zyMerchantIds)) { if (CollectionUtils.isEmpty(zyMerchantIds)) {
zyMerchantIds = Arrays.asList(44210895, 44212556,44218339); return new ArrayList<>();
// 测试数据
} }
return zyMerchantIds; return zyMerchantIds;
} }
...@@ -1990,4 +1993,10 @@ public class BusinessAnalysisService { ...@@ -1990,4 +1993,10 @@ public class BusinessAnalysisService {
} }
} }
public void insertDynamicRecord(BIDynamicRecord record) {
record.setCreatedDate(new Date());
record.setCreatedBy(record.getCustomerAccountId());
record.setEnterDate(record.getCreatedDate());
biDynamicRecordMapper.insert(record);
}
} }
<?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="cn.com.glsx.dj.peanalysis.mapper.BIDynamicRecordMapper" >
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.peanalysis.model.BIDynamicRecord" >
<!--
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="INTEGER" />
<result column="customer_account_id" property="customerAccountId" jdbcType="INTEGER" />
<result column="customer_account_name" property="customerAccountName" jdbcType="VARCHAR" />
<result column="customer_mobile" property="customerMobile" jdbcType="VARCHAR" />
<result column="goods_type" property="goodsType" jdbcType="TINYINT" />
<result column="enter_date" property="enterDate" jdbcType="TIMESTAMP" />
<result column="leave_date" property="leaveDate" jdbcType="TIMESTAMP" />
<result column="browse_duration" property="browseDuration" jdbcType="INTEGER" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR" />
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
-->
id, customer_account_id, customer_account_name, customer_mobile, goods_type, enter_date,
leave_date, browse_duration, created_by, created_date, updated_by, updated_date,
deleted_flag
</sql>
</mapper>
\ No newline at end of file \ No newline at end of file
  • @wangxw1
    commented
    Master

    Auto Review Result:

    代码审查报告

    问题描述和优化建议

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

    • 问题:在BusinessAnalysisService.java中,insertDynamicRecord方法中,record.setCreatedBy(record.getCustomerAccountId()); 这一行代码假设了customerAccountId总是可用的,这可能不是一种好的做法,如果customerAccountId为空,则会导致记录的创建人字段为空。

      • 建议:添加对customerAccountId的非空校验,或者使用一个默认值(如系统账户)来确保createdBy字段不为空。
    • 问题:findHHStoreInfo和getZyMerchantIds方法中,返回的测试数据被移除后,如果数据库中没有数据,这些方法会返回空列表。这可能会导致调用者需要额外的空值检查。

      • 建议:考虑在这些方法中添加适当的日志记录,以便于调试和监控。此外,可以考虑在方法调用处统一处理空值的情况,而不是在每个方法中都进行处理。

    2. 安全性与潜在风险

    • 问题:目前代码中没有明显的安全问题,但是由于BIDynamicRecord类中包含了敏感信息(如用户手机号码),在处理这些数据时需要注意防止数据泄露。
      • 建议:确保在传输和存储这些敏感信息时使用适当的安全措施,如加密和访问控制。

    3. 是否符合最佳实践

    • 问题:BIDynamicRecord类中的字段命名使用了驼峰命名法,但注释中的字段描述使用了下划线命名法,这可能会引起混淆。

      • 建议:统一字段描述的命名风格,建议使用驼峰命名法,以便与Java的编码规范保持一致。
    • 问题:insertDynamicRecord方法中的日志记录仅记录了错误信息,而没有记录请求参数或其他上下文信息。

      • 建议:增强日志记录,以便于调试和故障排除。例如,可以记录请求的详细信息,包括customerAccountId等关键字段。

    4. 性能与资源利用效率

    • 问题:目前代码中没有明显的性能问题,但是insertDynamicRecord方法中每次插入记录都会创建一个新的Date对象,这可能会导致一定的内存开销。
      • 建议:如果createdDate和enterDate字段总是相同的,可以考虑在插入之前创建一次Date对象,然后复用它。

    5. Commits信息的清晰性与准确性

    • 问题:提交信息“bi报表新增埋点”不够具体,无法明确知道这次提交的具体更改内容。
      • 建议:提供更详细的提交信息,例如“新增BIDynamicRecord实体类及其相关接口和实现”。

    评分明细

    • 功能实现的正确性与健壮性:35分
    • 安全性与潜在风险:28分
    • 是否符合最佳实践:18分
    • 性能与资源利用效率:5分
    • Commits信息的清晰性与准确性:4分

    总分: 88分


    请根据以上建议进行相应的代码调整和优化。

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