Commit e1bb8058 by zhoupeng

提交导入组织架构openapi接口

parent c7a4184c
...@@ -6,9 +6,7 @@ import io.swagger.annotations.Api; ...@@ -6,9 +6,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @Author: zhoupeng * @Author: zhoupeng
...@@ -32,4 +30,23 @@ public class SyncEmployeCdpController { ...@@ -32,4 +30,23 @@ public class SyncEmployeCdpController {
return Response.builderSuccess(syncEmployeCdpService.synAllEmpCdpBase(pageNum)); return Response.builderSuccess(syncEmployeCdpService.synAllEmpCdpBase(pageNum));
} }
@GetMapping( "/synByCdpEmployee")
@ApiOperation(value = "新Cdp根据员工号同步员工信息")
public Response<Boolean> synByCdpEmployee(@RequestParam("employeeNumber") String employeeNumber){
Boolean flag = syncEmployeCdpService.synByCdpEmployee(employeeNumber);
return Response.builderSuccess(flag);
}
@GetMapping( "/syncProgress")
@ApiOperation(value = "新Cdp根据员工号同步员工信息")
public Response<String> syncProgress(){
String progress = syncEmployeCdpService.synProgress();
return Response.builderSuccess(progress);
}
} }
...@@ -14,4 +14,21 @@ public interface SyncEmployeCdpService { ...@@ -14,4 +14,21 @@ public interface SyncEmployeCdpService {
* 同步查询员工(基础信息) -(工单系统等) * 同步查询员工(基础信息) -(工单系统等)
*/ */
Boolean synAllEmpCdpBase(Integer pageNum); Boolean synAllEmpCdpBase(Integer pageNum);
/**
* 根据员工号同步员工信息
* @param employeeNumber
* @return
*/
Boolean synByCdpEmployee(String employeeNumber);
/**
* 查询组织架构导入进度
* @return
*/
String synProgress();
} }
...@@ -3,11 +3,13 @@ package com.rome.order.domain.service.impl; ...@@ -3,11 +3,13 @@ package com.rome.order.domain.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.rome.order.domain.enums.ResponseMsg;
import com.rome.order.domain.service.OrganizationRedisService; import com.rome.order.domain.service.OrganizationRedisService;
import com.rome.order.domain.service.SyncEmployeCdpService; import com.rome.order.domain.service.SyncEmployeCdpService;
import com.rome.order.domain.util.DateUtils; import com.rome.order.domain.util.DateUtils;
import com.rome.order.domain.util.HmacSHA256Util; import com.rome.order.domain.util.HmacSHA256Util;
import com.rome.order.domain.util.HttpUtil; import com.rome.order.domain.util.HttpUtil;
import com.rome.order.domain.util.ParameterCheckUtils;
import com.rome.order.infrastructure.dataobject.SyncEmployeeCdpDO; import com.rome.order.infrastructure.dataobject.SyncEmployeeCdpDO;
import com.rome.order.infrastructure.mapper.SyncEmployeeCdpMapper; import com.rome.order.infrastructure.mapper.SyncEmployeeCdpMapper;
import com.rome.order.infrastructure.remote.constant.QiDianOpenApiRemoteConstant; import com.rome.order.infrastructure.remote.constant.QiDianOpenApiRemoteConstant;
...@@ -55,6 +57,54 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService { ...@@ -55,6 +57,54 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService {
return this.synEmpCdp(null,pageNum,1,allOrg); return this.synEmpCdp(null,pageNum,1,allOrg);
} }
@Override
public Boolean synByCdpEmployee(String employeeNumber) {
// 参数非空校验
ParameterCheckUtils.noNull(ResponseMsg.PARAM_EMPLOYEENUMBER_NOT_EMPT,employeeNumber);
EmpMainDataResDTO dataResDTO = userEmployeeFacade.synByEmployee(employeeNumber);
ParameterCheckUtils.noNull(ResponseMsg.PARAM_EMPLOYEENUMBER_EMPT,dataResDTO);
Long userId = dataResDTO.getUserId();
String result = this.orgSetAdminAccountId(userId + "");
Boolean successFlag=false;
String errMsg="";
if(StringUtils.isNotBlank(result)){
Map map = JSONObject.parseObject(result, Map.class);
if (Objects.nonNull(map.get("status"))) {
Object statusObj = map.get("status");
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(statusObj));
String code = jsonObject.getString("code");
String message=jsonObject.getString("message");
//返回为1 表示成功
if(RemoteConstant.CODE.equals(code)){
successFlag=true;
}else{
//其他的表示失败
errMsg=message;
}
}
}
return successFlag;
}
@Override
public String synProgress() {
try {
String timestamp = DateUtils.convert(new Date(), DateUtils.YYYYMMDDHHMMSS);
Map<String, String> headers=new HashMap<>();
headers.put("corporationId","0");
headers.put("timestamp",timestamp);
String sign = HmacSHA256Util.getSign(timestamp);
headers.put("sign",sign);
log.info("------指定某员工为企业管理员查询组织架构导入进度头部信息------:{}",JSON.toJSONString(headers));
String result = HttpUtil.httpGet(QiDianOpenApiRemoteConstant.SYNC_PROGRESS_URL,headers);
log.info("----synProgress返回信息----:{}",result);
return result;
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
}
/** /**
* 同步员工数据 * 同步员工数据
...@@ -205,6 +255,26 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService { ...@@ -205,6 +255,26 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService {
} }
} }
private String orgSetAdminAccountId(String accountId){
try {
log.info("-----指定某员工为企业管理员/api/dataauth/authserver/openapi/org/set/admin入参信息----:{}",accountId);
String timestamp = DateUtils.convert(new Date(), DateUtils.YYYYMMDDHHMMSS);
Map<String, String> headers=new HashMap<>();
headers.put("corporationId","0");
headers.put("timestamp",timestamp);
String sign = HmacSHA256Util.getSign(timestamp);
headers.put("sign",sign);
log.info("------指定某员工为企业管理员/api/dataauth/authserver/openapi/org/set/admin头部信息------:{}",JSON.toJSONString(headers));
String result = HttpUtil.httpGet(QiDianOpenApiRemoteConstant.SET_ADMIN_ACCOUNT_URL+accountId,headers);
log.info("----orgSetAdminAccountId返回信息----:{}",result);
return result;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/** /**
* 同步导入组织架构和人员信息到企点 * 同步导入组织架构和人员信息到企点
* @param staffs * @param staffs
...@@ -221,6 +291,7 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService { ...@@ -221,6 +291,7 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService {
headers.put("sign",sign); headers.put("sign",sign);
log.info("------同步导入组织架构和人员信息到企点/api/dataauth/authserver/openapi/org/sync头部信息------:{}",JSON.toJSONString(headers)); log.info("------同步导入组织架构和人员信息到企点/api/dataauth/authserver/openapi/org/sync头部信息------:{}",JSON.toJSONString(headers));
String result = HttpUtil.httpPost(QiDianOpenApiRemoteConstant.ORG_SYNC_URL, bodyStr,headers); String result = HttpUtil.httpPost(QiDianOpenApiRemoteConstant.ORG_SYNC_URL, bodyStr,headers);
log.info("----syncCdpEmpOrg返回信息----:{}",result);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -14,4 +14,17 @@ public class QiDianOpenApiRemoteConstant { ...@@ -14,4 +14,17 @@ public class QiDianOpenApiRemoteConstant {
* 导入组织架构openapi接口 * 导入组织架构openapi接口
*/ */
public static String ORG_SYNC_URL = "/api/dataauth/authserver/openapi/org/sync"; public static String ORG_SYNC_URL = "/api/dataauth/authserver/openapi/org/sync";
/**
* 导入组织架构openapi接口
*/
public static String SET_ADMIN_ACCOUNT_URL = "/api/dataauth/authserver/openapi/org/set/admin?account=";
/**
* 查询组织架构导入进度接口
*/
public static String SYNC_PROGRESS_URL = "/api/dataauth/authserver/openapi/org/sync/progress";
} }
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