Commit 96fff103 by 墨竹

Merge branch 'fixbug_0525' into developer

# Conflicts:
#	haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/StaffClerkRelationApiServiceImpl.java
parents b16bf3ec 489bfb20
......@@ -183,4 +183,15 @@ public interface DepartmentApiService {
*/
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 {
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
void del(String staffDepartmentStaffRelatedId);
......
......@@ -5,7 +5,6 @@ import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
public interface StaffMapper {
int deleteByPrimaryKey(String staffId);
......@@ -24,7 +23,12 @@ public interface StaffMapper {
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和企业标识
......
......@@ -82,7 +82,7 @@ public interface StaffClerkRelationService {
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 {
int countByDepartmentId(String departmentId);
/**
* 效率很低
* @param departmentId
* @param keyword
* @return
*/
@Deprecated
List<TabHaobanStaffDepartmentRelated> listByDepartmentIdByKeyword(List<String> departmentId, String keyword);
List<TabHaobanStaffDepartmentRelated> listByWxUserId(String wxUserId);
......
......@@ -5,7 +5,6 @@ import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.github.pagehelper.Page;
import java.util.List;
import java.util.Set;
public interface StaffService {
......@@ -15,7 +14,8 @@ public interface StaffService {
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);
......
......@@ -99,7 +99,7 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe
* @return
*/
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)) {
return null;
}
......
......@@ -138,7 +138,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
}
String staffId = staffClerkRelation.getStaffId();
String wxEnterpriseId = staffClerkRelation.getWxEnterpriseId();
List<StaffClerkRelationDTO> list = this.lisByStaffId(wxEnterpriseId, staffId);
List<StaffClerkRelationDTO> list = this.listByStaffId(wxEnterpriseId, staffId);
if (list != null && list.size() == 1) {
clerkMainStoreRelatedService.setMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId);
}
......@@ -240,7 +240,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
}
@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));
}
......
......@@ -16,7 +16,10 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
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;
@Service
......@@ -61,8 +64,8 @@ public class StaffServiceImpl implements StaffService {
}
@Override
public Page<TabHaobanStaff> pageStaff(Set<String> staffIds, Integer activeFlag, String keyword) {
return mapper.pageStaff(staffIds, activeFlag, 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,departmentIds,wxEnterpriseId,relationFlag);
}
@Override
......
......@@ -532,4 +532,21 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
List<DepartmentShortDTO> list = departmentService.listAllDepartment(wxEnterpriseId);
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;
}
}
......@@ -51,7 +51,6 @@ import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service
......@@ -211,46 +210,23 @@ public class StaffApiServiceImpl implements StaffApiService {
}
@Override
public Page<StaffDTO> pageStaff(List<String> departmentIds, Integer activeFlag, String keyword, BasePageInfo pageInfo, Integer relationFlag) {
// 部门 员工列表
List<TabHaobanStaffDepartmentRelated> list = staffDepartmentRelatedService.listByDepartmentIdByKeyword(departmentIds, keyword);
if (CollectionUtils.isEmpty(list)) {
return new Page<>();
public Page<StaffDTO> pageStaff(List<String> departmentIds, Integer activeFlag, String keyword, BasePageInfo pageInfo, Integer relationFlag,String wxEnterpriseId) {
List<String> staffIds = new ArrayList<>();
if (relationFlag != null) {
List<TabHaobanStaffClerkRelation> relationList = staffClerkRelationService.listByWxEnterpriseId(wxEnterpriseId);
staffIds = relationList.stream().map(TabHaobanStaffClerkRelation::getStaffId).collect(Collectors.toList());
}
// 当前部门的所有员工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());
Page<StaffDTO> page = PageUtil.changePageHelperToCurrentPage(staffService.pageStaff(queryStaffSet, activeFlag, ""), StaffDTO.class);
if (CollectionUtils.isEmpty(page.getResult())) {
Page<StaffDTO> page = PageUtil.changePageHelperToCurrentPage(staffService.pageStaff(staffIds, activeFlag, keyword,departmentIds,wxEnterpriseId,relationFlag), StaffDTO.class);
List<StaffDTO> staffDTOList = page.getResult();
if (CollectionUtils.isEmpty(staffDTOList)) {
return new Page<>();
}
Map<String, TabHaobanStaffDepartmentRelated> map = list.stream()
.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());
staffDTOList.forEach(one -> {
//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;
......
......@@ -276,20 +276,33 @@
<select id="pageStaff" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_staff
where status_flag = 1
from tab_haoban_staff a
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 != ''">
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 test="activeFlag != null">
and active_flag = #{activeFlag}
and a.active_flag = #{activeFlag}
</if>
<if test="staffIds != null and staffIds.size() > 0">
and staff_id IN
<if test="staffIds != null and staffIds.size() > 0 and relationFlag != null and relationFlag == 1 ">
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=",">
#{id,jdbcType=VARCHAR}
</foreach>
</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
</select>
<select id="listByIds" resultMap="BaseResultMap">
......
......@@ -145,11 +145,11 @@ public class StaffController extends WebBaseController {
return this.resultResponse(HaoBanErrCode.ERR_10030) ;
}
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
// 部门
List<DepartmentDTO> sonDepartmentList = departmentApiService.listSonByDepartmentIds(Lists.newArrayList(departmentId), login.getWxEnterpriseId());
List<String> departmentIds = sonDepartmentList.stream().map(DepartmentDTO::getDepartmentId).collect(Collectors.toList());
List<String> departmentIds = departmentApiService.listSonDeptIdsByDepartmentId(departmentId, wxEnterpriseId);
//员工
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());
......@@ -470,7 +470,7 @@ public class StaffController extends WebBaseController {
int pageNum = 1;
while (true) {
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();
if (CollectionUtils.isEmpty(list)) {
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