同步组织用户

This commit is contained in:
liyawei
2022-03-01 18:32:43 +08:00
parent e613e6de96
commit b30ba53fc5
20 changed files with 583 additions and 9 deletions
@@ -51,6 +51,8 @@ public class SysDepartTreeModel implements Serializable{
private String orgCode; private String orgCode;
private String parentCode;
private String mobile; private String mobile;
private String fax; private String fax;
@@ -74,6 +76,13 @@ public class SysDepartTreeModel implements Serializable{
private List<SysDepartTreeModel> children = new ArrayList<>(); private List<SysDepartTreeModel> children = new ArrayList<>();
public String getParentCode() {
return parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public boolean getIsLeaf() { public boolean getIsLeaf() {
return isLeaf; return isLeaf;
@@ -312,6 +321,7 @@ public class SysDepartTreeModel implements Serializable{
Objects.equals(orgCategory, model.orgCategory) && Objects.equals(orgCategory, model.orgCategory) &&
Objects.equals(orgType, model.orgType) && Objects.equals(orgType, model.orgType) &&
Objects.equals(orgCode, model.orgCode) && Objects.equals(orgCode, model.orgCode) &&
Objects.equals(parentCode, model.parentCode) &&
Objects.equals(mobile, model.mobile) && Objects.equals(mobile, model.mobile) &&
Objects.equals(fax, model.fax) && Objects.equals(fax, model.fax) &&
Objects.equals(address, model.address) && Objects.equals(address, model.address) &&
@@ -332,9 +342,9 @@ public class SysDepartTreeModel implements Serializable{
public int hashCode() { public int hashCode() {
return Objects.hash(id, parentId, departName, departNameEn, departNameAbbr, return Objects.hash(id, parentId, departName, departNameEn, departNameAbbr,
departOrder, description, orgCategory, orgType, orgCode, mobile, fax, address, departOrder, description, orgCategory, orgType, orgCode, parentCode,
memo, status, delFlag, createBy, createTime, updateBy, updateTime, mobile, fax, address, memo, status, delFlag, createBy, createTime,
children); updateBy, updateTime, children);
} }
} }
@@ -0,0 +1,60 @@
package com.jero.modules.system.entity;
import lombok.Data;
import java.util.Date;
/**
* @Author: liyawei
* @Description:
* @Date: Created in 10:01 2022/3/1
*/
@Data
public class PPEmployee {
private String data_difference; //数据来源[WORKDAY,XPT,NIOCAPITAL]
private String employee_difference; // 员工来源[CN, EU_US,EU]
private String employee_id; // 员工编号(员工唯一标识)
private String worker_user_id; //WD帐号创建SSO账号 / AD账户
private String user_name; // WD同步到people的域帐号
private String foreign_employee_id; // 兼职公司对应的员工编号
private String name; // 全名
private String formatted_name; // 全名-拼音及中文
private String preferred_first_name; // 首选-名
private String preferred_last_name; // 首选-姓
private String first_name; //法定-名-拼音
private String middle_name; // 中间-名 - 英文
private String last_name; // 法定-姓-拼音
private String english_name; // 英文名称
private String name_in_local_script; // 法定-姓名-中文
private String first_name_in_local_script; // 名-中文
private String last_name_in_local_script; // 姓-中文
private String delete_flag; // 删除标记[1:存在;0:删除]
private String delete_time; // 删除时间
private String delay_flag; // 延期标记(0:延期,1:未延期,2:未操作)
private String delay_time; // 延期时间
private String employee_status; // 员工状态[Active,Terminated]
private String outsourcing_type; // 外包形式
private String worker_type; // 员工种类 Employee,Contingent Worker
private String hire_date; // 员工入职日期
private String original_hire_date; // 员工原始入职日期
private String rehire; // 重新雇用[1:是;0:否]
private String seniority_date; // 工龄开始日期
private String is_terminated; // 离职状态[1:是;0:否]
private String termination_date; // 离职日期
private String termination_last_day_of_work; // 最后工作日期
private String primary_termination_reason; // 主要离职原因
private String hire_reason; // 雇佣原因
private String user_type; // 用户类型
private String probation_end_date; // 试用期结束时间
private String option_user; // 最后操作人
private String data_provider; // 第三方数据提供商
private String extension_attribute1; // O365标签
private String working_hour; // 工作制
private String domain; // 账号所属域
private String ad_failed; // 创建ad失败原账号
private String have_employees; // 是否有下属员工
private String id; // id
private Date creation_time; // 创建时间
private Date update_time; // 修改时间
}
@@ -0,0 +1,33 @@
package com.jero.modules.system.entity;
import lombok.Data;
import java.util.Date;
/**
* @Author: liyawei
* @Description:
* @Date: Created in 15:27 2022/3/1
*/
@Data
public class PPOrgPosEmployee {
private String worker_user_id; //域账号
private String biz_org_code; //组织编码
private String biz_org_path; //组织路径
private String biz_org_path_name; //组织路径名
private String biz_org_path_type; //组织路径类型
private String sub_biz_org_path; //子组织路径
private String sub_biz_org_path_name; //子组织路径名
private String sub_biz_org_path_type; //子组织路径类型
private String position_code; //岗位ID
private String position_name; //岗位名称
private String attribute_template; //岗位属性配置
private String position_custom_type; //岗位自定义类型
private String employee_id; //员工号
private String biz_org_x_position_id; //组织-岗位ID
private String attribute; //岗位属性
private String id;
private Date creation_time;
private Date update_time;
}
@@ -0,0 +1,29 @@
package com.jero.modules.system.entity;
import lombok.Data;
import java.util.List;
/**
* @Author: liyawei
* @Description:
* @Date: Created in 16:05 2022/2/28
*/
@Data
public class PPOrganization {
private String id; //组织id
private String code; //组织编码
private String name; //组织名称
private String parent_code; //节点上级编码
private String parent_path; //节点所有上级编码,按/分割
private String full_path; //根节点到当前节点全路径
private String full_path_name; //根节点到当前节点名称全路径,按/分割
private String is_tree_leaf; //是否叶子节点
private String tree_level; //节点层级,根节点为0
private String type; //节点种类Enum, ("GEOGRAPHY", "BUSINESS")
private String full_path_type; //跟节点到节点路径上所有节点的类型,按/分割
private String app_id; //业务节点:业务系统的APP ID
private String api; //存储业务系统的API接口
private List<PPOrganization> children; //叶子节点
}
@@ -0,0 +1,25 @@
package com.jero.modules.system.entity;
import lombok.Data;
/**
* @Author: liyawei
* @Description:
* @Date: Created in 14:13 2022/3/1
*/
@Data
public class PPOrganizationPosition {
private String id;
private String biz_org_code; //组织编码
private String biz_org_path; //组织全路径
private String biz_org_path_name; //组织全路径 - 名字
private String biz_org_path_type; //组织全路径 - 类型
private String sub_biz_org_path; //子组织全路径
private String sub_biz_org_path_name; //子组织全路径 - 名字
private String sub_biz_org_path_type; //子组织全路径 - 类型
private String biz_position_code; //岗位编码
private String biz_position_name; //岗位名字
private String attribute_template; //岗位属性配置
private String position_custom_type; //岗位自定义类型
}
@@ -0,0 +1,24 @@
package com.jero.modules.system.entity;
import lombok.Data;
import java.util.List;
/**
* @Author: liyawei
* @Description:
* @Date: Created in 10:01 2022/3/1
*/
@Data
public class PPPosition {
private String id; //岗位编号
private String code; //岗位code
private String name; //岗位名称
private String parent_code; //父级岗位code
private String parent_name; //父级岗位名称
private String is_tree_leaf; //是否为叶子节点
private String attribute_template; //JSON字符串,属性配置
private String custom_type; //自定义类型
private List<PPPosition> children;
}
@@ -53,6 +53,8 @@ public class SysDepart implements Serializable {
/**机构编码*/ /**机构编码*/
@Excel(name="机构编码",width=15) @Excel(name="机构编码",width=15)
private String orgCode; private String orgCode;
/**父级机构编码*/
private String parentCode;
/**手机号*/ /**手机号*/
@Excel(name="手机号",width=15) @Excel(name="手机号",width=15)
private String mobile; private String mobile;
@@ -83,7 +85,6 @@ public class SysDepart implements Serializable {
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date updateTime; private Date updateTime;
/** /**
* 重写equals方法 * 重写equals方法
*/ */
@@ -109,10 +110,11 @@ public class SysDepart implements Serializable {
Objects.equals(orgCategory, depart.orgCategory) && Objects.equals(orgCategory, depart.orgCategory) &&
Objects.equals(orgType, depart.orgType) && Objects.equals(orgType, depart.orgType) &&
Objects.equals(orgCode, depart.orgCode) && Objects.equals(orgCode, depart.orgCode) &&
Objects.equals(mobile, depart.mobile) && Objects.equals(parentCode, depart.parentCode) &&
Objects.equals(fax, depart.fax) && Objects.equals(mobile, depart.mobile) &&
Objects.equals(address, depart.address) && Objects.equals(fax, depart.fax) &&
Objects.equals(memo, depart.memo) && Objects.equals(address, depart.address) &&
Objects.equals(memo, depart.memo) &&
Objects.equals(status, depart.status) && Objects.equals(status, depart.status) &&
Objects.equals(delFlag, depart.delFlag) && Objects.equals(delFlag, depart.delFlag) &&
Objects.equals(createBy, depart.createBy) && Objects.equals(createBy, depart.createBy) &&
@@ -129,7 +131,7 @@ public class SysDepart implements Serializable {
return Objects.hash(super.hashCode(), id, parentId, departName, return Objects.hash(super.hashCode(), id, parentId, departName,
departNameEn, departNameAbbr, departOrder, description,orgCategory, departNameEn, departNameAbbr, departOrder, description,orgCategory,
orgType, orgCode, mobile, fax, address, memo, status, orgType, orgCode, parentCode, mobile, fax, address, memo, status,
delFlag, createBy, createTime, updateBy, updateTime); delFlag, createBy, createTime, updateBy, updateTime);
} }
} }
@@ -71,5 +71,9 @@ public class SysDepartRole {
@ApiModelProperty(value = "更新时间") @ApiModelProperty(value = "更新时间")
private java.util.Date updateTime; private java.util.Date updateTime;
@ApiModelProperty(value = "角色id")
private java.lang.String roleId;
} }
@@ -41,6 +41,11 @@ public class SysDepartRoleUser {
@ApiModelProperty(value = "角色id") @ApiModelProperty(value = "角色id")
private java.lang.String droleId; private java.lang.String droleId;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private java.util.Date createTime;
public SysDepartRoleUser() { public SysDepartRoleUser() {
} }
@@ -78,5 +78,15 @@ public class SysRole implements Serializable {
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date updateTime; private Date updateTime;
/**
* 父级岗位code
*/
private String parentCode;
/**
* 父级岗位code
*/
private Integer roleOrder;
} }
@@ -175,4 +175,6 @@ public class SysUser implements Serializable {
/**设备id uniapp推送用*/ /**设备id uniapp推送用*/
private String clientId; private String clientId;
private String thirdId;//用户域账号
} }
@@ -0,0 +1,27 @@
package com.jero.modules.system.service;
import com.jero.modules.system.entity.PPOrganization;
import java.io.IOException;
import java.net.MalformedURLException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
/**
* @Author: liyawei
* @Description:
* @Date: Created in 15:37 2022/2/28
*/
public interface ISyncDataService {
void syncDepartInfo() throws IOException, NoSuchAlgorithmException, InvalidKeyException;
int insertDepartFromTree(PPOrganization root, int i);
void syncRoleInfo() throws IOException, NoSuchAlgorithmException, InvalidKeyException;
void syncDepartRoleInfo() throws IOException, NoSuchAlgorithmException, InvalidKeyException;
void syncDepartRoleUserInfo() throws IOException, NoSuchAlgorithmException, InvalidKeyException;
String getResultDataOfGet(String uri, String queryString) throws IOException, NoSuchAlgorithmException, InvalidKeyException;
}
@@ -123,4 +123,11 @@ public interface ISysDepartService extends IService<SysDepart>{
* @param departId 部门id * @param departId 部门id
*/ */
List<SysDepartTreeModel> listSonDepartsByDepId(String departId); List<SysDepartTreeModel> listSonDepartsByDepId(String departId);
/**
* 根据编码查询
* @param departCode
* @return
*/
List<SysDepart> queryByDepartCode(String departCode);
} }
@@ -6,6 +6,8 @@ import com.jero.modules.system.entity.SysRole;
import org.jeecgframework.poi.excel.entity.ImportParams; import org.jeecgframework.poi.excel.entity.ImportParams;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/** /**
* <p> * <p>
* 角色表 服务类 * 角色表 服务类
@@ -40,4 +42,11 @@ public interface ISysRoleService extends IService<SysRole> {
*/ */
public boolean deleteBatchRole(String[] roleids); public boolean deleteBatchRole(String[] roleids);
/**
* 根据编码查询
* @param roleCode
* @return
*/
List<SysRole> queryByRoleCode(String roleCode);
} }
@@ -233,4 +233,6 @@ public interface ISysUserService extends IService<SysUser> {
* @return * @return
*/ */
List<SysUser> queryByDepIds(List<String> departIds, String username); List<SysUser> queryByDepIds(List<String> departIds, String username);
List<SysUser> queryByWorkNo(String workNo);
} }
@@ -0,0 +1,301 @@
package com.jero.modules.system.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jero.common.constant.CommonConstant;
import com.jero.common.system.util.JwtUtil;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.PasswordUtil;
import com.jero.common.util.oConvertUtils;
import com.jero.modules.system.entity.*;
import com.jero.modules.system.service.*;
import com.jero.modules.system.util.HmacSignUtil;
import com.jero.modules.system.util.HttpRequestUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.io.PipedOutputStream;
import java.net.MalformedURLException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author: liyawei
* @Description:
* @Date: Created in 15:39 2022/2/28
*/
@Slf4j
@Service
public class SyncDataServiceImpl implements ISyncDataService{
@Value("${people.appId}")
private String appId;
@Value("${people.host}")
private String host;
@Value("${people.secret}")
private String secret;
@Autowired
private ISysUserService sysUserService;
@Autowired
private ISysDepartService sysDepartService;
@Autowired
private ISysRoleService sysRoleService;
@Autowired
private ISysDepartRoleService sysDepartRoleService;
@Autowired
private ISysDepartRoleUserService sysDepartRoleUserService;
public static void main(String[] args) throws IOException, NoSuchAlgorithmException, InvalidKeyException {
}
/**
* 同步组织信息
* @throws IOException
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
*/
public void syncDepartInfo() throws IOException, NoSuchAlgorithmException, InvalidKeyException {
//查询所有组织列表,children为空
String path = "/people/v1/organization/list";
String queryStr = "app_id=100679&hash_type=sha256";
String resultData = getResultDataOfGet(path, queryStr);
//JSON转实体类
List<PPOrganization> organizationList = JSONArray.parseArray(resultData, PPOrganization.class);
log.info("需要同步的组织数据总数:" + organizationList.size());
for(PPOrganization ppo : organizationList){
//添加当前节点的组织数据
SysDepart sysDepart = new SysDepart();
sysDepart.setId(ppo.getId());
sysDepart.setDepartName(ppo.getName());
sysDepart.setOrgCategory(ppo.getType());
sysDepart.setOrgType(ppo.getTree_level());
sysDepart.setOrgCode(ppo.getCode());
if(StringUtils.isNotBlank(ppo.getParent_path())) {
String parentCode = ppo.getParent_path().substring(ppo.getParent_path().lastIndexOf("/")+1);
sysDepart.setParentCode(parentCode);
}else{
sysDepart.setParentCode(ppo.getParent_path());
}
sysDepart.setDepartOrder(Integer.valueOf(ppo.getId()));
// LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
// sysDepart.setCreateBy(sysUser.getRealname());
sysDepart.setCreateBy("admin");
sysDepart.setCreateTime(new Date());
sysDepart.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
sysDepartService.save(sysDepart);
// int insertRowNum = insertDepartFromTree(ppo, 1);
// log.info(ppo.getName() + "添加成功条数:" + insertRowNum);
}
}
/**
* 先序遍历树,将数据插入数据库
* @param root
*/
public int insertDepartFromTree(PPOrganization root, int i) {
if(root == null)
return i;
//添加当前节点的组织数据
SysDepart sysDepart = new SysDepart();
sysDepart.setId(root.getId());
sysDepart.setDepartName(root.getName());
sysDepart.setOrgCategory(root.getType());
sysDepart.setOrgType(root.getTree_level());
sysDepart.setOrgCode(root.getCode());
String parentCode = root.getParent_path().substring(root.getParent_path().lastIndexOf("/"));
sysDepart.setParentCode(parentCode);
sysDepart.setDepartOrder(i);
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
sysDepart.setCreateBy(sysUser.getRealname());
sysDepart.setCreateTime(new Date());
sysDepart.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
sysDepartService.save(sysDepart);
for(PPOrganization child:root.getChildren())
{
insertDepartFromTree(child, ++i);
}
return i;
}
/**
* 同步岗位信息
* @throws IOException
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
*/
public void syncRoleInfo() throws IOException, NoSuchAlgorithmException, InvalidKeyException {
//同步所有角色
//查询所有角色列表,非树状,children为空
String path = "/people/v1/position/list";
String queryStr = "app_id=100679&hash_type=sha256";
String resultData = getResultDataOfGet(path, queryStr);
//JSON转实体类
List<PPPosition> positionList = JSONArray.parseArray(resultData, PPPosition.class);
List<String> positionCodeList = positionList.stream().map(PPPosition :: getCode).collect(Collectors.toList());
String positionDetailPath = "/people/v1/position/detail";
String positionDetailQueryStr = "app_id=100679&hash_type=sha256&code=";
log.info("需要同步的岗位数据总数:" + positionList.size());
for(String code : positionCodeList){
String queryStrDetail = positionDetailQueryStr + code;
String result = getResultDataOfGet(positionDetailPath, queryStrDetail);
PPPosition position = JSONObject.parseObject(result, PPPosition.class);
SysRole sysRole = new SysRole();
sysRole.setId(position.getId());
sysRole.setRoleName(position.getName());
sysRole.setRoleCode(position.getCode());
sysRole.setParentCode(position.getParent_code());
sysRole.setRoleOrder(Integer.valueOf(position.getId()));
// LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
// sysRole.setCreateBy(sysUser.getRealname());
sysRole.setCreateBy("admin");
sysRole.setCreateTime(new Date());
sysRoleService.save(sysRole);
}
}
/**
* 同步组织岗位关系
* @throws IOException
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
*/
public void syncDepartRoleInfo() throws IOException, NoSuchAlgorithmException, InvalidKeyException {
String path = "/people/v1/organization-position/all";
String queryStr = "app_id=100679&hash_type=sha256";
String resultData = getResultDataOfGet(path, queryStr);
//JSON转实体类
List<PPOrganizationPosition> organizationPositionList = JSONArray.parseArray(resultData, PPOrganizationPosition.class);
log.info("需要同步的组织岗位关系数据总数:" + organizationPositionList.size());
for(PPOrganizationPosition op : organizationPositionList){
SysDepartRole sysDepartRole = new SysDepartRole();
List<SysDepart> sysDepartList = sysDepartService.queryByDepartCode(op.getBiz_org_code());
if(CollectionUtil.isNotEmpty(sysDepartList)){
sysDepartRole.setDepartId(sysDepartList.get(0).getId());
}
List<SysRole> sysRoleList = sysRoleService.queryByRoleCode(op.getBiz_position_code());
if(CollectionUtil.isNotEmpty(sysRoleList)){
sysDepartRole.setRoleId(sysRoleList.get(0).getId());
}
sysDepartRole.setId(op.getId());
sysDepartRoleService.save(sysDepartRole);
}
}
/**
* 同步人员信息及人员-组织岗位关系
* @throws IOException
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
*/
public void syncDepartRoleUserInfo() throws IOException, NoSuchAlgorithmException, InvalidKeyException {
//查询所有人员组织岗位
String path = "/people/v1/employee/organization-position/list";
String queryStr = "app_id=100679&hash_type=sha256";
String resultData = getResultDataOfGet(path, queryStr);
//JSON转实体类
List<PPOrgPosEmployee> orgPosEmployeeList = JSONArray.parseArray(resultData, PPOrgPosEmployee.class);
log.info("需要同步的组织岗位人员关系数据总数:" + orgPosEmployeeList.size());
String employeeDetailPath = "/people/v1/employee/detail";
String employeeDetailQueryStr = "app_id=100679&hash_type=sha256&employee_id=";
for(PPOrgPosEmployee ope : orgPosEmployeeList){
//查询人员详情
String queryStrDetail = employeeDetailQueryStr + ope.getEmployee_id();
String result = getResultDataOfGet(employeeDetailPath, queryStrDetail);
//JSON转实体类
PPEmployee employee = JSONObject.parseObject(result, PPEmployee.class);
//判断用户信息是否已添加,人员-组织岗位关系为多对多
List<SysUser> sysUserList = sysUserService.queryByWorkNo(ope.getEmployee_id());
if (CollectionUtil.isEmpty(sysUserList)) {
//添加用户信息
SysUser sysUser = new SysUser();
sysUser.setId(employee.getId());
sysUser.setUsername(employee.getUser_name());
sysUser.setRealname(employee.getName_in_local_script());
String username = employee.getUser_name();
String password = "nio.com123"; //设置默认密码
//用户默认密码处理
String salt = oConvertUtils.randomGen(8);
String passwordEncode = PasswordUtil.encrypt(username, password, salt);
sysUser.setPassword(passwordEncode);
sysUser.setSalt(salt);
sysUser.setOrgCode(ope.getBiz_org_code());
sysUser.setStatus("Active".equals(employee.getEmployee_status())? CommonConstant.USER_UNFREEZE : CommonConstant.USER_FREEZE);
sysUser.setDelFlag("1".equals(employee.getDelete_flag())? CommonConstant.DEL_FLAG_0 : CommonConstant.DEL_FLAG_1);
sysUser.setThirdId(employee.getWorker_user_id());
sysUser.setActivitiSync(CommonConstant.ACT_SYNC_1);
sysUser.setWorkNo(employee.getEmployee_id());
sysUser.setUpdateTime(employee.getUpdate_time());
sysUser.setCreateTime(new Date());
sysUser.setCreateBy("admin");
sysUser.setUpdateBy("admin");
sysUserService.save(sysUser);
}
//添加组织岗位-人员关系
SysDepartRoleUser sysDepartRoleUser = new SysDepartRoleUser();
sysDepartRoleUser.setId(ope.getId());
sysDepartRoleUser.setUserId(employee.getId());
sysDepartRoleUser.setDroleId(ope.getBiz_org_x_position_id());
sysDepartRoleUserService.save(sysDepartRoleUser);
}
}
/**
* 发送请求,获取同步数据
* @param uri
* @param queryString
* @return
* @throws IOException
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
*/
public String getResultDataOfGet(String uri, String queryString) throws IOException, NoSuchAlgorithmException, InvalidKeyException {
String appId = "100679";
// String appSecret = "CDf2D9404C6ac1B0f7c3e3845ae0282a";
String appSecret = "7C3F03170E3ea489df04Ce8DEC7Df4f7";
// 获取签名
String method ="GET";
String path = uri;
String queryStr = queryString;
Map<String, String> header = new HashMap<>();
String timestamp = HmacSignUtil.getSecondTimestamp(new Date());
queryStr += "&timestamp=" + timestamp;
String sign = HmacSignUtil.getSign(appSecret,method,path,queryStr,header);
// String url = "http://napoleon-fab-test.nioint.com";
String url = "http://napoleon.nioint.com";
url += path + "?";
url += queryStr;
url += "&sign=" + sign;
Map<String, String> headerMap = new HashMap<>();
String response = HttpRequestUtil.getResponseOfGET(url, headerMap);
JSONObject myJson = JSONObject.parseObject(response);
log.debug(myJson.toJSONString());
if(!myJson.get("result_code").toString().equals("success")) {
log.error("请求出现异常:" + myJson.get("result_code") + " " + myJson);
}
log.debug("打印输出本次同步信息返回结果:"+myJson.get("data").toString());
return myJson.get("data").toString();
}
}
@@ -527,4 +527,11 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
return realResult; return realResult;
} }
@Override
public List<SysDepart> queryByDepartCode(String departCode) {
LambdaQueryWrapper<SysDepart> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysDepart::getOrgCode, departCode);
return this.list(queryWrapper);
}
} }
@@ -1,7 +1,9 @@
package com.jero.modules.system.service.impl; package com.jero.modules.system.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
import com.jero.common.api.vo.Result; import com.jero.common.api.vo.Result;
import com.jero.common.constant.CommonConstant; import com.jero.common.constant.CommonConstant;
@@ -90,4 +92,11 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
this.removeByIds(Arrays.asList(roleIds)); this.removeByIds(Arrays.asList(roleIds));
return true; return true;
} }
@Override
public List<SysRole> queryByRoleCode(String roleCode) {
LambdaQueryWrapper<SysRole> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysRole::getRoleCode, roleCode);
return this.list(queryWrapper);
}
} }
@@ -439,4 +439,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return userMapper.queryByDepIds(departIds,username); return userMapper.queryByDepIds(departIds,username);
} }
@Override
public List<SysUser> queryByWorkNo(String workNo) {
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysUser::getWorkNo, workNo);
return this.list(queryWrapper);
}
} }
@@ -158,6 +158,7 @@ public class FindsDepartsChildrenUtil {
sysDepartTreeModel.setOrgCategory(sysDepart.getOrgCategory()); sysDepartTreeModel.setOrgCategory(sysDepart.getOrgCategory());
sysDepartTreeModel.setOrgType(sysDepart.getOrgType()); sysDepartTreeModel.setOrgType(sysDepart.getOrgType());
sysDepartTreeModel.setOrgCode(sysDepart.getOrgCode()); sysDepartTreeModel.setOrgCode(sysDepart.getOrgCode());
sysDepartTreeModel.setOrgCode(sysDepart.getParentCode());
sysDepartTreeModel.setMobile(sysDepart.getMobile()); sysDepartTreeModel.setMobile(sysDepart.getMobile());
sysDepartTreeModel.setFax(sysDepart.getFax()); sysDepartTreeModel.setFax(sysDepart.getFax());
sysDepartTreeModel.setAddress(sysDepart.getAddress()); sysDepartTreeModel.setAddress(sysDepart.getAddress());