Commit 223ea1ad by jinxin

转移接口处理

parent de59dca3
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @description: 转移返回结果DTO
* @Author: wenhua
* @Date: 2023/2/3 10:47
*/
public class TransferActiveCodeDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 转移总数
*/
private Integer totalNum;
/**
* 成功总数
*/
private Integer successNum;
/**
* 失败总数
*/
private Integer failedNum;
/**
* 失败明细
*/
private List<Map<String,String>> failedList;
public Integer getTotalNum() {
return totalNum;
}
public void setTotalNum(Integer totalNum) {
this.totalNum = totalNum;
}
public Integer getSuccessNum() {
return successNum;
}
public void setSuccessNum(Integer successNum) {
this.successNum = successNum;
}
public Integer getFailedNum() {
return failedNum;
}
public void setFailedNum(Integer failedNum) {
this.failedNum = failedNum;
}
public List<Map<String, String>> getFailedList() {
return failedList;
}
public void setFailedList(List<Map<String, String>> failedList) {
this.failedList = failedList;
}
}
...@@ -12,27 +12,27 @@ public class TransferActiveCodeQDTO implements Serializable { ...@@ -12,27 +12,27 @@ public class TransferActiveCodeQDTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 转移成员的userid。只支持加密的userid * 转移成员的staffId
*/ */
private String handover_userid ; private String handoverStaffId;
/** /**
* 接收成员的userid。只支持加密的userid * 接收成员的staffId
*/ */
private String takeover_userid ; private String takeoverStaffId ;
public String getHandover_userid() { public String getHandoverStaffId() {
return handover_userid; return handoverStaffId;
} }
public void setHandover_userid(String handover_userid) { public void setHandoverStaffId(String handoverStaffId) {
this.handover_userid = handover_userid; this.handoverStaffId = handoverStaffId;
} }
public String getTakeover_userid() { public String getTakeoverStaffId() {
return takeover_userid; return takeoverStaffId;
} }
public void setTakeover_userid(String takeover_userid) { public void setTakeoverStaffId(String takeoverStaffId) {
this.takeover_userid = takeover_userid; this.takeoverStaffId = takeoverStaffId;
} }
} }
...@@ -329,5 +329,5 @@ public interface StaffApiService { ...@@ -329,5 +329,5 @@ public interface StaffApiService {
/** /**
* 转移员工许可 * 转移员工许可
*/ */
com.gic.api.base.commons.ServiceResponse<Integer> batchTransferLicense(List<TransferActiveCodeQDTO> transferActiveCodeQOList,String wxEnterpriseId); com.gic.api.base.commons.ServiceResponse<TransferActiveCodeDTO> batchTransferLicense(List<TransferActiveCodeQDTO> transferActiveCodeQOList,String wxEnterpriseId);
} }
...@@ -168,11 +168,10 @@ public interface StaffMapper { ...@@ -168,11 +168,10 @@ public interface StaffMapper {
*/ */
Integer getOccupyNum(@Param("wxEnterpriseId") String wxEnterpriseId); Integer getOccupyNum(@Param("wxEnterpriseId") String wxEnterpriseId);
TabHaobanStaff getStaffInfoByWxOpenUserId(@Param("wxOpenUseId") String wxOpenUseId);
/** /**
* 通过wxOpenUserId更新企业成员许可信息 * 通过wxOpenUserId更新企业成员许可信息
*/ */
void updateStaffInfoByWxOpenUserId(@Param("wxOpenUseId") String wxOpenUseId, void updateStaffInfoByStaffId(@Param("staffId") String staffId,
@Param("activeTime")Date activeTime, @Param("activeTime")Date activeTime,
@Param("expireTime")Date expireTime, @Param("expireTime")Date expireTime,
@Param("activeCode")String activeCode, @Param("activeCode")String activeCode,
......
package com.gic.haoban.manage.service.service.out.impl; package com.gic.haoban.manage.service.service.out.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
...@@ -936,25 +937,68 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -936,25 +937,68 @@ public class StaffApiServiceImpl implements StaffApiService {
} }
@Override @Override
public com.gic.api.base.commons.ServiceResponse<Integer> batchTransferLicense(List<TransferActiveCodeQDTO> transferActiveCodeQOList,String wxEnterpriseId) { public com.gic.api.base.commons.ServiceResponse<TransferActiveCodeDTO> batchTransferLicense(List<TransferActiveCodeQDTO> transferActiveCodeQOList,String wxEnterpriseId) {
TransferActiveCodeDTO result = new TransferActiveCodeDTO();
if (CollUtil.isEmpty(transferActiveCodeQOList)){
return com.gic.api.base.commons.ServiceResponse.failure("-9999"," 传入的参数有误!",result);
}
//拼接staffIdList
List<String> staffIds = new ArrayList<>();
transferActiveCodeQOList.stream().forEach(a->{
staffIds.add(a.getHandoverStaffId());
staffIds.add(a.getTakeoverStaffId());
});
List<TabHaobanStaff> tabHaobanStaffs = staffMapper.listByIds(staffIds);
if (CollUtil.isEmpty(tabHaobanStaffs)){
return com.gic.api.base.commons.ServiceResponse.failure("-9999","通讯录成员不存在!",result);
}
WxEnterpriseDTO wxEnterpriseDTO = this.wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseDTO wxEnterpriseDTO = this.wxEnterpriseService.selectById(wxEnterpriseId);
String openCorpid = wxEnterpriseDTO.getOpenCorpid(); String openCorpid = wxEnterpriseDTO.getOpenCorpid();
String serviceCorpid = config.getCorpid(); String serviceCorpid = config.getCorpid();
List<AccountTransferUserDTO> accountTransferUserDTOList = JSONArray.parseArray(JSONObject.toJSONString(transferActiveCodeQOList), AccountTransferUserDTO.class); //拼接转移参数
Map<String, TabHaobanStaff> collect = tabHaobanStaffs.stream().collect(Collectors.toMap(TabHaobanStaff::getStaffId, a -> a));
Map<String, String> map = tabHaobanStaffs.stream().collect(Collectors.toMap(TabHaobanStaff::getWxOpenUseId, a -> a.getStaffId()));
List<AccountTransferUserDTO> accountTransferUserDTOList = new ArrayList<>();
transferActiveCodeQOList.stream().forEach(a->{
AccountTransferUserDTO accountTransferUserDTO = new AccountTransferUserDTO();
TabHaobanStaff handoverStaff = collect.get(a.getHandoverStaffId());
TabHaobanStaff takeOverStaff = collect.get(a.getTakeoverStaffId());
accountTransferUserDTO.setHandover_userid(handoverStaff.getWxOpenUseId());
accountTransferUserDTO.setTakeover_userid(takeOverStaff.getWxOpenUseId());
accountTransferUserDTOList.add(accountTransferUserDTO);
});
com.gic.api.base.commons.ServiceResponse<List<AccountTransferUserDTO>> listServiceResponse = qywxOrderApiService.batchTransferLicense(serviceCorpid, openCorpid, accountTransferUserDTOList); com.gic.api.base.commons.ServiceResponse<List<AccountTransferUserDTO>> listServiceResponse = qywxOrderApiService.batchTransferLicense(serviceCorpid, openCorpid, accountTransferUserDTOList);
logger.info("转移成员返回结果:{}",JSONObject.toJSONString(listServiceResponse)); logger.info("转移成员返回结果:{}",JSONObject.toJSONString(listServiceResponse));
if (Constant.SUCCESS.equals(listServiceResponse.getCode())){ if (Constant.SUCCESS.equals(listServiceResponse.getCode())){
//企微转移成功,好办staff表对应更新 List<AccountTransferUserDTO> resultList = listServiceResponse.getResult();
transferActiveCodeQOList.stream().forEach(a->{ result.setTotalNum(resultList.size());
//先查询转移成员的许可信息 int successNum=0,failedNum=0;
TabHaobanStaff staffDTO = staffMapper.getStaffInfoByWxOpenUserId(a.getHandover_userid()); List<Map<String,String>> failedList =new ArrayList<>();
//置空转移成员的许可信息 for (AccountTransferUserDTO dto : resultList) {
staffMapper.updateStaffInfoByWxOpenUserId(a.getHandover_userid(),null,null,null,0); if(Constant.SUCCESS.equals(dto.getErrcode())){
//更新接收成员的许可信息 //企微转移成功,好办staff表对应更新
staffMapper.updateStaffInfoByWxOpenUserId(a.getTakeover_userid(),staffDTO.getActiveTime(),staffDTO.getExpireTime(), staffDTO.getActiveCode(),1); successNum++;
}); TabHaobanStaff handoverStaff = collect.get(map.get(dto.getHandover_userid()));
return com.gic.api.base.commons.ServiceResponse.success(); TabHaobanStaff takeOverStaff = collect.get(map.get(dto.getTakeover_userid()));
} //置空转移成员的许可信息
return com.gic.api.base.commons.ServiceResponse.failure(listServiceResponse.getCode(),listServiceResponse.getMessage()); staffMapper.updateStaffInfoByStaffId(handoverStaff.getStaffId(),null,null,null,0);
//更新接收成员的许可信息
staffMapper.updateStaffInfoByStaffId(takeOverStaff.getStaffId(),takeOverStaff.getActiveTime(),takeOverStaff.getExpireTime(), takeOverStaff.getActiveCode(),1);
}else{
//企微转移失败,记录失败明细
failedNum++;
TabHaobanStaff handoverStaff = collect.get(map.get(dto.getHandover_userid()));
TabHaobanStaff takeOverStaff = collect.get(map.get(dto.getTakeover_userid()));
Map<String,String> stringMap = new HashMap<>(8);
stringMap.put("handoverStaffName",handoverStaff.getStaffName());
stringMap.put("takeOverStaffName",takeOverStaff.getStaffName());
failedList.add(stringMap);
}
}
return com.gic.api.base.commons.ServiceResponse.success(result);
}
return com.gic.api.base.commons.ServiceResponse.failure(listServiceResponse.getCode(),listServiceResponse.getMessage(),result);
} }
} }
...@@ -607,9 +607,6 @@ ...@@ -607,9 +607,6 @@
SELECT count(*) FROM tab_haoban_staff WHERE status_flag = 0 and update_time >= DATE_FORMAT(NOW(),'%Y-%m-%d') and active_status = 1 and wx_enterprise_id = #{wxEnterpriseId} SELECT count(*) FROM tab_haoban_staff WHERE status_flag = 0 and update_time >= DATE_FORMAT(NOW(),'%Y-%m-%d') and active_status = 1 and wx_enterprise_id = #{wxEnterpriseId}
</select> </select>
<select id="getStaffInfoByWxOpenUserId" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" /> FROM tab_haoban_staff WHERE wx_open_user_id = #{wxOpenUseId}
</select>
<update id="updateStaffInfoByWxOpenUserId"> <update id="updateStaffInfoByWxOpenUserId">
update tab_haoban_staff set update tab_haoban_staff set
......
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.TransferActiveCodeDTO;
import com.gic.haoban.manage.api.dto.qdto.TransferActiveCodeQDTO; import com.gic.haoban.manage.api.dto.qdto.TransferActiveCodeQDTO;
import com.gic.haoban.manage.api.service.StaffApiService; import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.hm.HmPageApiService; import com.gic.haoban.manage.api.service.hm.HmPageApiService;
import com.gic.haoban.manage.service.service.WxEnterpriseActiveDataService; import com.gic.haoban.manage.service.service.WxEnterpriseActiveDataService;
import com.google.gson.JsonObject;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -35,14 +38,17 @@ public class WxEnterpriseActiveDataServiceTest { ...@@ -35,14 +38,17 @@ public class WxEnterpriseActiveDataServiceTest {
public void test1(){ public void test1(){
List<TransferActiveCodeQDTO> transferActiveCodeQOList = new ArrayList<>(); List<TransferActiveCodeQDTO> transferActiveCodeQOList = new ArrayList<>();
TransferActiveCodeQDTO transferActiveCodeQDTO = new TransferActiveCodeQDTO(); TransferActiveCodeQDTO transferActiveCodeQDTO = new TransferActiveCodeQDTO();
transferActiveCodeQDTO.setHandover_userid("wo59NLDQAACLAXbOdqrz-70qpl72cWcA"); transferActiveCodeQDTO.setHandoverStaffId("1fccf6ff6ecf434d9b00f31227b45d63");
transferActiveCodeQDTO.setTakeover_userid("wo59NLDQAApF0TAIJkdCZjESTGq-fuEQ"); transferActiveCodeQDTO.setTakeoverStaffId("8a3a60a4e5b546b79087ee70f1844b25");
transferActiveCodeQOList.add(transferActiveCodeQDTO); transferActiveCodeQOList.add(transferActiveCodeQDTO);
TransferActiveCodeQDTO transferActiveCodeQDTO1 = new TransferActiveCodeQDTO(); // TransferActiveCodeQDTO transferActiveCodeQDTO1 = new TransferActiveCodeQDTO();
transferActiveCodeQDTO1.setHandover_userid("wo59NLDQAAxWVUBU76zh3jRMXZ8TOxfw"); // transferActiveCodeQDTO1.setHandoverStaffId("wo59NLDQAAxWVUBU76zh3jRMXZ8TOxfw");
transferActiveCodeQDTO1.setTakeover_userid("wo59NLDQAArJKx2wWmQGWTOd36ueijwQ"); // transferActiveCodeQDTO1.setTakeoverStaffId("wo59NLDQAArJKx2wWmQGWTOd36ueijwQ");
transferActiveCodeQOList.add(transferActiveCodeQDTO1); // transferActiveCodeQOList.add(transferActiveCodeQDTO1);
ServiceResponse<Integer> integerServiceResponse = staffApiService.batchTransferLicense(transferActiveCodeQOList,"ca66a01b79474c40b3e7c7f93daf1a3b"); ServiceResponse<TransferActiveCodeDTO> transferLicense = staffApiService.batchTransferLicense(transferActiveCodeQOList, "ca66a01b79474c40b3e7c7f93daf1a3b");
System.out.println("222222222222"+ JSONObject.toJSONString(transferLicense));
} }
} }
...@@ -617,8 +617,9 @@ public class StaffController extends WebBaseController { ...@@ -617,8 +617,9 @@ public class StaffController extends WebBaseController {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser(); WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId(); String wxEnterpriseId = login.getWxEnterpriseId();
List<TransferActiveCodeQDTO> transferActiveCodeQDTOList = JSONArray.parseArray(JSONObject.toJSONString(transferActiveCodeQOList), TransferActiveCodeQDTO.class); List<TransferActiveCodeQDTO> transferActiveCodeQDTOList = JSONArray.parseArray(JSONObject.toJSONString(transferActiveCodeQOList), TransferActiveCodeQDTO.class);
ServiceResponse<Integer> integerServiceResponse = staffApiService.batchTransferLicense(transferActiveCodeQDTOList, wxEnterpriseId); ServiceResponse<TransferActiveCodeDTO> transferActiveCodeDTOServiceResponse = staffApiService.batchTransferLicense(transferActiveCodeQDTOList, wxEnterpriseId);
return RestResponse.successResult(integerServiceResponse);
return RestResponse.successResult(transferActiveCodeDTOServiceResponse);
} }
} }
...@@ -12,27 +12,27 @@ public class TransferActiveCodeQO implements Serializable { ...@@ -12,27 +12,27 @@ public class TransferActiveCodeQO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 转移成员的userid。只支持加密的userid * 转移成员的staffId
*/ */
private String handover_userid ; private String handoverStaffId;
/** /**
* 接收成员的userid。只支持加密的userid * 接收成员的staffId
*/ */
private String takeover_userid ; private String takeoverStaffId ;
public String getHandover_userid() { public String getHandoverStaffId() {
return handover_userid; return handoverStaffId;
} }
public void setHandover_userid(String handover_userid) { public void setHandoverStaffId(String handoverStaffId) {
this.handover_userid = handover_userid; this.handoverStaffId = handoverStaffId;
} }
public String getTakeover_userid() { public String getTakeoverStaffId() {
return takeover_userid; return takeoverStaffId;
} }
public void setTakeover_userid(String takeover_userid) { public void setTakeoverStaffId(String takeoverStaffId) {
this.takeover_userid = takeover_userid; this.takeoverStaffId = takeoverStaffId;
} }
} }
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