Commit 269abff9 by 墨竹

fix:员工列表超时接口优化

parent 30083c62
......@@ -100,6 +100,8 @@ public class StaffDTO implements Serializable {
private String defaultGicEid;
private Integer addNum;
private Integer activeStatus;
private String enterpriseId;
private String storeId;
public String getDefaultGicEid() {
return defaultGicEid;
......@@ -382,4 +384,20 @@ public class StaffDTO implements Serializable {
public void setActiveStatus(Integer activeStatus) {
this.activeStatus = activeStatus;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId;
}
}
......@@ -279,4 +279,15 @@ public interface StaffApiService {
*/
boolean isManager(String clerkId);
/**
* 绑定的员工列表
*
* @param storeIds 存储id
* @param wxEnterpriseId wx企业标识
* @return {@link List }<{@link StaffDTO }>
* @author mozhu
* @date 2022-10-21 00:25:46
*/
List<StaffDTO> listBindStoreIds(List<String> storeIds,String wxEnterpriseId);
}
package com.gic.haoban.manage.service.dao.mapper;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Param;
......@@ -133,4 +134,16 @@ public interface StaffMapper {
* @date 2022-07-25 16:36:07
*/
int resetAddNum();
/**
* 绑定的员工列表(暂时取100条,后续和前端一起改为分页接口)
*
* @param storeIds 存储id
* @param wxEnterpriseId wx企业标识
* @return {@link List }<{@link StaffDTO }>
* @author mozhu
* @date 2022-10-21 00:26:47
*/
List<StaffDTO> listBindStoreIds(@Param("storeIds") List<String> storeIds,
@Param("wxEnterpriseId") String wxEnterpriseId);
}
\ No newline at end of file
......@@ -1018,4 +1018,9 @@ public class StaffApiServiceImpl implements StaffApiService {
}
return false;
}
@Override
public List<StaffDTO> listBindStoreIds(List<String> storeIds, String wxEnterpriseId) {
return staffMapper.listBindStoreIds(storeIds,wxEnterpriseId);
}
}
......@@ -28,7 +28,8 @@
</resultMap>
<sql id="Base_Column_List">
staff_id, wx_user_id, phone_number, staff_name, nation_code, nick_name, sex, postion,
staff_id
, wx_user_id, phone_number, staff_name, nation_code, nick_name, sex, postion,
active_flag, extend_postion, status_flag, create_time, update_time,wx_enterprise_id,head_img,
sort,sync_postion_flag,super_manager_flag,wx_open_user_id,wx_open_id,qr_code,add_num,active_status
</sql>
......@@ -38,7 +39,7 @@
from tab_haoban_staff
where staff_id = #{staffId,jdbcType=VARCHAR} and status_flag = 1
</select>
<update id="delOtherStaffByWxUserId">
update tab_haoban_staff
......@@ -282,11 +283,11 @@
select
a.*
<if test="departmentIds != null and departmentIds.size() > 0">
, b.department_id departmentIds
, b.department_id departmentIds
</if>
from tab_haoban_staff a
<if test="departmentIds != null and departmentIds.size() > 0">
left join tab_haoban_staff_department_related b on a.staff_id = b.staff_id and b.status_flag = 1
left join tab_haoban_staff_department_related b on a.staff_id = b.staff_id and b.status_flag = 1
</if>
where a.status_flag = 1 and a.wx_enterprise_id = #{wxEnterpriseId}
<if test="keyword != null and keyword != ''">
......@@ -314,7 +315,7 @@
</foreach>
</if>
<if test="departmentIds != null and departmentIds.size() > 0">
group by a.staff_id
group by a.staff_id
</if>
order by a.create_time desc
</select>
......@@ -358,7 +359,7 @@
<foreach collection="userIds" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR}
</foreach>
or
or
wx_open_user_id IN
<foreach collection="userIds" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR}
......@@ -467,16 +468,17 @@
<update id="updateAddNumById" parameterType="java.lang.String">
update tab_haoban_staff
set add_num = add_num +1,
update_time = now()
where staff_id = #{staffId} and status_flag = 1
set add_num = add_num + 1,
update_time = now()
where staff_id = #{staffId}
and status_flag = 1
</update>
<update id="updateActiveStatusById" >
<update id="updateActiveStatusById">
update tab_haoban_staff
set active_status = #{activeStatus},
update_time = now()
update_time = now()
where staff_id = #{staffId}
</update>
......@@ -489,4 +491,29 @@
where status_flag = 1
</update>
<select id="listBindStoreIds" resultType="com.gic.haoban.manage.api.dto.StaffDTO">
select
a.staff_id staffId,
a.phone_number phoneNumber,
a.staff_name staffName,
a.head_img headImg,
a.wx_enterprise_id wxEnterpriseId,
b.clerk_id clerkId,
b.clerk_code clerkCode,
b.enterprise_id enterpriseId,
b.store_id storeId
from tab_haoban_staff a
left join tab_haoban_staff_clerk_relation b on a.staff_id = b.staff_id
where a.wx_enterprise_id = #{wxEnterpriseId}
and a.status_flag = 1 and b.status_flag = 1
<if test="null != storeIds and storeIds.size gt 0">
and b.store_id in
<foreach collection="storeIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
limit 100
</select>
</mapper>
\ No newline at end of file
......@@ -119,25 +119,19 @@ public class WxStaffController extends WebBaseController {
if (storeIds.contains("-1")) {
storeIds = null;
}
List<StaffClerkRelationDTO> list = staffClerkRelationApiService.listByStoreIds(storeIds);
List<String> staffIds = list.stream().map(StaffClerkRelationDTO::getStaffId).collect(Collectors.toList());
List<StaffDTO> resultlist = staffApiService.listByIds(staffIds);
Map<String, StaffDTO> map = com.gic.commons.util.CollectionUtil.toMap(resultlist, "staffId");
List<StaffDTO> resultlist = staffApiService.listBindStoreIds(storeIds, wxEnterpriseId);
List<StaffVO> resultList = new ArrayList<>();
for (StaffClerkRelationDTO staffClerkRelationDTO : list) {
String staffId = staffClerkRelationDTO.getStaffId();
logger.info("员工id为:{}", staffId);
StaffDTO staffDTO = map.get(staffId);
if (staffDTO != null) {
ClerkDTO clerk = clerkService.getClerkByClerkCode(staffClerkRelationDTO.getEnterpriseId(), staffClerkRelationDTO.getClerkCode());
if (clerk != null) {
long memberCount = distributeApiService.getClerkMemberCount(staffClerkRelationDTO.getEnterpriseId(), clerk.getClerkId(), storeId);
logger.info("【获取会员数】enterpriseId={},clerkId={},storeId={},memberCount={}", staffClerkRelationDTO.getEnterpriseId(), clerk.getClerkId(), storeId, memberCount);
staffDTO.setMemberCount(Convert.toInt(memberCount, 0));
staffDTO.setClerkId(clerk.getClerkId());
staffDTO.setClerkCode(clerk.getClerkCode());
resultList.add(EntityUtil.changeEntityNew(StaffVO.class, staffDTO));
}
for (StaffDTO staffDTO : resultlist) {
String enterpriseId = staffDTO.getEnterpriseId();
String clerkCode = staffDTO.getClerkCode();
ClerkDTO clerk = clerkService.getClerkByClerkCode(enterpriseId, clerkCode);
if (clerk != null) {
long memberCount = distributeApiService.getClerkMemberCount(enterpriseId, clerk.getClerkId(), storeId);
logger.info("【获取会员数】enterpriseId={},clerkId={},storeId={},memberCount={}", enterpriseId, clerk.getClerkId(), storeId, memberCount);
staffDTO.setMemberCount(Convert.toInt(memberCount, 0));
staffDTO.setClerkId(clerk.getClerkId());
staffDTO.setClerkCode(clerk.getClerkCode());
resultList.add(EntityUtil.changeEntityNew(StaffVO.class, staffDTO));
}
}
return resultResponse(HaoBanErrCode.ERR_1, resultList);
......@@ -335,7 +329,7 @@ public class WxStaffController extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_10009);
}
String enterpriseId = store.getEnterpriseId();
boolean b = auditApiService.judgeHavePhoneNumberOrCode(enterpriseId, clerkCode, phoneNumber,wxEnterpriseId);
boolean b = auditApiService.judgeHavePhoneNumberOrCode(enterpriseId, clerkCode, phoneNumber, wxEnterpriseId);
if (b) {
//待审核中存在code或该手机号
return resultResponse(HaoBanErrCode.ERR_10021);
......@@ -347,7 +341,7 @@ public class WxStaffController extends WebBaseController {
}
AuditSettingDTO dto = auditSettingApiService.findSettingByWxEnterpriseId(wxEnterpriseId);
if (dto.getAuditFlag() == 1 && dto.getClerkChangeFlag() == 1) {
AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkCode, AuditType.CLERK_ADD.getCode(),wxEnterpriseId,enterpriseId);
AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkCode, AuditType.CLERK_ADD.getCode(), wxEnterpriseId, enterpriseId);
if (auditDTO != null) {
logger.info("已经存在了审核记录,待审核{}", clerkCode);
return resultResponse(HaoBanErrCode.ERR_10018);
......@@ -435,7 +429,7 @@ public class WxStaffController extends WebBaseController {
//需要审核
String[] clerkIdArr = clerkIds.split(",");
for (String clerkId : clerkIdArr) {
AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkId, AuditType.CLERK_DEL.getCode(),wxEnterpriseId,store.getEnterpriseId());
AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkId, AuditType.CLERK_DEL.getCode(), wxEnterpriseId, store.getEnterpriseId());
if (auditDTO != null) {
logger.info("已经存在了审核记录,待审核{}", clerkId);
continue;
......@@ -859,7 +853,7 @@ public class WxStaffController extends WebBaseController {
if (staff == null) {
return resultResponse(HaoBanErrCode.ERR_10006);
}
AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkId, AuditType.CLERK_BIND.getCode(),wxEnterpriseId,clerk.getEnterpriseId());
AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkId, AuditType.CLERK_BIND.getCode(), wxEnterpriseId, clerk.getEnterpriseId());
if (auditDTO != null) {
return resultResponse(HaoBanErrCode.ERR_10018);
}
......
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