Commit c90409ed by guojuxing

Merge remote-tracking branch 'origin/developer' into developer

parents 05646667 791d69e9
......@@ -167,7 +167,16 @@ public interface StoreApiService {
* @return com.gic.api.base.commons.ServiceResponse
* @throws
*/
ServiceResponse<Void> bulkAddStoreToIndex(Integer enterpriseId);
ServiceResponse<Integer> bulkAddStoreToIndex(Integer enterpriseId);
/** @Description: 通过分组刷新门店缓存
* @author taogs
* @Date 14:25 2020/4/2
* @Param
* @return
*/
ServiceResponse<Integer> refreshStoreIndex(Integer enterpriseId, Integer storeGroupId);
/**
* @Title: bulkAddStoreToIndex
......@@ -181,39 +190,6 @@ public interface StoreApiService {
ServiceResponse<Void> bulkAddStoreToIndex(Integer enterpriseId, List<Integer> storeIdList);
/**
* @Title: updateStoreToIndex
* @Description: 批量编辑门店到索引
* @author zhiwj
* @param enterpriseId
* @param storeId
* @param indexId
* @return com.gic.api.base.commons.ServiceResponse
* @throws
*/
ServiceResponse<Void> updateStoreToIndex(Integer enterpriseId, Integer storeId, Long indexId);
/**
* @Title: bulkUpdateStoreToIndex
* @Description: 批量编辑门店到索引
* @author zhiwj
* @param enterpriseId
* @return com.gic.api.base.commons.ServiceResponse
* @throws
*/
ServiceResponse<Void> bulkUpdateStoreToIndex(Integer enterpriseId);
/**
* @Title: bulkUpdateStoreToIndex
* @Description: 批量编辑门店到索引
* @author zhiwj
* @param enterpriseId
* @param storeIdList
* @return com.gic.api.base.commons.ServiceResponse
* @throws
*/
ServiceResponse<Void> bulkUpdateStoreToIndex(Integer enterpriseId, List<Integer> storeIdList);
/**
* @Title: queryStoreFromES
* @Description: 查询es
* @author zhiwj
......
......@@ -77,4 +77,8 @@ public interface TabStoreMapper {
@Param("storeBrandId") Integer storeBrandId);
Integer checkExistStore(@Param("enterpriseId") Integer enterpriseId);
int refreshStoreIndex(@Param("enterpriseId") Integer enterpriseId);
int refreshStoreIndexByStoreGroup(@Param("enterpriseId") Integer enterpriseId, @Param("storeGroupId") Integer storeGroupId);
}
\ No newline at end of file
......@@ -130,4 +130,8 @@ public interface StoreService {
TabStore getByStoreCodeAndRegionId(Integer enterpriseId, Integer regionId, String storeCode);
Boolean checkExistStore(Integer enterpriseId);
int refreshStoreIndex(Integer enterpriseId);
int refreshStoreIndex(Integer enterpriseId, Integer storeGroupId);
}
......@@ -514,4 +514,14 @@ public class StoreServiceImpl implements StoreService {
Integer line = this.tabStoreMapper.checkExistStore(enterpriseId);
return line != null;
}
@Override
public int refreshStoreIndex(Integer enterpriseId) {
return this.tabStoreMapper.refreshStoreIndex(enterpriseId);
}
@Override
public int refreshStoreIndex(Integer enterpriseId, Integer storeGroupId) {
return this.tabStoreMapper.refreshStoreIndexByStoreGroup(enterpriseId, storeGroupId);
}
}
......@@ -1042,9 +1042,9 @@ public class StoreApiServiceImpl implements StoreApiService {
}
if (type == 1 || type == 5 || type == 7) {
if ("all".equals(storeIds)) {
this.bulkUpdateStoreToIndex(enterpriseId);
this.bulkAddStoreToIndex(enterpriseId);
} else {
this.bulkUpdateStoreToIndex(enterpriseId, storeIdList);
this.bulkAddStoreToIndex(enterpriseId, storeIdList);
}
}
} catch (Exception e) {
......@@ -1130,55 +1130,20 @@ public class StoreApiServiceImpl implements StoreApiService {
@Override
public ServiceResponse bulkAddStoreToIndex(Integer enterpriseId) {
List<Integer> storeIdList = this.storeService.listAllStoreId(enterpriseId);
return this.bulkAddStoreToIndex(enterpriseId, storeIdList);
int i = this.storeService.refreshStoreIndex(enterpriseId);
return ServiceResponse.success(i);
}
@Override
public ServiceResponse bulkAddStoreToIndex(Integer enterpriseId, List<Integer> storeIdList) {
if (CollectionUtils.isNotEmpty(storeIdList)) {
List<DynamicDocDTO> dynamicDocDTOList = new ArrayList<>();
for (int i = 0; i < storeIdList.size(); i++) {
DynamicDocDTO docDTO = this.buildStoreDocDto(enterpriseId, storeIdList.get(i));
dynamicDocDTOList.add(docDTO);
if (dynamicDocDTOList.size() == 200) {
this.esBusinessOperaApiService.createDataBatch(dynamicDocDTOList, true);
dynamicDocDTOList.clear();
}
}
if (CollectionUtils.isNotEmpty(dynamicDocDTOList)) {
this.esBusinessOperaApiService.createDataBatch(dynamicDocDTOList, true);
}
}
return ServiceResponse.success();
public ServiceResponse<Integer> refreshStoreIndex(Integer enterpriseId, Integer storeGroupId) {
int i = this.storeService.refreshStoreIndex(enterpriseId, storeGroupId);
return ServiceResponse.success(i);
}
@Override
public ServiceResponse updateStoreToIndex(Integer enterpriseId, Integer storeId, Long indexId) {
return null;
}
@Override
public ServiceResponse bulkUpdateStoreToIndex(Integer enterpriseId) {
List<Integer> storeIdList = this.storeService.listAllStoreId(enterpriseId);
return this.bulkUpdateStoreToIndex(enterpriseId, storeIdList);
}
@Override
public ServiceResponse bulkUpdateStoreToIndex(Integer enterpriseId, List<Integer> storeIdList) {
if (CollectionUtils.isNotEmpty(storeIdList)) {
List<DynamicDocDTO> dynamicDocDTOList = new ArrayList<>();
for (int i = 0; i < storeIdList.size(); i++) {
DynamicDocDTO docDTO = this.buildStoreDocDto(enterpriseId, storeIdList.get(i));
dynamicDocDTOList.add(docDTO);
if (dynamicDocDTOList.size() == 200) {
this.esBusinessOperaApiService.updateDataBatch(dynamicDocDTOList, true);
dynamicDocDTOList.clear();
}
}
if (CollectionUtils.isNotEmpty(dynamicDocDTOList)) {
this.esBusinessOperaApiService.updateDataBatch(dynamicDocDTOList, true);
}
public ServiceResponse bulkAddStoreToIndex(Integer enterpriseId, List<Integer> storeIdList) {
for(Integer storeId : storeIdList){
this.addStoreToIndex(enterpriseId, storeId);
}
return ServiceResponse.success();
}
......
......@@ -6,6 +6,7 @@ import java.util.List;
import java.util.Stack;
import java.util.concurrent.TimeUnit;
import com.gic.store.service.StoreApiService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -38,6 +39,8 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService {
private StoreService storeService;
@Autowired
private StoreGroupService storeGroupService;
@Autowired
private StoreApiService storeApiService;
@Override
public ServiceResponse<Integer> save(StoreGroupDTO storeGroupDTO) {
......@@ -204,6 +207,7 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService {
//刷新缓存
refreshRedisCache(storeGroupDTO.getStoreGroupId());
this.storeApiService.refreshStoreIndex(storeGroupDTO.getEnterpriseId(), storeGroupDTO.getStoreGroupId());
return ServiceResponse.success(SUCCESS);
}
......
......@@ -238,4 +238,15 @@
from tab_store
where enterprise_id = #{enterpriseId} and own_type = 0 limit 1
</select>
<update id="refreshStoreIndex">
update tab_store t1,tab_store_info t2 set t2.index_id=t2.index_id + 1,t2.update_time=t2.update_time
where t1.enterprise_id=#{enterpriseId}
and t1.store_info_id=t2.store_info_id
</update>
<update id="refreshStoreIndexByStoreGroup">
update tab_store t1,tab_store_info t2 set t2.index_id=t2.index_id + 1,t2.update_time=t2.update_time
where t1.enterprise_id=#{enterpriseId}
and t1.store_group_id=#{storeGroupId}
and t1.store_info_id=t2.store_info_id
</update>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment