Commit 67382b61 by zhouhaibao

Merge remote-tracking branch 'origin/v5.5.1' into v5.5.1

2 parents 2c292324 79b5b23d
......@@ -25,6 +25,7 @@ public class SalePotentialCustomersReq implements Serializable {
*/
@ApiModelProperty(notes = "关联商户id ")
private List<Integer> merchantIds;
private List<Integer> excludeMerchantIds;
/**
* 是否绑定 0-否 1-是
......
......@@ -87,6 +87,9 @@ public class SceneBaseReq implements Serializable {
@ApiModelProperty(notes = "是否查询达成率趋势")
private boolean withTargetRatio;
@ApiModelProperty(notes = "是否预估趋势")
private boolean isPredictTrend;
@ApiModelProperty(notes = "查询类型")
private int queryType;
......
package cn.com.glsx.dj.peanalysis.dto.res.UserdCarDataStats;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class TrendChartInfoRes implements Serializable {
private static final long serialVersionUID = 2507729541857822347L;
/**
* 原始趋势图数据
*/
private List<TrendChartRes> list;
/**
* 预测趋势图数据
*/
private List<TrendChartRes> predictList;
}
......@@ -6,6 +6,7 @@ import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
@ApiModel(description = "区域分布响应")
......@@ -25,4 +26,6 @@ public class RegionalDistributionResponse implements Serializable {
@ApiModelProperty(notes = "新车交付数总和")
private BigDecimal deliveryCount;
private List<Integer> merchantIds;
}
package cn.com.glsx.dj.peanalysis.dto.res.output;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
@ApiModel(description = "产值响应")
@Data
@ToString
@Accessors(chain = true)
public class TrendOutputWithPredictResponse implements Serializable {
private static final long serialVersionUID = -1;
@ApiModelProperty(notes = "产值趋势")
private List<TrendOutputResponse> list;
@ApiModelProperty(notes = "产值预测")
private List<TrendOutputResponse> listpredict;
}
......@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.Date;
import java.util.List;
@Mapper
......@@ -15,7 +16,7 @@ public interface GoodsOrderMapper extends OreMapper<GoodsOrder> {
List<TrafficContributionRankResponse> findTrafficRank(
@Param("merchantIds") List<Integer> merchantIds,
@Param("staffUuids") List<String> staffUuids,
@Param("startDate") String startDate,
@Param("endDate") String endDate,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@Param("scene") Integer sceneType);
}
\ No newline at end of file
......@@ -438,10 +438,12 @@ public class UsedCarDataStatsService {
* 二手车相关趋势图
*/
public List<TrendChartRes> getTrendChart(TrendChartReq request) {
// TrendChartInfoRes result = new TrendChartInfoRes();
List<Pair<String, String>> previousPeriodsIncludingCurrent = DateUtils.getPreviousPeriodsIncludingCurrent(
request.getStartTime(), request.getEndTime(), request.getCycleType(), 8);
List<PeriodDescription> periodDescriptions = DateUtils.formatPeriodDescriptions(previousPeriodsIncludingCurrent, request.getCycleType());
List<TrendChartRes> result = TrendChartResConvert.INSTANCE.toTrendChartResList(periodDescriptions);
List<TrendChartRes> list = TrendChartResConvert.INSTANCE.toTrendChartResList(periodDescriptions);
// result.setList(list);
List<Integer> merchantIds = new ArrayList<>();
if (ObjectUtil.isEmpty(request.getMerchantId())) {
Integer brandId = request.getBrandId();
......@@ -451,7 +453,7 @@ public class UsedCarDataStatsService {
|| ObjectUtil.equals(request.getRole(), LoginRoleEnum.SALE_LEADER.getValue());
if (leaderBoolean) {
if (CollUtil.isEmpty(merchantIds)) {
return result;
return list;
}
}
// 是否通过品牌,区域
......@@ -467,14 +469,14 @@ public class UsedCarDataStatsService {
filterMerchantResponse = filterMerchantIdsResponse.getResult();
// 如果为空则返回空结果
if (CollUtil.isEmpty(filterMerchantResponse)) {
return result;
return list;
}
merchantIdList = filterMerchantResponse.stream().map(MerchantProvinceDTO::getMerchantId).collect(Collectors.toList());
// 如果角色为销售大区经理和区域运营大区经理需要取交集
if (leaderBoolean) {
merchantIds = merchantIds.stream().filter(merchantIdList::contains).collect(Collectors.toList());
if (CollUtil.isEmpty(merchantIds)) {
return result;
return list;
}
} else {
merchantIds = merchantIdList;
......@@ -495,7 +497,7 @@ public class UsedCarDataStatsService {
// 二手车产值(当期卖车总产值、环比)-A0001 二手车毛利(当期毛利、环比)-A0002
queryDataBiz.setItemCodes(request.getTrendChartType() == 1 ? "A0001" : "A0002");
Map<Pair<String, String>, DataBusinessDTO> dataResp = getDataStatsService.parallelCallTimeMap(previousPeriodsIncludingCurrent, queryDataBiz);
for (TrendChartRes item : result) {
for (TrendChartRes item : list) {
DataBusinessDTO dataBusinessDTO = dataResp.get(item.getDatePair());
item.setValue(BigDecimal.ZERO);
if (ObjectUtil.isNotEmpty(dataBusinessDTO)) {
......@@ -509,7 +511,7 @@ public class UsedCarDataStatsService {
trendChartList.forEach(item -> item.setDatePair(item.getDatePairInfo()));
// trendChartRes根据datePair分组
Map<Pair<String, String>, TrendChartRes> trendChartResMap = trendChartList.stream().collect(Collectors.toMap(TrendChartRes::getDatePair, item -> item));
for (TrendChartRes item : result) {
for (TrendChartRes item : list) {
TrendChartRes trendChart = trendChartResMap.get(item.getDatePair());
item.setValue(BigDecimal.ZERO);
if (ObjectUtil.isNotEmpty(trendChart)) {
......@@ -517,10 +519,48 @@ public class UsedCarDataStatsService {
}
}
}
return result;
// result.setList(list);
// // 当周期类型为周或月
// if (ObjectUtil.equals(request.getCycleType(), 1) || ObjectUtil.equals(request.getCycleType(), 2)) {
// // 且今天属于当周或今天属于当月时,需要设置预测数据
// // 判断今天是否大于开始日期
// Date startDate = DateUtil.parse(request.getStartTime(), "yyyy-MM-dd");
// // 结束时间
// Date endDate = DateUtil.parse(request.getEndTime(), "yyyy-MM-dd");
// if (endDate.after(new Date())) {
// List<TrendChartRes> predictList = new ArrayList<>();
// // 把list数据 深拷贝到 predictList
// for (int i = 0; i < list.size(); i++) {
// // 需要修改第一个值为预测值
// TrendChartRes predictItem = new TrendChartRes();
// predictItem.setDateDescription(list.get(i).getDateDescription());
// predictItem.setDatePair(list.get(i).getDatePair());
// BigDecimal value = list.get(i).getValue();
// if (i == 0) {
// // 判断今天时间距离开始时间多少天,这个值除以周数或者月数,然后乘以周数或者月数,得到预测值
// long day = DateUtil.between(new Date(), startDate, DateUnit.DAY) + 1;
// long totalDays = DateUtil.between(endDate, startDate, DateUnit.DAY) + 1;
// // [当前产值 * (结束时间-开始时间+1)] / (当天日期-开始时间+1) 保留2位小数
// // value不大于0则返回0
// if (value.compareTo(BigDecimal.ZERO) <= 0) {
// predictItem.setValue(BigDecimal.ZERO);
// } else {
// BigDecimal predictValue = NumberUtil.div(NumberUtil.mul(value, totalDays), day).setScale(2, RoundingMode.HALF_UP);
// predictItem.setValue(predictValue);
// }
// } else {
// predictItem.setValue(value);
// }
// predictList.add(predictItem);
// }
// result.setPredictList(predictList);
// }
// }
return list;
}
/**
* 存量门店分析
*/
......@@ -1042,6 +1082,14 @@ public class UsedCarDataStatsService {
.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
}
public static BigDecimal calculateDivWithoutMultiply(Number num1, Number num2) {
// 如果num2为0,则返回null
if (num2.doubleValue() == 0) {
return null;
}
return NumberUtil.div(num1, num2, 2, RoundingMode.HALF_UP);
}
/**
* 统计单品类门店数量
* 规则:在统计周期内,门店恰好开展1种业务
......
......@@ -147,37 +147,54 @@
<select id="findTrafficRank" resultType="cn.com.glsx.dj.peanalysis.dto.res.output.TrafficContributionRankResponse">
select
user_id as employeeId,
employee_name as employeeName,
count(*) as totalTrafficContribution
from dj_car_life_goods_order
o.user_id as employeeId,
o.employee_name as employeeName,
count(distinct o.order_code) as totalTrafficContribution
from dj_car_life_goods_order o
left join dj_car_life_pay_order po on po.order_code=o.order_code and po.deleted_flag='N'
<where>
deleted_flag = 'N'
and user_id is not null
and status in (2, 4, 6)
o.deleted_flag = 'N'
and o.user_id is not null
and o.status in (2, 4, 6)
<if test="merchantIds != null and merchantIds.size() > 0">
and merchant_id in
and o.merchant_id in
<foreach collection="merchantIds" item="uuid" open="(" close=")" separator=",">
#{uuid}
</foreach>
</if>
<if test="staffUuids != null and staffUuids.size() > 0">
and user_id in
and o.user_id in
<foreach collection="staffUuids" item="uuid" open="(" close=")" separator=",">
#{uuid}
</foreach>
</if>
<if test="startDate != null and startDate !=''">
and order_time >= #{startDate}
<if test="scene != null">
and o.scene_type = #{scene}
</if>
<if test="endDate != null and endDate !=''">
and order_time &lt;= #{endDate}
<if test="startDate != null">
<![CDATA[ and (
(
o.upgrade_flag='Y' and po.success_date >= #{startDate}
)
or (
o.upgrade_flag='N' and o.order_time >= #{startDate}
)
)
]]>
</if>
<if test="scene != null">
and scene_type = #{scene}
<if test="endDate != null">
<![CDATA[ and (
(
o.upgrade_flag='Y' and po.success_date <= #{endDate}
)
or (
o.upgrade_flag='N' and o.order_time <= #{endDate}
)
)
]]>
</if>
</where>
group by user_id
group by o.user_id
</select>
</mapper>
\ No newline at end of file
......@@ -95,6 +95,12 @@
#{item}
</foreach>
</if>
<if test="excludeMerchantIds != null and excludeMerchantIds.size() > 0">
and spc.merchant_id not in
<foreach item="item" collection="excludeMerchantIds" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
<if test="isBind != null">
and spc.is_bind = #{isBind}
</if>
......
  • @wangxw1
    commented
    Master

    Auto Review Result:

    代码审查报告

    问题描述和优化建议

    1. 重复计算 technicianCount:

      • 问题描述:在方法中首先通过流操作计算了 technicianCount,但在循环内部又重新计算了 technicianCount,并且在循环结束后再次将 technicianCount 加入到 totalStaffCount 中,这会导致重复计算。
      • 优化建议:删除循环内部对 technicianCount 的重新计算,并确保只在循环外进行一次累加。
    2. 方法命名不清晰:

      • 问题描述:calculatePercent 方法名不够具体,没有明确表示该方法的功能。
      • 优化建议:将方法名改为更具描述性的名称,例如 calculateProfitMargin。
    3. 提交信息不清晰:

      • 问题描述:提交信息 "技师去重;Merge remote-tracking branch 'origin/v5.5.1' into v5.5.1" 包含了两个不同的操作,且没有详细描述所做的更改。
      • 优化建议:将合并分支的操作和业务逻辑的更改分开提交,或者在提交信息中详细描述所做的更改,例如 "修复技师去重逻辑"。

    评分明细

    1. 功能实现的正确性与健壮性(40分):

      • 代码逻辑存在重复计算的问题,需要修正。
      • 分数:30分
    2. 安全性与潜在风险(30分):

      • 当前代码段没有明显的安全漏洞。
      • 分数:30分
    3. 是否符合最佳实践(20分):

      • 方法命名不够清晰,需要改进。
      • 分数:15分
    4. 性能与资源利用效率(5分):

      • 当前代码没有明显的性能问题。
      • 分数:5分
    5. Commits信息的清晰性与准确性(5分):

      • 提交信息不够清晰,建议改进。
      • 分数:2分

    总分

    总分:82分


    通过以上审查,建议开发者对上述问题进行修正,并在未来的代码提交中遵循最佳实践,编写清晰的提交信息。

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