Commit a1ee3fbf by 徐高华

标签同步

parent c08b10d1
......@@ -321,5 +321,4 @@ public interface ExternalClerkRelatedApiService {
*/
com.gic.api.base.commons.ServiceResponse<String> getMemberIdByExternalId(String wxEnterpriseId,String externalUserId);
void listMemberIdByEnterpriseId(String json);
}
......@@ -178,12 +178,6 @@ public interface TabHaobanExternalClerkRelatedMapper {
List<String> listMemberIdByEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("enterpriseId") String enterpriseId);
Integer countByEnterpriseIdAndWxEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("enterpriseId") String enterpriseId);
List<String> getMemberIdList(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("enterpriseId") String enterpriseId,
@Param("num")Integer num,
@Param("size")Integer size);
/**
* 查询会员在企业下的好友关系memberIds 根据会员ids
......
package com.gic.haoban.manage.service.service.out.impl;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ctrip.framework.apollo.ConfigService;
import com.gic.api.base.commons.Page;
import com.gic.api.base.dto.SubscribeMessageDTO;
import com.gic.clerk.api.dto.ClerkDTO;
......@@ -13,7 +10,6 @@ import com.gic.commons.util.GICMQClientUtil;
import com.gic.dubbo.entity.ProviderLocalTag;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.app.customer.dto.QywxTagSyncInfoDTO;
import com.gic.haoban.app.customer.enums.GicQywxSyncTypeEnum;
import com.gic.haoban.app.customer.enums.QywxSyncTaskTypeEnum;
import com.gic.haoban.app.customer.service.api.service.QywxTagSyncApiService;
......@@ -62,14 +58,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
......@@ -113,8 +102,6 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
private MemberService memberService;
@Autowired
private ExternalClerkRelatedService externalClerkRelatedService;
@Autowired
private QywxTagSyncApiService qywxTagSyncApiService;
/**
* 查询会员在企业下的好友关系
......@@ -800,98 +787,4 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
public com.gic.api.base.commons.ServiceResponse<String> getMemberIdByExternalId(String wxEnterpriseId, String externalUserId) {
return com.gic.api.base.commons.ServiceResponse.success(externalClerkRelatedService.getMemberIdByExternalId(wxEnterpriseId,externalUserId));
}
@Override
public void listMemberIdByEnterpriseId(String json){
if(null == json){
log.info("参数不能为空");
return;
}
log.info("标签同步会员参数:{}",json);
QywxTagSyncInfoDTO dto = JSONObject.parseObject(json, QywxTagSyncInfoDTO.class);
Integer size = 1000;
String wxEnterpriseId = dto.getWxEnterpriseId();
String enterpriseId = dto.getEnterpriseId();
Integer totalCount = 0;
/*Integer totalCount = tabHaobanExternalClerkRelatedMapper.countByEnterpriseIdAndWxEnterpriseId(wxEnterpriseId, enterpriseId);
if(0 == totalCount){
dto.setTotalCount(0);
qywxTagSyncApiService.tagSync(dto);
return;
}
dto.setTotalCount(totalCount);*/
Connection conn = null;
ResultSet rs = null;
PreparedStatement pstat = null;
List<String> result = new LinkedList<>();
try {
String excelDb = "devDs";
String schema = "haoban3";
if (isProd()) {
excelDb = "haobanDs" ;
schema = "haoban3.0";
}
conn = com.gic.privatedb.util.ConnectionUtil.createConnection(excelDb, schema);
StringBuilder sqlBuilder = new StringBuilder("select ");
sqlBuilder.append("member_id memberId")
.append(" from tab_haoban_external_clerk_related where wx_enterprise_id ='")
.append(wxEnterpriseId).append("'")
.append(" and enterprise_id ='").append(enterpriseId).append("'")
.append(" and status_flag = 1");
String sql = sqlBuilder.toString();
log.info("查询会员id执行的sql语句:{}",sql);
pstat = conn.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
pstat.setFetchSize(Integer.MIN_VALUE);
pstat.setFetchDirection(ResultSet.FETCH_REVERSE);
rs = pstat.executeQuery();
while (rs.next()) {
String memberId = rs.getString("memberId");
result.add(memberId);
if (result.size() == size){
totalCount = totalCount + size;
dto.setMemberIds(result);
dto.setTotalCount(totalCount);
qywxTagSyncApiService.tagSync(dto);
result.clear();
}
}
if (CollUtil.isNotEmpty(result)){
totalCount = totalCount + result.size();
dto.setMemberIds(result);
dto.setTotalCount(totalCount);
qywxTagSyncApiService.tagSync(dto);
result.clear();
}else {
dto.setMemberIds(result);
dto.setTotalCount(totalCount);
qywxTagSyncApiService.tagSync(dto);
}
}catch (Exception e){
log.warn("异常",e);
}finally {
try {
if (null != rs) {
rs.close();
rs = null;
}
if (null != pstat) {
pstat.close();
pstat = null;
}
if (null != conn) {
conn.close();
conn = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
private boolean isProd() {
com.ctrip.framework.apollo.Config config = ConfigService.getConfig("COMMON.gic-properties");
String env = config.getProperty("environment.value", "") ;
log.info("feile env={}",env);
return "prod".equals(env) ;
}
}
......@@ -517,22 +517,6 @@
and enterprise_id = #{enterpriseId}
and status_flag = 1
</select>
<select id="countByEnterpriseIdAndWxEnterpriseId" resultType="int">
select count(*)
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and status_flag = 1
</select>
<select id="getMemberIdList" resultType="String">
select member_id
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and status_flag = 1
limit ${num},${size}
</select>
<select id="listMemberIdsByMemberIds" resultType="String">
select
......
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