添加ec标签同步代码;优化excel中手机号重名情况;
This commit is contained in:
@@ -29,4 +29,6 @@ public class ExcelErrorConstants {
|
||||
|
||||
public static final String COUNT_MORE = "每次数据最多导入500条,请分批上传";
|
||||
|
||||
public static final String MOBILE_REPEAT = "手机号重复";
|
||||
|
||||
}
|
||||
|
||||
@@ -55,18 +55,23 @@
|
||||
</select>
|
||||
<select id="selectByHourDate" resultType="com.cool.store.entity.SyncEcCustomerDO" >
|
||||
SELECT
|
||||
a.id AS id,b.partner_id,
|
||||
a.username AS customername,
|
||||
a.mobile AS customermobile,
|
||||
a.id AS id,
|
||||
b.partner_id,
|
||||
b.username AS customername,
|
||||
b.mobile AS customermobile,
|
||||
d.`name` AS followname,
|
||||
d.mobile AS followmobile,b.line_status as lineStatus,
|
||||
c.channel_id AS channelId ,ifnull(tl_l.followCount,0) as followCount
|
||||
d.mobile AS followmobile,
|
||||
a.line_status AS lineStatus,
|
||||
c.channel_id AS channelId,
|
||||
ifnull( tl_l.followCount, 0 ) AS followCount
|
||||
FROM
|
||||
hy_partner_user_info a
|
||||
LEFT JOIN hy_partner_line_info b ON a.partner_id = b.partner_id and b.deleted=0
|
||||
LEFT JOIN hy_partner_user_channel c ON a.user_channel_id = c.channel_id
|
||||
LEFT JOIN enterprise_user d ON b.investment_manager = d.user_id and d.deleted=0
|
||||
LEFT JOIN (
|
||||
hy_partner_line_info a
|
||||
LEFT JOIN hy_partner_user_info b ON a.partner_id = b.partner_id
|
||||
AND a.deleted = 0
|
||||
LEFT JOIN hy_partner_user_channel c ON b.user_channel_id = c.channel_id
|
||||
LEFT JOIN enterprise_user d ON a.investment_manager = d.user_id
|
||||
AND d.deleted = 0
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
partner_id,
|
||||
IFNULL( COUNT( 1 ), 0 ) AS followCount
|
||||
@@ -76,31 +81,35 @@
|
||||
( deleted = 1 OR ( deleted = 0 AND line_status IN ( 0, 3 ) AND close_time IS NOT NULL ) )
|
||||
AND investment_manager IS NOT NULL
|
||||
GROUP BY
|
||||
partner_id ) tl_l on b.partner_id=tl_l.partner_id
|
||||
partner_id
|
||||
) tl_l ON b.partner_id = tl_l.partner_id
|
||||
WHERE ( b.update_time BETWEEN #{selectTime} and #{now} or
|
||||
a.update_time BETWEEN #{selectTime} and #{now} ) and a.username is not null order by a.id Limit #{limit1},#{limit2}
|
||||
a.update_time BETWEEN #{selectTime} and #{now} ) and b.partner_id is not null order by a.id Limit #{limit1},#{limit2}
|
||||
</select>
|
||||
<select id="selectByHourDateCount" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
count(*)
|
||||
FROM
|
||||
hy_partner_user_info a
|
||||
LEFT JOIN hy_partner_line_info b ON a.partner_id = b.partner_id and b.deleted=0
|
||||
LEFT JOIN hy_partner_user_channel c ON a.user_channel_id = c.channel_id
|
||||
LEFT JOIN enterprise_user d ON b.investment_manager = d.user_id and d.deleted=0
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
partner_id,
|
||||
IFNULL( COUNT( 1 ), 0 ) AS followCount
|
||||
FROM
|
||||
hy_partner_line_info
|
||||
WHERE
|
||||
( deleted = 1 OR ( deleted = 0 AND line_status IN ( 0, 3 ) AND close_time IS NOT NULL ) )
|
||||
AND investment_manager IS NOT NULL
|
||||
GROUP BY
|
||||
partner_id ) tl_l on b.partner_id=tl_l.partner_id
|
||||
hy_partner_line_info a
|
||||
LEFT JOIN hy_partner_user_info b ON a.partner_id = b.partner_id
|
||||
AND a.deleted = 0
|
||||
LEFT JOIN hy_partner_user_channel c ON b.user_channel_id = c.channel_id
|
||||
LEFT JOIN enterprise_user d ON a.investment_manager = d.user_id
|
||||
AND d.deleted = 0
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
partner_id,
|
||||
IFNULL( COUNT( 1 ), 0 ) AS followCount
|
||||
FROM
|
||||
hy_partner_line_info
|
||||
WHERE
|
||||
( deleted = 1 OR ( deleted = 0 AND line_status IN ( 0, 3 ) AND close_time IS NOT NULL ) )
|
||||
AND investment_manager IS NOT NULL
|
||||
GROUP BY
|
||||
partner_id
|
||||
) tl_l ON b.partner_id = tl_l.partner_id
|
||||
WHERE (b.update_time BETWEEN #{selectTime} and #{now} or
|
||||
a.update_time BETWEEN #{selectTime} and #{now} ) and a.username is not null
|
||||
a.update_time BETWEEN #{selectTime} and #{now} ) and b.partner_id is not null
|
||||
</select>
|
||||
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SyncEcCustomerLabelJob {
|
||||
@Autowired
|
||||
private MybatisBatchUtils mybatisBatchUtils;
|
||||
|
||||
private final Integer count = 10;
|
||||
private final Integer count = 20;
|
||||
|
||||
/**
|
||||
* 同步ec标签到招商数据库中
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.cool.store.dao.EnterpriseUserDAO;
|
||||
import com.cool.store.dao.HyPartnerBaseInfoDAO;
|
||||
import com.cool.store.dao.HyPartnerLineInfoDAO;
|
||||
import com.cool.store.dao.HyPartnerUserInfoDAO;
|
||||
import com.cool.store.dto.label.LabelAddDTO;
|
||||
import com.cool.store.dto.partner.LineCountDTO;
|
||||
import com.cool.store.entity.*;
|
||||
import com.cool.store.enums.LineStatusEnum;
|
||||
import com.cool.store.enums.WorkflowStageEnum;
|
||||
@@ -39,9 +39,11 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -208,25 +210,28 @@ public class EcSyncServiceImpl implements EcSyncService {
|
||||
hyPartnerLineInfoDAO.updateByPrimaryKeySelective(resultLine);
|
||||
}
|
||||
} else {
|
||||
EnterpriseUserDO enterpriseUser = enterpriseUserDAO.getUserInfoById(partnerLine.getInvestmentManager());
|
||||
enterpriseUser.setMobile(getNoWith86Number(enterpriseUser.getMobile()));
|
||||
//电话相同但是名字不同
|
||||
if (enterpriseUser.getMobile().equals(followUserMobile) && !enterpriseUser.getName().equals(followUserName)) {
|
||||
ChangeFollowUserRequest changeFollowUserRequest = new ChangeFollowUserRequest();
|
||||
ChangeFollowUserBo changeFollowUserBo = new ChangeFollowUserBo();
|
||||
changeFollowUserBo.setFollowUserId(customerInfoItem.getLastFollowUserId()).setCrmId(customerInfoItem.getCrmId())
|
||||
.setType(1).setUsername(enterpriseUser.getName()).setMobile(enterpriseUser.getMobile());
|
||||
changeFollowUserRequest.setParameter(changeFollowUserBo);
|
||||
ChangeFollowUserResponse changeFollowUserExec = ecClient.exec(baseUrl, changeFollowUserRequest);
|
||||
}
|
||||
//电话不同
|
||||
if (!enterpriseUser.getMobile().equals(followUserMobile)) {
|
||||
ChangeFollowUserRequest changeFollowUserRequest = new ChangeFollowUserRequest();
|
||||
ChangeFollowUserBo changeFollowUserBo = new ChangeFollowUserBo();
|
||||
changeFollowUserBo.setFollowUserId(customerInfoItem.getLastFollowUserId()).setCrmId(customerInfoItem.getCrmId())
|
||||
.setType(2).setUsername(enterpriseUser.getName()).setMobile(enterpriseUser.getMobile());
|
||||
changeFollowUserRequest.setParameter(changeFollowUserBo);
|
||||
ChangeFollowUserResponse changeFollowUserExec = ecClient.exec(baseUrl, changeFollowUserRequest);
|
||||
if (!getFollowLineStatus(partnerLine)) {
|
||||
//私海
|
||||
EnterpriseUserDO enterpriseUser = enterpriseUserDAO.getUserInfoById(partnerLine.getInvestmentManager());
|
||||
enterpriseUser.setMobile(getNoWith86Number(enterpriseUser.getMobile()));
|
||||
//电话相同但是名字不同
|
||||
if (enterpriseUser.getMobile().equals(followUserMobile) && !enterpriseUser.getName().equals(followUserName)) {
|
||||
ChangeFollowUserRequest changeFollowUserRequest = new ChangeFollowUserRequest();
|
||||
ChangeFollowUserBo changeFollowUserBo = new ChangeFollowUserBo();
|
||||
changeFollowUserBo.setFollowUserId(customerInfoItem.getLastFollowUserId()).setCrmId(customerInfoItem.getCrmId())
|
||||
.setType(1).setUsername(enterpriseUser.getName()).setMobile(enterpriseUser.getMobile());
|
||||
changeFollowUserRequest.setParameter(changeFollowUserBo);
|
||||
ChangeFollowUserResponse changeFollowUserExec = ecClient.exec(baseUrl, changeFollowUserRequest);
|
||||
}
|
||||
//电话不同
|
||||
if (!enterpriseUser.getMobile().equals(followUserMobile)) {
|
||||
ChangeFollowUserRequest changeFollowUserRequest = new ChangeFollowUserRequest();
|
||||
ChangeFollowUserBo changeFollowUserBo = new ChangeFollowUserBo();
|
||||
changeFollowUserBo.setFollowUserId(customerInfoItem.getLastFollowUserId()).setCrmId(customerInfoItem.getCrmId())
|
||||
.setType(2).setUsername(enterpriseUser.getName()).setMobile(enterpriseUser.getMobile());
|
||||
changeFollowUserRequest.setParameter(changeFollowUserBo);
|
||||
ChangeFollowUserResponse changeFollowUserExec = ecClient.exec(baseUrl, changeFollowUserRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
//base表
|
||||
@@ -257,10 +262,23 @@ public class EcSyncServiceImpl implements EcSyncService {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Integer a=null;
|
||||
System.out.println(a.equals("bb"));
|
||||
|
||||
/**
|
||||
*招商公海内跟进次数大于等于1的用户EC同步该用户进去公海,假若跟进次数为0的同步到EC跟进人就是唐佑玉
|
||||
* @param partnerLine
|
||||
* @return true为公海 false:私海
|
||||
*/
|
||||
public Boolean getFollowLineStatus(HyPartnerLineInfoDO partnerLine){
|
||||
if(partnerLine.getLineStatus()!=0){
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add(partnerLine.getPartnerId());
|
||||
List<LineCountDTO> followCountList = hyPartnerLineInfoDAO.getFollowCountList(list);
|
||||
if (!CollectionUtils.isEmpty(followCountList)) {
|
||||
return followCountList.get(0).getFollowCount()>0;
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,6 +36,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class LineHighSeasServiceImpl implements LineHighSeasService {
|
||||
@@ -145,6 +146,10 @@ public class LineHighSeasServiceImpl implements LineHighSeasService {
|
||||
String fileStr = ossServer.uploadFileServer(stream, dir + getExcelName());
|
||||
return new ResponseResult(500, "共上传" + lineDOList.size() + "条线索,其中" + styleCells.size() + "条存在异常", new ErrorExcelResponse(lineDOList.size(), styleCells.size(), fileStr));
|
||||
}
|
||||
//获取重复手机号集合
|
||||
List<String> uniqueList = lineDOList.stream().filter(item->StringUtil.isNotEmpty(item.getMobile())).collect(Collectors.groupingBy(HyPartnerLineDO::getMobile, Collectors.counting()))
|
||||
.entrySet().stream().filter(e -> e.getValue() > 1)
|
||||
.map(Map.Entry::getKey).collect(Collectors.toList());
|
||||
for (int i = 0; i < lineDOList.size(); i++) {
|
||||
HyPartnerLineDO hyPartnerLineDO = lineDOList.get(i);
|
||||
String partnerName = hyPartnerLineDO.getPartnerName();
|
||||
@@ -174,6 +179,11 @@ public class LineHighSeasServiceImpl implements LineHighSeasService {
|
||||
hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.MOBILE_EXIST : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.MOBILE_EXIST));
|
||||
ExcelUtil.setStyleMap(styleCells, i, 1, new String[]{ExcelUtil.FONT_RED});
|
||||
}
|
||||
//手机号重复
|
||||
if (uniqueList.contains(mobile)) {
|
||||
hyPartnerLineDO.setErrorInfo(StringUtil.isEmpty(hyPartnerLineDO.getErrorInfo()) ? ExcelErrorConstants.MOBILE_REPEAT : hyPartnerLineDO.getErrorInfo().concat(Constants.SEMICOLON).concat(ExcelErrorConstants.MOBILE_REPEAT));
|
||||
ExcelUtil.setStyleMap(styleCells, i, 1, new String[]{ExcelUtil.FONT_RED});
|
||||
}
|
||||
}
|
||||
//常驻区域为空
|
||||
String liveArea = hyPartnerLineDO.getLiveAreaReplace().trim();
|
||||
|
||||
Reference in New Issue
Block a user