Commit 489bfb20 by 墨竹

feat:通讯录修改

parent 51629c18
...@@ -183,4 +183,15 @@ public interface DepartmentApiService { ...@@ -183,4 +183,15 @@ public interface DepartmentApiService {
*/ */
List<DepartmentShortDTO> listAllDepartment(String wxEnterpriseId); List<DepartmentShortDTO> listAllDepartment(String wxEnterpriseId);
/**
* 获取子部门ids
*
* @param departmentId 部门id设置
* @param wxEnterpriseId wx企业标识
* @return {@link List }<{@link String }>
* @author mozhu
* @date 2022-05-24 17:45:57
*/
List<String> listSonDeptIdsByDepartmentId(String departmentId, String wxEnterpriseId);
} }
...@@ -23,7 +23,8 @@ public interface StaffApiService { ...@@ -23,7 +23,8 @@ public interface StaffApiService {
List<StaffDepartmentRelatedDTO> listStaffDepartmentByStaffId(String staffId); List<StaffDepartmentRelatedDTO> listStaffDepartmentByStaffId(String staffId);
Page<StaffDTO> pageStaff(List<String> departmentId, Integer activeFlag, String keyword, BasePageInfo pageInfo, Integer relationFlag); Page<StaffDTO> pageStaff(List<String> departmentId, Integer activeFlag,
String keyword, BasePageInfo pageInfo, Integer relationFlag,String wxEnterpriseId);
@Deprecated @Deprecated
void del(String staffDepartmentStaffRelatedId); void del(String staffDepartmentStaffRelatedId);
......
...@@ -5,7 +5,6 @@ import com.github.pagehelper.Page; ...@@ -5,7 +5,6 @@ import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Set;
public interface StaffMapper { public interface StaffMapper {
int deleteByPrimaryKey(String staffId); int deleteByPrimaryKey(String staffId);
...@@ -24,7 +23,12 @@ public interface StaffMapper { ...@@ -24,7 +23,12 @@ public interface StaffMapper {
List<TabHaobanStaff> listLikeName(@Param("staffName") String staffName, @Param("wxEnterpriseId") String wxEnterpriseId); List<TabHaobanStaff> listLikeName(@Param("staffName") String staffName, @Param("wxEnterpriseId") String wxEnterpriseId);
Page<TabHaobanStaff> pageStaff(@Param("staffIds") Set<String> staffIds, @Param("activeFlag") Integer activeFlag, @Param("keyword") String keyword); Page<TabHaobanStaff> pageStaff(@Param("staffIds") List<String> staffIds,
@Param("activeFlag") Integer activeFlag,
@Param("keyword") String keyword,
@Param("departmentIds") List<String> departmentIds,
@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("relationFlag") Integer relationFlag);
/** /**
* 选择用户id和企业标识 * 选择用户id和企业标识
......
...@@ -82,7 +82,7 @@ public interface StaffClerkRelationService { ...@@ -82,7 +82,7 @@ public interface StaffClerkRelationService {
List<StaffClerkRelationDTO> listByClerkIds(List<String> clerkList); List<StaffClerkRelationDTO> listByClerkIds(List<String> clerkList);
List<StaffClerkRelationDTO> lisByStaffId(String wxEnterpriseId, String staffId); List<StaffClerkRelationDTO> listByStaffId(String wxEnterpriseId, String staffId);
/** /**
* 保存 * 保存
......
...@@ -23,6 +23,13 @@ public interface StaffDepartmentRelatedService { ...@@ -23,6 +23,13 @@ public interface StaffDepartmentRelatedService {
int countByDepartmentId(String departmentId); int countByDepartmentId(String departmentId);
/**
* 效率很低
* @param departmentId
* @param keyword
* @return
*/
@Deprecated
List<TabHaobanStaffDepartmentRelated> listByDepartmentIdByKeyword(List<String> departmentId, String keyword); List<TabHaobanStaffDepartmentRelated> listByDepartmentIdByKeyword(List<String> departmentId, String keyword);
List<TabHaobanStaffDepartmentRelated> listByWxUserId(String wxUserId); List<TabHaobanStaffDepartmentRelated> listByWxUserId(String wxUserId);
......
...@@ -5,7 +5,6 @@ import com.gic.haoban.manage.service.entity.TabHaobanStaff; ...@@ -5,7 +5,6 @@ import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import java.util.List; import java.util.List;
import java.util.Set;
public interface StaffService { public interface StaffService {
...@@ -15,7 +14,8 @@ public interface StaffService { ...@@ -15,7 +14,8 @@ public interface StaffService {
String add(TabHaobanStaff tab); String add(TabHaobanStaff tab);
Page<TabHaobanStaff> pageStaff(Set<String> staffIds, Integer activeFlag, String keyword); Page<TabHaobanStaff> pageStaff(List<String> staffIds, Integer activeFlag,
String keyword,List<String> departmentIds,String wxEnterpriseId,Integer relationFlag);
void updateByPrimaryKey(TabHaobanStaff tab); void updateByPrimaryKey(TabHaobanStaff tab);
......
...@@ -99,7 +99,7 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe ...@@ -99,7 +99,7 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe
* @return * @return
*/ */
private TabHaobanClerkMainStoreRelated setStaffMainStore(String staffId, String wxEnterpriseId) { private TabHaobanClerkMainStoreRelated setStaffMainStore(String staffId, String wxEnterpriseId) {
List<StaffClerkRelationDTO> clerkRelationDTOS = staffClerkRelationService.lisByStaffId(wxEnterpriseId, staffId); List<StaffClerkRelationDTO> clerkRelationDTOS = staffClerkRelationService.listByStaffId(wxEnterpriseId, staffId);
if (CollectionUtils.isEmpty(clerkRelationDTOS)) { if (CollectionUtils.isEmpty(clerkRelationDTOS)) {
return null; return null;
} }
......
...@@ -138,7 +138,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService ...@@ -138,7 +138,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
} }
String staffId = staffClerkRelation.getStaffId(); String staffId = staffClerkRelation.getStaffId();
String wxEnterpriseId = staffClerkRelation.getWxEnterpriseId(); String wxEnterpriseId = staffClerkRelation.getWxEnterpriseId();
List<StaffClerkRelationDTO> list = this.lisByStaffId(wxEnterpriseId, staffId); List<StaffClerkRelationDTO> list = this.listByStaffId(wxEnterpriseId, staffId);
if (list != null && list.size() == 1) { if (list != null && list.size() == 1) {
clerkMainStoreRelatedService.setMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId); clerkMainStoreRelatedService.setMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId);
} }
...@@ -240,7 +240,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService ...@@ -240,7 +240,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
} }
@Override @Override
public List<StaffClerkRelationDTO> lisByStaffId(String wxEnterpriseId, String staffId) { public List<StaffClerkRelationDTO> listByStaffId(String wxEnterpriseId, String staffId) {
return EntityUtil.changeEntityListByJSON(StaffClerkRelationDTO.class, mapper.lisByStaffId(wxEnterpriseId, staffId)); return EntityUtil.changeEntityListByJSON(StaffClerkRelationDTO.class, mapper.lisByStaffId(wxEnterpriseId, staffId));
} }
......
...@@ -16,7 +16,10 @@ import org.apache.logging.log4j.Logger; ...@@ -16,7 +16,10 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -61,8 +64,8 @@ public class StaffServiceImpl implements StaffService { ...@@ -61,8 +64,8 @@ public class StaffServiceImpl implements StaffService {
} }
@Override @Override
public Page<TabHaobanStaff> pageStaff(Set<String> staffIds, Integer activeFlag, String keyword) { public Page<TabHaobanStaff> pageStaff(List<String> staffIds, Integer activeFlag, String keyword,List<String> departmentIds,String wxEnterpriseId,Integer relationFlag) {
return mapper.pageStaff(staffIds, activeFlag, keyword); return mapper.pageStaff(staffIds, activeFlag, keyword,departmentIds,wxEnterpriseId,relationFlag);
} }
@Override @Override
......
...@@ -532,4 +532,21 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -532,4 +532,21 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
List<DepartmentShortDTO> list = departmentService.listAllDepartment(wxEnterpriseId); List<DepartmentShortDTO> list = departmentService.listAllDepartment(wxEnterpriseId);
return list; return list;
} }
@Override
public List<String> listSonDeptIdsByDepartmentId(String departmentId, String wxEnterpriseId) {
List<String> list = new ArrayList<>();
String chainId = "";
TabHaobanDepartment department = departmentService.selectById(departmentId);
if (department != null) {
chainId = department.getChainId() + Constant.ID_SEPARATOR + departmentId;
}
list.add(departmentId);
if (StringUtils.isNotBlank(chainId)) {
List<TabHaobanDepartment> tabList = departmentService.listByChainId(chainId, wxEnterpriseId);
List<String> departmentIds = tabList.stream().map(TabHaobanDepartment::getDepartmentId).collect(Collectors.toList());
list.addAll(departmentIds);
}
return list;
}
} }
...@@ -46,7 +46,6 @@ import org.springframework.stereotype.Service; ...@@ -46,7 +46,6 @@ import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -198,46 +197,23 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -198,46 +197,23 @@ public class StaffApiServiceImpl implements StaffApiService {
} }
@Override @Override
public Page<StaffDTO> pageStaff(List<String> departmentIds, Integer activeFlag, String keyword, BasePageInfo pageInfo, Integer relationFlag) { public Page<StaffDTO> pageStaff(List<String> departmentIds, Integer activeFlag, String keyword, BasePageInfo pageInfo, Integer relationFlag,String wxEnterpriseId) {
// 部门 员工列表 List<String> staffIds = new ArrayList<>();
List<TabHaobanStaffDepartmentRelated> list = staffDepartmentRelatedService.listByDepartmentIdByKeyword(departmentIds, keyword); if (relationFlag != null) {
List<TabHaobanStaffClerkRelation> relationList = staffClerkRelationService.listByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isEmpty(list)) { staffIds = relationList.stream().map(TabHaobanStaffClerkRelation::getStaffId).collect(Collectors.toList());
return new Page<>();
} }
// 当前部门的所有员工id列表
Set<String> staffIdSet = list.stream().map(TabHaobanStaffDepartmentRelated::getStaffId).collect(Collectors.toSet());
// 查询当前部门所有已关联导购的员工id列表
List<String> relationsStaffIdList = staffClerkRelationService.listRelationsStaffId(staffIdSet);
Set<String> relationStaffSet = new HashSet<>(relationsStaffIdList);
logger.info("已关联的员工id列表:{}", JSON.toJSONString(relationStaffSet));
Set<String> queryStaffSet = filterByRelationFlag(staffIdSet, relationStaffSet, relationFlag);
if (CollectionUtils.isEmpty(queryStaffSet)) {
return new Page<>();
}
// 分页
PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize()); PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
Page<StaffDTO> page = PageUtil.changePageHelperToCurrentPage(staffService.pageStaff(queryStaffSet, activeFlag, ""), StaffDTO.class); Page<StaffDTO> page = PageUtil.changePageHelperToCurrentPage(staffService.pageStaff(staffIds, activeFlag, keyword,departmentIds,wxEnterpriseId,relationFlag), StaffDTO.class);
List<StaffDTO> staffDTOList = page.getResult();
if (CollectionUtils.isEmpty(page.getResult())) { if (CollectionUtils.isEmpty(staffDTOList)) {
return new Page<>(); return new Page<>();
} }
staffDTOList.forEach(one -> {
Map<String, TabHaobanStaffDepartmentRelated> map = list.stream() //one.setDepartmentIds(Objects.isNull(related) ? null : related.getDepartmentId());
.collect(Collectors.toMap(TabHaobanStaffDepartmentRelated::getStaffId, Function.identity(), (s1, s2) -> s2));
page.getResult().forEach(one -> {
TabHaobanStaffDepartmentRelated related = map.get(one.getStaffId());
one.setDepartmentIds(Objects.isNull(related) ? null : related.getDepartmentId());
// 关联状态 // 关联状态
one.setRelationFlag(relationStaffSet.contains(one.getStaffId()) ? 1 : 0); List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listByStaffId(wxEnterpriseId, one.getStaffId());
one.setRelationFlag(CollectionUtils.isNotEmpty(staffClerkRelationDTOS) ? 1 : 0);
}); });
return page; return page;
......
...@@ -405,7 +405,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -405,7 +405,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
} }
String staffId = staffClerkRelation.getStaffId(); String staffId = staffClerkRelation.getStaffId();
String wxEnterpriseId = staffClerkRelation.getWxEnterpriseId(); String wxEnterpriseId = staffClerkRelation.getWxEnterpriseId();
List<StaffClerkRelationDTO> list = staffClerkRelatinService.lisByStaffId(wxEnterpriseId, staffId); List<StaffClerkRelationDTO> list = staffClerkRelatinService.listByStaffId(wxEnterpriseId, staffId);
if (list != null && list.size() == 1) { if (list != null && list.size() == 1) {
clerkMainStoreRelatedService.setMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId); clerkMainStoreRelatedService.setMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId);
} }
......
...@@ -275,20 +275,33 @@ ...@@ -275,20 +275,33 @@
<select id="pageStaff" resultMap="BaseResultMap"> <select id="pageStaff" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from tab_haoban_staff from tab_haoban_staff a
where status_flag = 1 left join tab_haoban_staff_department_related b on a.staff_id = b.staff_id
where a.status_flag = 1 and a.wx_enterprise_id = #{wxEnterpriseId}
<if test="keyword != null and keyword != ''"> <if test="keyword != null and keyword != ''">
and (staff_name like CONCAT('%',#{keyword},'%') or phone_number like CONCAT('%',#{keyword},'%')) and (a.staff_name like CONCAT('%',#{keyword},'%') or a.phone_number like CONCAT('%',#{keyword},'%'))
</if> </if>
<if test="activeFlag != null"> <if test="activeFlag != null">
and active_flag = #{activeFlag} and a.active_flag = #{activeFlag}
</if> </if>
<if test="staffIds != null and staffIds.size() > 0"> <if test="staffIds != null and staffIds.size() > 0 and relationFlag != null and relationFlag == 1 ">
and staff_id IN and a.staff_id IN
<foreach collection="staffIds" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR}
</foreach>
</if>
<if test="staffIds != null and staffIds.size() > 0 and relationFlag != null and relationFlag == 0 ">
and a.staff_id not in
<foreach collection="staffIds" item="id" index="index" open="(" close=")" separator=","> <foreach collection="staffIds" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR} #{id,jdbcType=VARCHAR}
</foreach> </foreach>
</if> </if>
<if test="departmentIds != null and departmentIds.size() > 0">
and b.department_id IN
<foreach collection="departmentIds" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR}
</foreach>
</if>
order by create_time desc order by create_time desc
</select> </select>
<select id="listByIds" resultMap="BaseResultMap"> <select id="listByIds" resultMap="BaseResultMap">
......
...@@ -135,11 +135,11 @@ public class StaffController extends WebBaseController { ...@@ -135,11 +135,11 @@ public class StaffController extends WebBaseController {
String keyWord, String keyWord,
BasePageInfo pageInfo) { BasePageInfo pageInfo) {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser(); WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
// 部门 // 部门
List<DepartmentDTO> sonDepartmentList = departmentApiService.listSonByDepartmentIds(Lists.newArrayList(departmentId), login.getWxEnterpriseId()); List<String> departmentIds = departmentApiService.listSonDeptIdsByDepartmentId(departmentId, wxEnterpriseId);
List<String> departmentIds = sonDepartmentList.stream().map(DepartmentDTO::getDepartmentId).collect(Collectors.toList());
//员工 //员工
Page<StaffDTO> page = staffApiService.pageStaff(departmentIds, activeFlag, keyWord, pageInfo, relationFlag); Page<StaffDTO> page = staffApiService.pageStaff(departmentIds, activeFlag, keyWord, pageInfo, relationFlag,wxEnterpriseId);
logger.info("pages={},totalPage={}", page.getCurrentPage(), page.getTotalPage()); logger.info("pages={},totalPage={}", page.getCurrentPage(), page.getTotalPage());
...@@ -492,7 +492,7 @@ public class StaffController extends WebBaseController { ...@@ -492,7 +492,7 @@ public class StaffController extends WebBaseController {
int pageNum = 1; int pageNum = 1;
while (true) { while (true) {
pageInfo.setPageNum(pageNum); pageInfo.setPageNum(pageNum);
Page<StaffDTO> page = staffApiService.pageStaff(departmentIds, activeFlag, keyWord, pageInfo, relationFlag); Page<StaffDTO> page = staffApiService.pageStaff(departmentIds, activeFlag, keyWord, pageInfo, relationFlag,wxEnterpriseId);
List<StaffDTO> list = page.getResult(); List<StaffDTO> list = page.getResult();
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
break; break;
......
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