Commit b426ea21 by 徐高华

离职继承

parent 9c1203b0
......@@ -121,4 +121,6 @@ public interface HandoverService {
*/
public List<HandoverStaffFriendCountDTO> listFriendCountByWxStaffIds(String wxEnterpriseId, List<String> staffIds);
Boolean filterHandoverStaff(String wxEnterpriseId, String wxUserId);
public void delHandoverStaff(String wxEnterpriseId, List<String> wxUserIds) ;
}
......@@ -85,7 +85,6 @@ public class HandoverServiceImpl implements HandoverService {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if (CollectionUtils.isEmpty(infoList)) {
logger.info("没有要保存的数据,删除所有需要删除逇");
// delHandoverStaff(wxEnterpriseId, null);
return false;
}
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(qwDTO.getWxEnterpriseId(), SecretTypeEnum.CUSTOMIZED_APP.getVal());
......@@ -127,20 +126,6 @@ public class HandoverServiceImpl implements HandoverService {
handoverExternalMapper.insertBatch(needAdd);
}
});
//删除不需要的staff数据
/*List<TabHandoverStaff> handoverStaffList = handoverStaffMapper.listByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isEmpty(handoverStaffList)) {
logger.info("没有新数据,无需删除");
return true;
}
Set<String> hasWxUserIds = handoverStaffList.stream().map(dto -> dto.getHandoverUserId()).collect(Collectors.toSet());
Sets.SetView<String> needDelUserIds = Sets.difference(hasWxUserIds, handoverUserMap.keySet());
if (CollectionUtils.isEmpty(needDelUserIds)) {
logger.info("没有新数据,无需删除2");
return true;
}
logger.info("删除数据");
delHandoverStaff(wxEnterpriseId, new ArrayList<>(needDelUserIds));*/
return false;
}
......@@ -158,7 +143,7 @@ public class HandoverServiceImpl implements HandoverService {
* @param wxEnterpriseId
* @param wxUserIds
*/
private void delHandoverStaff(String wxEnterpriseId, List<String> wxUserIds) {
public void delHandoverStaff(String wxEnterpriseId, List<String> wxUserIds) {
handoverStaffMapper.delByUserIds(wxEnterpriseId, wxUserIds);
handoverExternalMapper.delNoTransferExternal(wxUserIds, wxEnterpriseId);
}
......
......@@ -10,6 +10,7 @@ import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.service.HandoverOperationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.HandoverStaffMapper;
import com.gic.haoban.manage.service.entity.TabHandoverExternal;
import com.gic.haoban.manage.service.entity.TabHandoverStaff;
import com.gic.haoban.manage.service.entity.TabHandoverTransfer;
......@@ -23,6 +24,7 @@ import com.gic.wechat.api.dto.qywx.QywxUnassignedInfoDTO;
import com.gic.wechat.api.dto.qywx.response.QywxGetUnassignedListDTO;
import com.gic.wechat.api.dto.qywx.response.QywxTransferCustomerDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
......@@ -53,7 +55,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
@Autowired
private WxEnterpriseService wxEnterpriseService;
@Autowired
private Config config;
private HandoverStaffMapper handoverStaffMapper;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
......@@ -100,10 +102,11 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
private List<QywxUnassignedInfoDTO> getAllQywxUnassigned(String wxEnterpriseId) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
//这里改成LinkedList,避免使用ArrayList导致频繁扩容,从而减少内存的浪费
List<QywxUnassignedInfoDTO> ret = new LinkedList<>();
List<QywxUnassignedInfoDTO> retList = new LinkedList<>();
QywxGetUnassignedListDTO unassignedListDTO = null;
String cursor = null;
Map<String,Boolean> map = new HashMap<>() ;
Set<String> leaveStaffSet = new HashSet<>() ;
do {
//离职成员客户列表
unassignedListDTO = qywxUserApiService.getUnassignedList(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), cursor , qwDTO.isSelf(),qwDTO.getUrlHost());
......@@ -116,20 +119,34 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
String handoverUserid = dto.getHandoverUserid();
Boolean flag = map.get(handoverUserid) ;
if(null == flag) {
leaveStaffSet.add(handoverUserid) ;
flag = handoverService.filterHandoverStaff(wxEnterpriseId, handoverUserid) ;
map.put(handoverUserid,flag) ;
}
if (flag) {
ret.add(dto);
retList.add(dto);
}
}
}
} while (StringUtils.isNotBlank(cursor) && unassignedListDTO.getErrcode() == 0);
if (CollectionUtils.isEmpty(ret)) {
return ret;
//删除不需要的staff数据
List<TabHandoverStaff> handoverStaffList = handoverStaffMapper.listByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isNotEmpty(handoverStaffList) && CollectionUtils.isNotEmpty(leaveStaffSet)) {
Set<String> hasWxUserIds = handoverStaffList.stream().map(dto -> dto.getHandoverUserId()).collect(Collectors.toSet());
Sets.SetView<String> needDelUserIds = Sets.difference(hasWxUserIds, leaveStaffSet);
if (CollectionUtils.isNotEmpty(needDelUserIds)) {
logger.info("需要删除的离职人={}",needDelUserIds);
this.handoverService.delHandoverStaff(wxEnterpriseId, new ArrayList<>(needDelUserIds));
}
}
if (CollectionUtils.isEmpty(retList)) {
logger.info("无待处理的离职继承数");
return retList;
}
logger.info("无待处理的离职继承数={}",retList.size());
//去重
return ret.stream().collect(
return retList.stream().collect(
Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(dto -> {
return dto.getExternalUserid() + dto.getHandoverUserid();
......
......@@ -5,6 +5,7 @@ import com.gic.haoban.manage.api.dto.chat.GroupChatPlanDTO;
import com.gic.haoban.manage.api.dto.notify.qdto.NoticeMessageQDTO;
import com.gic.haoban.manage.api.dto.notify.qdto.NotifyMessageBatchQDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.service.HandoverOperationApiService;
import com.gic.haoban.manage.api.service.QywxTagApiService;
import com.gic.haoban.manage.api.service.notify.NoticeMessageApiService;
import com.gic.haoban.manage.service.config.Config;
......@@ -33,19 +34,11 @@ public class ChatTest {
private static Logger logger = LoggerFactory.getLogger(ChatTest.class);
@Autowired
private GroupChatPlanService groupChatPlanService;
private HandoverOperationApiService handoverOperationApiService;
@Test
public void test() {
String str = "{\"name\":\"测试\",\"remark\":\"测试\",\"expireDays\":\"2\",\"sendType\":1,\"sendTime\":\"\",\"chatContent\":\"[{\\\"img\\\":\\\"https://platform-1251519181.cos.ap-shanghai.myqcloud.com/image/jhdm/marketing_common-edc68cbf153846928c0ac28e2b2aa92f.jpg\\\",\\\"relation_id\\\":\\\"510923843246776342\\\",\\\"type\\\":2},{\\\"img\\\":\\\"https://platform-1251519181.cos.ap-shanghai.myqcloud.com/image/jhdm/marketing_common-3acc9bc9bbe8416e8aefe459b23eea5e.jpg\\\",\\\"relation_id\\\":\\\"510923843246776342\\\",\\\"type\\\":2},{\\\"content\\\":\\\"莎啦啦啦🐮\\\",\\\"relation_id\\\":\\\"510923843246776342\\\",\\\"type\\\":1}]\",\"staffIdList\":\"36067cdee7ba4ff6adc7551b34cc2005\",\"requestProject\":\"haoban-manage-web\"}";
GroupChatPlanDTO groupChatPlanDTO = JSONObject.parseObject(str, GroupChatPlanDTO.class);
groupChatPlanDTO.setWxEnterpriseId("ca66a01b79474c40b3e7c7f93daf1a3b");
groupChatPlanDTO.setEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000");
groupChatPlanDTO.setCreatorId("fefd1c81641711e69d0818c58a146fd2");
groupChatPlanDTO.setCreatorName("达摩管理员");
groupChatPlanDTO.setMaterialFrom(2);
groupChatPlanService.save(groupChatPlanDTO);
this.handoverOperationApiService.dealQywxEnterpriseHandover("ca66a01b79474c40b3e7c7f93daf1a3b") ;
}
@Test
......
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