Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-store
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
base_platform_enterprise
gic-store
Commits
c9c841e2
Commit
c9c841e2
authored
Feb 07, 2020
by
陶光胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
门店刷新es优化
parent
6371fdb1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
389 additions
and
16 deletions
+389
-16
StoreDTO.java
gic-store-api/src/main/java/com/gic/store/dto/StoreDTO.java
+10
-0
StoreEsDTO.java
...store-api/src/main/java/com/gic/store/dto/StoreEsDTO.java
+9
-0
StoreApiService.java
.../src/main/java/com/gic/store/service/StoreApiService.java
+10
-0
TabStoreIndexLogMapper.java
...java/com/gic/store/dao/mapper/TabStoreIndexLogMapper.java
+54
-0
TabStore.java
...-service/src/main/java/com/gic/store/entity/TabStore.java
+32
-12
TabStoreIndexLog.java
.../src/main/java/com/gic/store/entity/TabStoreIndexLog.java
+87
-0
StoreIndexLogService.java
...main/java/com/gic/store/service/StoreIndexLogService.java
+10
-0
StoreIndexLogServiceImpl.java
.../com/gic/store/service/impl/StoreIndexLogServiceImpl.java
+38
-0
StoreApiServiceImpl.java
...com/gic/store/service/outer/impl/StoreApiServiceImpl.java
+32
-4
TabStoreIndexLogMapper.xml
...vice/src/main/resources/mapper/TabStoreIndexLogMapper.xml
+107
-0
TabStoreMapper.xml
...tore-service/src/main/resources/mapper/TabStoreMapper.xml
+0
-0
No files found.
gic-store-api/src/main/java/com/gic/store/dto/StoreDTO.java
View file @
c9c841e2
...
...
@@ -38,6 +38,7 @@ public class StoreDTO extends StoreInfoDTO implements Serializable {
private
Integer
fromEnterpriseId
;
private
String
fromEnterpriseName
;
private
Double
score
;
/**
* 事由 1:web后台操作 2:外部触发 3:订单同步 4:会员同步 5:系统配置触发
...
...
@@ -158,4 +159,12 @@ public class StoreDTO extends StoreInfoDTO implements Serializable {
public
void
setOperatorName
(
String
operatorName
)
{
this
.
operatorName
=
operatorName
;
}
public
Double
getScore
()
{
return
score
;
}
public
void
setScore
(
Double
score
)
{
this
.
score
=
score
;
}
}
\ No newline at end of file
gic-store-api/src/main/java/com/gic/store/dto/StoreEsDTO.java
View file @
c9c841e2
...
...
@@ -32,6 +32,7 @@ public class StoreEsDTO implements Serializable {
private
List
<
StoreBusinessTimeDTO
>
businessTimeList
;
private
String
location
;
private
String
address
;
private
Double
score
;
public
Integer
getStoreId
()
{
return
storeId
;
...
...
@@ -256,4 +257,12 @@ public class StoreEsDTO implements Serializable {
public
void
setAddress
(
String
address
)
{
this
.
address
=
address
;
}
public
Double
getScore
()
{
return
score
;
}
public
void
setScore
(
Double
score
)
{
this
.
score
=
score
;
}
}
gic-store-api/src/main/java/com/gic/store/service/StoreApiService.java
View file @
c9c841e2
...
...
@@ -136,6 +136,16 @@ public interface StoreApiService {
ServiceResponse
<
Void
>
addStoreToIndex
(
Integer
enterpriseId
,
Integer
storeId
);
/**
* @Title:
* @Description: 门店es刷新队列方法
* @author zhiwj
* @param param
* @return com.gic.api.base.commons.ServiceResponse
* @throws
*/
ServiceResponse
<
Void
>
addStoreToIndexMq
(
String
param
);
/**
* @Title: bulkAddStoreToIndex
* @Description: 批量添加门店到索引
* @author zhiwj
...
...
gic-store-service/src/main/java/com/gic/store/dao/mapper/TabStoreIndexLogMapper.java
0 → 100644
View file @
c9c841e2
package
com
.
gic
.
store
.
dao
.
mapper
;
import
com.gic.store.entity.TabStoreIndexLog
;
public
interface
TabStoreIndexLogMapper
{
/**
* 根据主键删除
*
* @param storeIndexId 主键
* @return 更新条目数
*/
int
deleteByPrimaryKey
(
Integer
storeIndexId
);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
insert
(
TabStoreIndexLog
record
);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
insertSelective
(
TabStoreIndexLog
record
);
/**
* 根据主键查询
*
* @param storeIndexId 主键
* @return 实体对象
*/
TabStoreIndexLog
selectByPrimaryKey
(
Integer
storeIndexId
);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
updateByPrimaryKeySelective
(
TabStoreIndexLog
record
);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
updateByPrimaryKey
(
TabStoreIndexLog
record
);
}
\ No newline at end of file
gic-store-service/src/main/java/com/gic/store/entity/TabStore.java
View file @
c9c841e2
...
...
@@ -21,6 +21,9 @@ public class TabStore {
*/
private
Integer
enterpriseId
;
/**
* 门店来源企业
*/
private
Integer
fromEnterpriseId
;
/**
...
...
@@ -28,6 +31,9 @@ public class TabStore {
*/
private
Integer
storeGroupId
;
/**
* 是否手动修改过门店分组
*/
private
Integer
isEditStoreGroup
;
/**
...
...
@@ -50,6 +56,11 @@ public class TabStore {
*/
private
Date
updateTime
;
/**
* 门店评分
*/
private
Double
score
;
public
Integer
getStoreId
()
{
return
storeId
;
}
...
...
@@ -74,6 +85,14 @@ public class TabStore {
this
.
enterpriseId
=
enterpriseId
;
}
public
Integer
getFromEnterpriseId
()
{
return
fromEnterpriseId
;
}
public
void
setFromEnterpriseId
(
Integer
fromEnterpriseId
)
{
this
.
fromEnterpriseId
=
fromEnterpriseId
;
}
public
Integer
getStoreGroupId
()
{
return
storeGroupId
;
}
...
...
@@ -82,6 +101,14 @@ public class TabStore {
this
.
storeGroupId
=
storeGroupId
;
}
public
Integer
getIsEditStoreGroup
()
{
return
isEditStoreGroup
;
}
public
void
setIsEditStoreGroup
(
Integer
isEditStoreGroup
)
{
this
.
isEditStoreGroup
=
isEditStoreGroup
;
}
public
Integer
getOwnType
()
{
return
ownType
;
}
...
...
@@ -114,19 +141,11 @@ public class TabStore {
this
.
updateTime
=
updateTime
;
}
public
Integer
getIsEditStoreGroup
()
{
return
isEditStoreGroup
;
public
Double
getScore
()
{
return
score
;
}
public
void
setIsEditStoreGroup
(
Integer
isEditStoreGroup
)
{
this
.
isEditStoreGroup
=
isEditStoreGroup
;
}
public
Integer
getFromEnterpriseId
()
{
return
fromEnterpriseId
;
}
public
void
setFromEnterpriseId
(
Integer
fromEnterpriseId
)
{
this
.
fromEnterpriseId
=
fromEnterpriseId
;
public
void
setScore
(
Double
score
)
{
this
.
score
=
score
;
}
}
\ No newline at end of file
gic-store-service/src/main/java/com/gic/store/entity/TabStoreIndexLog.java
0 → 100644
View file @
c9c841e2
package
com
.
gic
.
store
.
entity
;
import
java.util.Date
;
/**
* tab_store_index_log
*/
public
class
TabStoreIndexLog
{
/**
*
*/
private
Integer
storeIndexId
;
/**
*
*/
private
Integer
enterpriseId
;
/**
*
*/
private
Integer
storeId
;
/**
*
*/
private
String
result
;
/**
*
*/
private
Date
createTime
;
/**
*
*/
private
Date
updateTime
;
public
Integer
getStoreIndexId
()
{
return
storeIndexId
;
}
public
void
setStoreIndexId
(
Integer
storeIndexId
)
{
this
.
storeIndexId
=
storeIndexId
;
}
public
Integer
getEnterpriseId
()
{
return
enterpriseId
;
}
public
void
setEnterpriseId
(
Integer
enterpriseId
)
{
this
.
enterpriseId
=
enterpriseId
;
}
public
Integer
getStoreId
()
{
return
storeId
;
}
public
void
setStoreId
(
Integer
storeId
)
{
this
.
storeId
=
storeId
;
}
public
String
getResult
()
{
return
result
;
}
public
void
setResult
(
String
result
)
{
this
.
result
=
result
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
}
\ No newline at end of file
gic-store-service/src/main/java/com/gic/store/service/StoreIndexLogService.java
0 → 100644
View file @
c9c841e2
package
com
.
gic
.
store
.
service
;
/**
* Created by tgs on 2020/2/6.
*/
public
interface
StoreIndexLogService
{
int
saveStoreIndexLog
(
Integer
enterpriseId
,
Integer
storeId
);
int
updateStoreIndexLog
(
Integer
logId
,
String
result
);
}
gic-store-service/src/main/java/com/gic/store/service/impl/StoreIndexLogServiceImpl.java
0 → 100644
View file @
c9c841e2
package
com
.
gic
.
store
.
service
.
impl
;
import
com.gic.store.dao.mapper.TabStoreIndexLogMapper
;
import
com.gic.store.entity.TabStoreIndexLog
;
import
com.gic.store.service.StoreIndexLogService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
/**
* Created by tgs on 2020/2/6.
*/
@Service
(
"storeIndexLogService"
)
public
class
StoreIndexLogServiceImpl
implements
StoreIndexLogService
{
@Autowired
private
TabStoreIndexLogMapper
tabStoreIndexLogMapper
;
@Override
public
int
saveStoreIndexLog
(
Integer
enterpriseId
,
Integer
storeId
)
{
TabStoreIndexLog
log
=
new
TabStoreIndexLog
();
log
.
setUpdateTime
(
new
Date
());
log
.
setCreateTime
(
new
Date
());
log
.
setEnterpriseId
(
enterpriseId
);
log
.
setStoreId
(
storeId
);
this
.
tabStoreIndexLogMapper
.
insertSelective
(
log
);
return
log
.
getStoreIndexId
();
}
@Override
public
int
updateStoreIndexLog
(
Integer
logId
,
String
result
)
{
TabStoreIndexLog
log
=
new
TabStoreIndexLog
();
log
.
setStoreIndexId
(
logId
);
log
.
setResult
(
result
);
int
i
=
this
.
tabStoreIndexLogMapper
.
updateByPrimaryKeySelective
(
log
);
return
i
;
}
}
gic-store-service/src/main/java/com/gic/store/service/outer/impl/StoreApiServiceImpl.java
View file @
c9c841e2
...
...
@@ -5,16 +5,14 @@ import com.alibaba.fastjson.JSONArray;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.commons.util.DateUtil
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.GlobalInfo
;
import
com.gic.commons.util.PageHelperUtils
;
import
com.gic.commons.util.*
;
import
com.gic.enterprise.dto.CustomStoreDTO
;
import
com.gic.enterprise.dto.EnterpriseDTO
;
import
com.gic.enterprise.error.ErrorCode
;
import
com.gic.enterprise.response.EnterpriseServiceResponse
;
import
com.gic.enterprise.service.CustomStoreApiService
;
import
com.gic.enterprise.service.EnterpriseApiService
;
import
com.gic.mq.sdk.GicMQClient
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.search.business.api.constant.enums.OperateEnum
;
import
com.gic.search.business.api.dto.DynamicDocDTO
;
...
...
@@ -95,6 +93,8 @@ public class StoreApiServiceImpl implements StoreApiService {
private
ProvincesApiService
provincesApiService
;
@Autowired
private
StoreFieldService
storeFieldService
;
@Autowired
private
StoreIndexLogService
storeIndexLogService
;
private
Map
<
String
,
BulkUpdateStoreStrtegy
>
storeStrtegyMap
=
new
ConcurrentHashMap
<>();
...
...
@@ -921,6 +921,27 @@ public class StoreApiServiceImpl implements StoreApiService {
@Override
public
ServiceResponse
addStoreToIndex
(
Integer
enterpriseId
,
Integer
storeId
)
{
logger
.
info
(
"addStoreToIndex:{},{}"
,
enterpriseId
,
storeId
);
int
logId
=
this
.
storeIndexLogService
.
saveStoreIndexLog
(
enterpriseId
,
storeId
);
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"enterpriseId"
,
enterpriseId
);
json
.
put
(
"storeId"
,
storeId
);
json
.
put
(
"logId"
,
logId
);
GicMQClient
clientInstance
=
GICMQClientUtil
.
getClientInstance
();
try
{
clientInstance
.
sendMessage
(
"storeIndexMq"
,
json
.
toJSONString
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
addStoreToIndexMq
(
String
param
){
JSONObject
json
=
JSON
.
parseObject
(
param
);
Integer
enterpriseId
=
json
.
getInteger
(
"enterpriseId"
);
Integer
storeId
=
json
.
getInteger
(
"storeId"
);
Integer
logId
=
json
.
getInteger
(
"logId"
);
boolean
isAdd
=
true
;
DynamicSearchDTO
dynamicSearchDTO
=
new
DynamicSearchDTO
();
JSONObject
search
=
QueryConditionAssemblyUtil
.
createSimpleQueryNode
(
"id"
,
OperateEnum
.
OPERATE_EQ
,
enterpriseId
+
"_"
+
storeId
);
...
...
@@ -938,6 +959,7 @@ public class StoreApiServiceImpl implements StoreApiService {
}
DynamicDocDTO
docDTO
=
this
.
buildStoreDocDto
(
enterpriseId
,
storeId
);
logger
.
info
(
"写入es的门店数据:{}"
,
JSON
.
toJSONString
(
docDTO
,
true
));
String
message
=
"success"
;
if
(
docDTO
!=
null
)
{
ServiceResponse
esResponse
=
null
;
if
(
isAdd
)
{
...
...
@@ -947,10 +969,15 @@ public class StoreApiServiceImpl implements StoreApiService {
}
logger
.
info
(
"门店写入es返回结果:{}"
,
JSON
.
toJSONString
(
esResponse
));
if
(
esResponse
.
isSuccess
())
{
this
.
storeIndexLogService
.
updateStoreIndexLog
(
logId
,
message
);
return
esResponse
;
}
message
=
esResponse
.
getMessage
();
this
.
storeIndexLogService
.
updateStoreIndexLog
(
logId
,
message
);
return
EnterpriseServiceResponse
.
failure
(
esResponse
.
getCode
(),
esResponse
.
getMessage
());
}
message
=
"门店不存在"
;
this
.
storeIndexLogService
.
updateStoreIndexLog
(
logId
,
message
);
return
null
;
}
...
...
@@ -1041,6 +1068,7 @@ public class StoreApiServiceImpl implements StoreApiService {
esDTO
.
setBusinessTimeList
(
dto
.
getBusinessTimeList
());
esDTO
.
setPhotoList
(
dto
.
getPhotoList
());
esDTO
.
setAddress
(
dto
.
getAddress
());
esDTO
.
setScore
(
dto
.
getScore
());
Double
[]
location
=
{
Double
.
valueOf
(
StringUtils
.
isBlank
(
dto
.
getLongitude
())?
"0"
:
dto
.
getLongitude
()),
Double
.
valueOf
(
StringUtils
.
isBlank
(
dto
.
getLatitude
())?
"0"
:
dto
.
getLatitude
())};
JSONObject
jsonObject
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
esDTO
));
jsonObject
.
put
(
"location"
,
location
);
...
...
gic-store-service/src/main/resources/mapper/TabStoreIndexLogMapper.xml
0 → 100644
View file @
c9c841e2
<?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=
"com.gic.store.dao.mapper.TabStoreIndexLogMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.gic.store.entity.TabStoreIndexLog"
>
<id
column=
"store_index_id"
jdbcType=
"INTEGER"
property=
"storeIndexId"
/>
<result
column=
"enterprise_id"
jdbcType=
"INTEGER"
property=
"enterpriseId"
/>
<result
column=
"store_id"
jdbcType=
"INTEGER"
property=
"storeId"
/>
<result
column=
"result"
jdbcType=
"VARCHAR"
property=
"result"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
store_index_id, enterprise_id, store_id, result, create_time, update_time
</sql>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_store_index_log
where store_index_id = #{storeIndexId,jdbcType=INTEGER}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Integer"
>
delete from tab_store_index_log
where store_index_id = #{storeIndexId,jdbcType=INTEGER}
</delete>
<insert
id=
"insert"
parameterType=
"com.gic.store.entity.TabStoreIndexLog"
useGeneratedKeys=
"true"
keyProperty=
"storeIndexId"
keyColumn=
"storeIndexId"
>
insert into tab_store_index_log (store_index_id, enterprise_id, store_id,
result, create_time, update_time
)
values (#{storeIndexId,jdbcType=INTEGER}, #{enterpriseId,jdbcType=INTEGER}, #{storeId,jdbcType=INTEGER},
#{result,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.gic.store.entity.TabStoreIndexLog"
useGeneratedKeys=
"true"
keyProperty=
"storeIndexId"
keyColumn=
"storeIndexId"
>
insert into tab_store_index_log
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"storeIndexId != null"
>
store_index_id,
</if>
<if
test=
"enterpriseId != null"
>
enterprise_id,
</if>
<if
test=
"storeId != null"
>
store_id,
</if>
<if
test=
"result != null"
>
result,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"storeIndexId != null"
>
#{storeIndexId,jdbcType=INTEGER},
</if>
<if
test=
"enterpriseId != null"
>
#{enterpriseId,jdbcType=INTEGER},
</if>
<if
test=
"storeId != null"
>
#{storeId,jdbcType=INTEGER},
</if>
<if
test=
"result != null"
>
#{result,jdbcType=VARCHAR},
</if>
<if
test=
"createTime != null"
>
#{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.gic.store.entity.TabStoreIndexLog"
>
update tab_store_index_log
<set>
<if
test=
"enterpriseId != null"
>
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
</if>
<if
test=
"storeId != null"
>
store_id = #{storeId,jdbcType=INTEGER},
</if>
<if
test=
"result != null"
>
result = #{result,jdbcType=VARCHAR},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where store_index_id = #{storeIndexId,jdbcType=INTEGER}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.gic.store.entity.TabStoreIndexLog"
>
update tab_store_index_log
set enterprise_id = #{enterpriseId,jdbcType=INTEGER},
store_id = #{storeId,jdbcType=INTEGER},
result = #{result,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where store_index_id = #{storeIndexId,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
gic-store-service/src/main/resources/mapper/TabStoreMapper.xml
View file @
c9c841e2
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment