Commit 29dc0bae by 13003003657

修改离职员工分配bug

1 parent 171a02a9
package com.linkwechat.wecom.domain;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
......@@ -25,7 +26,7 @@ public class WeCorpAccount extends BaseEntity
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
private Long id= SnowFlakeUtil.nextId();
/** 企业名称 */
@ApiModelProperty("企业名称")
......
......@@ -28,7 +28,7 @@ public class WeCustomer extends BaseEntity
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id= SnowFlakeUtil.nextId();;
private Long id= SnowFlakeUtil.nextId();
/** 外部联系人的userid */
private String externalUserid;
......
package com.linkwechat.wecom.domain;
import com.linkwechat.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author: Robin
......@@ -9,10 +12,13 @@ import lombok.Data;
* @Date: create in 2020/9/21 0021 23:55
*/
@Data
public class WeGroup extends BaseEntity {
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class WeGroup extends BaseEntity {
private static final long serialVersionUID = 1L;
private Long id;
private Long id= SnowFlakeUtil.nextId();
private String groupName;
......
......@@ -66,4 +66,12 @@ public interface WeFlowerCustomerRelMapper
* @return
*/
public int batchInsetWeFlowerCustomerRel(List<WeFlowerCustomerRel> WeFlowerCustomerRels);
/**
* 批量逻辑删除
* @param ids
* @return
*/
public int batchLogicDeleteByIds(List<Long> ids);
}
......@@ -21,4 +21,8 @@ public interface WeGroupMapper {
int deleteWeGroupById(Long paramLong);
int deleteWeGroupByIds(Long[] paramArrayOfLong);
int batchLogicDeleteByIds(List<Long> ids);
int batchInsetWeGroup(List<WeGroup> weGroups);
}
......@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service;
import java.util.List;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
/**
* 企业微信客户Service接口
......@@ -65,4 +66,11 @@ public interface IWeCustomerService
* @return
*/
public void synchWeCustomer();
/**
* 分配离职员工客户
* @param weLeaveUserInfoAllocateVo
*/
public void allocateWeCustomer(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo);
}
......@@ -67,4 +67,13 @@ public interface IWeFlowerCustomerRelService
* @return
*/
public int batchInsetWeFlowerCustomerRel(List<WeFlowerCustomerRel> WeFlowerCustomerRels);
/**
* 批量逻辑删除
* @param ids
* @return
*/
public int batchLogicDeleteByIds(List<Long> ids);
}
package com.linkwechat.wecom.service;
import com.linkwechat.wecom.domain.WeGroup;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
import java.util.List;
......@@ -21,4 +22,10 @@ public interface IWeGroupService {
int deleteWeGroupByIds(Long[] paramArrayOfLong);
int deleteWeGroupById(Long paramLong);
int batchLogicDeleteByIds(List<Long> ids);
int batchInsetWeGroup(List<WeGroup> weGroups);
void allocateWeGroup(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo);
}
......@@ -2,17 +2,20 @@ package com.linkwechat.wecom.service.impl;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ArrayUtil;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.wecom.client.WeCustomerClient;
import com.linkwechat.wecom.client.WeUserClient;
import com.linkwechat.wecom.domain.WeFlowerCustomerRel;
import com.linkwechat.wecom.domain.dto.WeCustomerDto;
import com.linkwechat.wecom.domain.dto.WeFollowUserDto;
import com.linkwechat.wecom.domain.dto.WeUserDto;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
import com.linkwechat.wecom.service.IWeFlowerCustomerRelService;
import com.linkwechat.wecom.service.IWeFlowerCustomerTagRelService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -20,6 +23,7 @@ import org.springframework.stereotype.Service;
import com.linkwechat.wecom.mapper.WeCustomerMapper;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.service.IWeCustomerService;
import org.springframework.transaction.annotation.Transactional;
/**
* 企业微信客户Service业务层处理
......@@ -42,8 +46,7 @@ public class WeCustomerServiceImpl implements IWeCustomerService
private WeUserClient weUserClient;
@Autowired
private IWeFlowerCustomerTagRelService iWeFlowerCustomerTagRelService;
@Autowired
......@@ -182,6 +185,31 @@ public class WeCustomerServiceImpl implements IWeCustomerService
}
/**
* 分配离职员工客户
* @param weLeaveUserInfoAllocateVo
*/
@Override
@Transactional
public void allocateWeCustomer(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo) {
//分配客户
List<WeFlowerCustomerRel> weFlowerCustomerRels = iWeFlowerCustomerRelService.selectWeFlowerCustomerRelList(WeFlowerCustomerRel.builder()
.userId(weLeaveUserInfoAllocateVo.getHandoverUserid())
.build());
if(CollectionUtil.isNotEmpty(weFlowerCustomerRels)){
//删除原有的
iWeFlowerCustomerRelService.batchLogicDeleteByIds(weFlowerCustomerRels.stream().map(WeFlowerCustomerRel::getId).collect(Collectors.toList()));
//保存新的
weFlowerCustomerRels.stream().forEach(k->{
k.setId(SnowFlakeUtil.nextId());
k.setUserId(weLeaveUserInfoAllocateVo.getTakeoverUserid());
});
//保存新
iWeFlowerCustomerRelService.batchInsetWeFlowerCustomerRel(weFlowerCustomerRels);
}
}
}
......@@ -103,4 +103,15 @@ public class WeFlowerCustomerRelServiceImpl implements IWeFlowerCustomerRelServi
public int batchInsetWeFlowerCustomerRel(List<WeFlowerCustomerRel> WeFlowerCustomerRels) {
return weFlowerCustomerRelMapper.batchInsetWeFlowerCustomerRel(WeFlowerCustomerRels);
}
/**
* 批量逻辑删除
* @param ids
* @return
*/
@Override
public int batchLogicDeleteByIds(List<Long> ids) {
return weFlowerCustomerRelMapper.batchLogicDeleteByIds(ids);
}
}
package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.wecom.domain.WeGroup;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
import com.linkwechat.wecom.mapper.WeGroupMapper;
import com.linkwechat.wecom.service.IWeGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author: Robin
......@@ -43,4 +48,54 @@ public class WeGroupServiceImpl implements IWeGroupService {
public int deleteWeGroupById(Long id) {
return this.weGroupMapper.deleteWeGroupById(id);
}
/**
* 逻辑批量删除
* @param ids
*/
@Override
public int batchLogicDeleteByIds(List<Long> ids) {
return weGroupMapper.batchLogicDeleteByIds(ids);
}
/**
* 批量保存
* @param weGroups
* @return
*/
@Override
public int batchInsetWeGroup(List<WeGroup> weGroups) {
return weGroupMapper.batchInsetWeGroup(weGroups);
}
/**
* 离职员工群分配
* @param weLeaveUserInfoAllocateVo
* @return
*/
@Override
@Transactional
public void allocateWeGroup(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo) {
//分配群
List<WeGroup> weGroups = this.selectWeGroupList(WeGroup.builder()
.groupLeaderUserId(weLeaveUserInfoAllocateVo.getHandoverUserid())
.build());
if(CollectionUtil.isNotEmpty(weGroups)){
this.batchLogicDeleteByIds(
weGroups.stream().map(WeGroup::getId).collect(Collectors.toList())
);
weGroups.stream().forEach(k->{
k.setId(SnowFlakeUtil.nextId());
k.setGroupLeaderUserId(weLeaveUserInfoAllocateVo.getTakeoverUserid());
});
this.batchInsetWeGroup(weGroups);
}
}
}
......@@ -6,18 +6,24 @@ import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.wecom.client.WeUserClient;
import com.linkwechat.wecom.domain.WeFlowerCustomerRel;
import com.linkwechat.wecom.domain.WeGroup;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
import com.linkwechat.wecom.domain.vo.WeLeaveUserVo;
import com.linkwechat.wecom.mapper.WeUserMapper;
import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeFlowerCustomerRelService;
import com.linkwechat.wecom.service.IWeGroupService;
import com.linkwechat.wecom.service.IWeUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
* 通讯录相关客户Service业务层处理
......@@ -36,8 +42,13 @@ public class WeUserServiceImpl implements IWeUserService
private WeUserClient weUserClient;
@Autowired
private IWeFlowerCustomerRelService iWeFlowerCustomerRelService;
private IWeCustomerService iWeCustomerService;
@Autowired
private IWeGroupService iWeGroupService;
/**
* 查询通讯录相关客户
......@@ -178,23 +189,23 @@ public class WeUserServiceImpl implements IWeUserService
return this.weUserMapper.leaveUserList(weLeaveUserVo);
}
/**
* 分配离职员工相关数据
* @param weLeaveUserInfoAllocateVo
*/
@Override
@Transactional(isolation= Isolation.DEFAULT,propagation= Propagation.REQUIRED,rollbackFor = Exception.class)
public void allocateLeaveUserAboutData(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo) {
List<WeFlowerCustomerRel> weFlowerCustomerRels = iWeFlowerCustomerRelService.selectWeFlowerCustomerRelList(WeFlowerCustomerRel.builder()
.userId(weLeaveUserInfoAllocateVo.getHandoverUserid())
.build());
if(CollectionUtil.isNotEmpty(weFlowerCustomerRels)){
//删除原有的
//保存新的
weFlowerCustomerRels.stream().forEach(k->{
k.setId(SnowFlakeUtil.nextId());
k.setUserId(weLeaveUserInfoAllocateVo.getTakeoverUserid());
});
//保存新
try {
//分配客户
iWeCustomerService.allocateWeCustomer(weLeaveUserInfoAllocateVo);
//分配群组
iWeGroupService.allocateWeGroup(weLeaveUserInfoAllocateVo);
}catch (Exception e){
throw new WeComException(e.getMessage());
}
}
......
......@@ -108,5 +108,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
(#{tag.id},#{tag.userId},#{tag.remark},#{tag.description},#{tag.createTime},#{tag.remarkCorpName},#{tag.remarkMobiles},#{tag.operUserid},#{tag.addWay},#{tag.state},#{tag.customerId})
</foreach>
</insert>
<update id="batchLogicDeleteByIds" parameterType="String">
update we_flower_customer_rel set del_flag=2
where id in
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>
\ No newline at end of file
......@@ -80,4 +80,20 @@
</foreach>
</delete>
<update id="batchLogicDeleteByIds" parameterType="String">
update we_group set del_flag=2
where id in
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<insert id="batchInsetWeGroup" >
insert into we_group (id, group_name, member_num, group_leader, create_time, notice, group_leader_user_id)
values
<foreach collection="weGroups" item="weGroup" index="index" separator=",">
(#{weGroup.id},#{weGroup.groupName},#{weGroup.memberNum},#{weGroup.groupLeader},#{weGroup.createTime},#{weGroup.notice},#{weGroup.groupLeaderUserId})
</foreach>
</insert>
</mapper>
\ No newline at end of file
......@@ -172,5 +172,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!