Showing
3 changed files
with
109 additions
and
6 deletions
1 | +package com.yoho.search.dal; | ||
2 | + | ||
3 | +import com.yoho.search.dal.model.ProductHeatValues; | ||
4 | +import org.apache.ibatis.annotations.Param; | ||
5 | + | ||
6 | +import java.util.List; | ||
7 | + | ||
8 | +public interface ProductHeatValuesOneDayMapper { | ||
9 | + | ||
10 | + Integer selectLatestDateId(); | ||
11 | + | ||
12 | + Integer selectCount(@Param(value = "dateId") Integer dateId); | ||
13 | + | ||
14 | + List<ProductHeatValues> selectHeatValuesOfLatestDateBySkn(@Param(value = "sknList") List<Integer> sknList, @Param(value = "dateId") Integer dateId); | ||
15 | + | ||
16 | + List<ProductHeatValues> selectHeatValuesOfLatestDate(@Param(value = "dateId") Integer dateId, @Param(value = "offset") Integer offset, @Param(value = "pageSize") Integer pageSize); | ||
17 | + | ||
18 | + List<Long> selectSknByDate(@Param(value = "dateId") String dateId, @Param(value = "pageSize") int pageSize); | ||
19 | + | ||
20 | + void deleteBatch(@Param(value = "sknList") List<Long> sknList, @Param(value = "dateId") String dateId); | ||
21 | +} |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | +<mapper namespace="com.yoho.search.dal.ProductHeatValuesOneDayMapper" > | ||
4 | + | ||
5 | + <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.ProductHeatValues" > | ||
6 | + <id column="product_skn" property="productSkn" jdbcType="INTEGER" /> | ||
7 | + <result column="date_id" property="dateId" jdbcType="VARCHAR" /> | ||
8 | + <result column="shareorder_num" property="shareorderNum" jdbcType="DECIMAL" /> | ||
9 | + <result column="sale_num" property="saleNum" jdbcType="DECIMAL" /> | ||
10 | + <result column="cart_num" property="cartNum" jdbcType="DECIMAL" /> | ||
11 | + <result column="favorite_num" property="favoriteNum" jdbcType="DECIMAL" /> | ||
12 | + <result column="comments_score" property="commentsScore" jdbcType="DECIMAL" /> | ||
13 | + <result column="ctr_value" property="ctrValue" jdbcType="DECIMAL" /> | ||
14 | + <result column="sale_amount" property="saleAmount" jdbcType="DECIMAL" /> | ||
15 | + <result column="profit_amount" property="profitAmount" jdbcType="DECIMAL" /> | ||
16 | + <result column="last_update_time" property="lastUpdateTime" jdbcType="INTEGER" /> | ||
17 | + </resultMap> | ||
18 | + | ||
19 | + <sql id="Base_Column_List" > | ||
20 | + product_skn, date_id, shareorder_num, sale_num, cart_num, favorite_num, comments_score, | ||
21 | + ctr_value, sale_amount, profit_amount, last_update_time | ||
22 | + </sql> | ||
23 | + | ||
24 | + <select id="selectHeatValuesOfLatestDateBySkn" resultMap="BaseResultMap" timeout="20000"> | ||
25 | + <![CDATA[ | ||
26 | + select * from product_heat_values_oneday p | ||
27 | + where | ||
28 | + date_id = #{dateId} | ||
29 | + and | ||
30 | + p.product_skn in | ||
31 | + ]]> | ||
32 | + <foreach item="item" index="index" collection="sknList" | ||
33 | + open="(" separator="," close=")"> | ||
34 | + #{item} | ||
35 | + </foreach> | ||
36 | + </select> | ||
37 | + | ||
38 | + <select id="selectHeatValuesOfLatestDate" resultMap="BaseResultMap" timeout="20000"> | ||
39 | + select * from product_heat_values_oneday p | ||
40 | + where | ||
41 | + date_id = #{dateId} | ||
42 | + limit #{offset},#{pageSize} | ||
43 | + </select> | ||
44 | + | ||
45 | + <select id="selectLatestDateId" resultType="java.lang.Integer"> | ||
46 | + select max(date_id) from product_heat_values_oneday | ||
47 | + </select> | ||
48 | + | ||
49 | + <select id="selectCount" resultType="java.lang.Integer" timeout="20000"> | ||
50 | + SELECT count(*) FROM product_heat_values_oneday | ||
51 | + where | ||
52 | + date_id = #{dateId} | ||
53 | + </select> | ||
54 | + | ||
55 | + <select id="selectSknByDate" resultType="java.lang.Long" timeout="20000"> | ||
56 | + SELECT product_skn FROM product_heat_values_oneday where date_id = #{dateId,jdbcType=VARCHAR} limit #{pageSize} | ||
57 | + </select> | ||
58 | + | ||
59 | + <delete id="deleteBatch"> | ||
60 | + <![CDATA[ | ||
61 | + DELETE FROM product_heat_values_oneday | ||
62 | + WHERE | ||
63 | + date_id = #{dateId,jdbcType=VARCHAR} | ||
64 | + AND | ||
65 | + ]]> | ||
66 | + product_skn in | ||
67 | + <foreach item="item" index="index" collection="sknList" open="(" separator="," close=")"> | ||
68 | + #{item} | ||
69 | + </foreach> | ||
70 | + </delete> | ||
71 | + | ||
72 | +</mapper> |
1 | package com.yoho.search.consumer.service.logic.productIndex; | 1 | package com.yoho.search.consumer.service.logic.productIndex; |
2 | 2 | ||
3 | import com.yoho.search.dal.ProductHeatValuesMapper; | 3 | import com.yoho.search.dal.ProductHeatValuesMapper; |
4 | +import com.yoho.search.dal.ProductHeatValuesOneDayMapper; | ||
4 | import com.yoho.search.dal.ProductMapper; | 5 | import com.yoho.search.dal.ProductMapper; |
5 | import com.yoho.search.dal.model.Product; | 6 | import com.yoho.search.dal.model.Product; |
6 | import com.yoho.search.dal.model.ProductHeatValues; | 7 | import com.yoho.search.dal.model.ProductHeatValues; |
@@ -34,6 +35,8 @@ public class ProductHeatValueLogicService { | @@ -34,6 +35,8 @@ public class ProductHeatValueLogicService { | ||
34 | @Autowired | 35 | @Autowired |
35 | private ProductHeatValuesMapper productHeatValuesMapper; | 36 | private ProductHeatValuesMapper productHeatValuesMapper; |
36 | @Autowired | 37 | @Autowired |
38 | + private ProductHeatValuesOneDayMapper productHeatValuesOneDayMapper; | ||
39 | + @Autowired | ||
37 | private ProductMapper productMapper; | 40 | private ProductMapper productMapper; |
38 | 41 | ||
39 | private Integer dateId = null; | 42 | private Integer dateId = null; |
@@ -53,16 +56,23 @@ public class ProductHeatValueLogicService { | @@ -53,16 +56,23 @@ public class ProductHeatValueLogicService { | ||
53 | productSknToIdMap.put(product.getErpProductId(), product.getId()); | 56 | productSknToIdMap.put(product.getErpProductId(), product.getId()); |
54 | } | 57 | } |
55 | List<ProductHeatValues> productHeatValuesList = productHeatValuesMapper.selectHeatValuesOfLatestDateBySkn(sknList, this.getDateId()); | 58 | List<ProductHeatValues> productHeatValuesList = productHeatValuesMapper.selectHeatValuesOfLatestDateBySkn(sknList, this.getDateId()); |
56 | - if (CollectionUtils.isEmpty(productHeatValuesList)) { | 59 | + List<ProductHeatValues> productHeatValuesOneDayList = productHeatValuesOneDayMapper.selectHeatValuesOfLatestDateBySkn(sknList, this.getDateId()); |
60 | + if (CollectionUtils.isEmpty(productHeatValuesList)&&CollectionUtils.isEmpty(productHeatValuesOneDayList)) { | ||
57 | return new HashMap<>(); | 61 | return new HashMap<>(); |
58 | } | 62 | } |
59 | Map<Integer, BigDecimal> result = new HashMap<Integer, BigDecimal>(); | 63 | Map<Integer, BigDecimal> result = new HashMap<Integer, BigDecimal>(); |
60 | for (ProductHeatValues productHeatValues : productHeatValuesList) { | 64 | for (ProductHeatValues productHeatValues : productHeatValuesList) { |
61 | - Integer productId = productSknToIdMap.get(productHeatValues.getProductSkn()); | ||
62 | - if (productId != null) { | ||
63 | - result.put(productId, this.countHeatValue(productHeatValues)); | ||
64 | - } | ||
65 | - } | 65 | + Integer productId = productSknToIdMap.get(productHeatValues.getProductSkn()); |
66 | + if (productId != null) { | ||
67 | + result.put(productId, this.countHeatValue(productHeatValues)); | ||
68 | + } | ||
69 | + } | ||
70 | + for (ProductHeatValues productHeatValues : productHeatValuesOneDayList) { | ||
71 | + Integer productId = productSknToIdMap.get(productHeatValues.getProductSkn()); | ||
72 | + if (productId != null) { | ||
73 | + result.put(productId, result.get(productId).add(this.countHeatValue(productHeatValues))); | ||
74 | + } | ||
75 | + } | ||
66 | return result; | 76 | return result; |
67 | } | 77 | } |
68 | 78 |
-
Please register or login to post a comment