Commit 707b0ab9 by 张富康

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

2 parents 6f71f4ba 41819e38
......@@ -18,6 +18,9 @@ public class StoreSceneSummaryResponse implements Serializable {
@ApiModelProperty(notes = "总开单门店数")
private Integer totalStores;
@ApiModelProperty(notes = "总开单门店商户号")
private List<Integer> totalStoreIds;
@ApiModelProperty(notes = "总开单门店环比")
private BigDecimal totalStoresMom;
......
......@@ -3,6 +3,8 @@ 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.math.BigDecimal;
......@@ -10,12 +12,20 @@ import java.math.BigDecimal;
@ApiModel(description = "产值响应")
@Data
@ToString
@Accessors(chain = true)
public class TrendOutputResponse implements Serializable {
private static final long serialVersionUID = -1;
@ApiModelProperty(notes = "时间")
private String time;
@ApiModelProperty(notes = "开始时间")
private String startTime;
@ApiModelProperty(notes = "结束时间")
private String endTime;
@ApiModelProperty(notes = "产值")
private BigDecimal output;
......
......@@ -129,4 +129,8 @@ public interface BusinessIntelligenceMapper {
List<TrendChartRes> countUsedCarMerchants(@Param("statDateList") List<Pair<String, String>> statDateList, @Param("merchantIds") List<Integer> merchantIds);
List<Integer> getZyMerchantIds(@Param("property") String property);
//统计兜底门店数量
Integer countBackUpStores(@Param("merchantIds") List<Integer> merchantIds, @Param("businessType") Integer businessType
, @Param("startDate") String startDate, @Param("endDate") String endDate);
}
\ No newline at end of file
......@@ -23,4 +23,6 @@ public interface ServiceMerchantMapper extends OreMapper<ServiceMerchant> {
List<StoreSettingDTO> findStoreSetting(@Param("merchantIds") List<Integer> merchantIds, @Param("scene") Integer scene);
List<StoreInfo> findYydList(@Param("list") List<Integer> collected);
}
\ No newline at end of file
......@@ -787,5 +787,35 @@
AND t1.deleted_flag = 'N'
</select>
<select id="countBackUpStores" resultType="java.lang.Integer">
SELECT count(distinct merchant_id4s)
FROM early_warning_msg t1
left join early_warning_rule t2 on t1.rule_id =t2.id
WHERE t1.deleted_flag = 'N' and t2.rule_type ='兜底指标'
<choose>
<when test="businessType == 1">
and t1.business_type = 4
</when>
<when test="businessType == 2">
and t1.business_type = 2
</when>
<otherwise>
and t1.business_type = 3
</otherwise>
</choose>
<if test="merchantIds != null and merchantIds.size() > 0">
and t1.merchant_id4s in
<foreach item="item" index="index" collection="merchantIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="startDate != null and startDate != null">
and t1.star_date &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != null">
and t1.star_date &lt;= #{endDate}
</if>
</select>
</mapper>
\ No newline at end of file
package cn.com.glsx.dj.peanalysis.service;
import cn.com.glsx.dj.peanalysis.dto.req.output.SceneBaseReq;
import cn.com.glsx.dj.peanalysis.dto.res.output.StoreSceneSummaryResponse;
import cn.com.glsx.dj.peanalysis.remote.BaseRemoteTest;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -171,4 +173,16 @@ public class BusinessSceneAnalysisServiceTest extends BaseRemoteTest {
Object res = service.goodsSummary(req);
System.out.println(res);
}
@Test
public void testStoreAnalysis() {
SceneBaseReq req = new SceneBaseReq();
req.setBizs(2);
req.setCycleType(5);
req.setStartTime("2025-01-01");
req.setEndTime("2025-12-31");
req.setMerchantIds(Lists.newArrayList(44217664));
StoreSceneSummaryResponse res = service.storeAnalysis(req);
System.out.println(JSON.toJSONString(res));
}
}
  • @wangxw1
    commented
    Master

    Auto Review Result:

    代码审查报告

    问题描述和优化建议

    1. 方法调用更改:

      • 问题描述:原始代码中使用 getDatePairInfo() 方法获取键值,而修改后的代码中改为使用 getDatePair() 方法。如果 getDatePairInfo() 和 getDatePair() 返回不同的值,这将导致数据无法正确匹配,从而引发数据错误。
      • 优化建议:需要确认 getDatePairInfo() 和 getDatePair() 的返回值是否一致。如果不一致,则需要进一步检查代码中其他地方是否也存在类似的调用,确保所有地方都能正确获取到键值。
    2. 数值精度设置:

      • 问题描述:在设置 item.setValue(dataBusinessDTO.getItemValue().setScale(2, RoundingMode.HALF_UP)); 时,直接对 BigDecimal 进行了 setScale 操作。如果 dataBusinessDTO.getItemValue() 已经设置了精度,再次设置可能会导致不必要的计算开销。
      • 优化建议:可以在设置之前先检查 dataBusinessDTO.getItemValue() 的精度,或者确保 getItemValue() 方法总是返回一个已经设置好精度的 BigDecimal 值。
    3. 默认值设置:

      • 问题描述:代码中已经对 item.setValue(BigDecimal.ZERO); 设置了默认值,这是正确的做法,可以防止空指针异常。
      • 优化建议:确保在其他可能为空的地方也进行了类似的默认值设置,保持代码的一致性。

    评分明细

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

      • 分数:30分
      • 说明:代码逻辑基本正确,但需要进一步确认 getDatePairInfo() 和 getDatePair() 的返回值一致性。
    2. 安全性与潜在风险(30分):

      • 分数:30分
      • 说明:代码中没有明显的安全漏洞,但需要注意数值精度设置的潜在开销。
    3. 是否符合最佳实践(20分):

      • 分数:15分
      • 说明:代码结构清晰,但可以进一步优化数值精度的设置逻辑。
    4. 性能与资源利用效率(5分):

      • 分数:3分
      • 说明:代码中直接对 BigDecimal 进行 setScale 操作可能存在一定的性能开销。
    5. Commits信息的清晰性与准确性(5分):

      • 分数:4分
      • 说明:提交信息清晰,但可以更详细地说明为什么需要修改键值获取方法。

    总分

    总分:82分


    通过上述审查,代码在功能实现、安全性、最佳实践方面表现良好,但在数值精度设置和键值获取方法上存在一些改进空间。希望开发者能够根据这些建议进一步完善代码。

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