mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-07 01:46:47 +08:00
用户同步
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package com.xboe.basic.api;
|
||||
|
||||
import com.xboe.core.JsonResponse;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/org-user")
|
||||
public class userOrgApi {
|
||||
|
||||
|
||||
/**
|
||||
* 新系统查询老系统添加或者更新机构
|
||||
* */
|
||||
@GetMapping("/save-org")
|
||||
public JsonResponse<Boolean> saveOrg(){
|
||||
//查询数据
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新系统查出用户 并根据老库 更新sys_depart_id,commany_id
|
||||
* */
|
||||
@GetMapping("/save-user")
|
||||
public JsonResponse<Boolean> saveUser(){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.basic.entity.Organization;
|
||||
|
||||
@Repository
|
||||
public interface BasicOrganizationDao extends JpaRepository<Organization,String>{
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.xboe.basic.dao;
|
||||
|
||||
import com.xboe.basic.entity.FwOrganization;
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.QueryBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 老系统的机构
|
||||
* */
|
||||
@Slf4j
|
||||
@Repository
|
||||
public class FwOrganizationDao extends BaseDao<FwOrganizationDao> {
|
||||
|
||||
|
||||
/**
|
||||
* 查询全部机构信息
|
||||
*
|
||||
* @param org
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
public List<FwOrganization> list(FwOrganization org, OrderCondition order) {
|
||||
// 删除状态的也同步,用于解决删除数据问题
|
||||
//filters.add(FieldFilters.eq("isDeleted", Constants.DELETED_NORMAL));
|
||||
//String hql="Select org,tn.namePath from FwOrganization org,FwOrgTreeNode tn where org.treeNodeId=tn.kid and tn.isDeleted=0";
|
||||
|
||||
QueryBuilder query=QueryBuilder.from("FwOrganization org,FwOrgTreeNode tn");
|
||||
query.addFields("org","tn.namePath");
|
||||
|
||||
query.addFilter(FieldFilters.eqField("org.treeNodeId", "tn.kid"));
|
||||
//query.addFilter(FieldFilters.eq("tn.isDeleted", 0));
|
||||
if (org != null) {
|
||||
if (StringUtils.isNotBlank(org.getParentOrgnizationId())) {
|
||||
query.addFilter(FieldFilters.eq("org.parentOrgnizationId", org.getParentOrgnizationId()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<FwOrganization> list=new ArrayList<FwOrganization>();
|
||||
|
||||
try {
|
||||
PageList<Object[]> rs = this.findPageFields(query.builder());
|
||||
//List<Object[]> rs=this.findListFields(query.builder());
|
||||
for(Object[] objs : rs.getList()) {
|
||||
FwOrganization fworg=(FwOrganization)objs[0];
|
||||
String namePath=(String)objs[1];
|
||||
fworg.setNamePath(namePath);
|
||||
list.add(fworg);
|
||||
}
|
||||
}catch(Exception e) {
|
||||
log.error("查询机构信息错误",e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.xboe.basic.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.basic.entity.Organization;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
|
||||
@Repository
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
package com.xboe.basic.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = "eln_fw_orgnization")
|
||||
public class FwOrganization {
|
||||
|
||||
/**
|
||||
* 组织部门ID
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "kid", length = 150)
|
||||
private String kid;
|
||||
|
||||
/**
|
||||
* 树节点ID
|
||||
*/
|
||||
@Column(name = "tree_node_id", length = 150)
|
||||
private String treeNodeId;
|
||||
|
||||
/**
|
||||
* 父组织部门ID
|
||||
*/
|
||||
@Column(name = "parent_orgnization_id", length = 150)
|
||||
private String parentOrgnizationId;
|
||||
|
||||
/**
|
||||
* 企业ID
|
||||
*/
|
||||
@Column(name = "company_id", length = 150)
|
||||
private String companyId;
|
||||
|
||||
/**
|
||||
* 域ID
|
||||
*/
|
||||
@Column(name = "domain_id", length = 150)
|
||||
private String domainId;
|
||||
|
||||
/**
|
||||
* 组织部门代码
|
||||
*/
|
||||
@Column(name = "orgnization_code", length = 150)
|
||||
private String orgnizationCode;
|
||||
|
||||
/**
|
||||
* 组织名
|
||||
*/
|
||||
@Column(name = "orgnization_name", length = 150)
|
||||
private String orgnizationName;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Column(name = "description", columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 组织部门经理ID
|
||||
*/
|
||||
@Column(name = "orgnization_manager_id", length = 150)
|
||||
private String orgnizationManagerId;
|
||||
|
||||
/**
|
||||
* 组织级别orgnization_level
|
||||
*/
|
||||
@Column(name = "orgnization_level", length = 150)
|
||||
private String organizationLevel;
|
||||
|
||||
/**
|
||||
* 是否制造组织
|
||||
* 0:否,1:是
|
||||
*/
|
||||
@Column(name = "is_make_org", length = 3)
|
||||
private String isMakeOrg;
|
||||
|
||||
/**
|
||||
* 是否服务现地
|
||||
* 0:否,1:是
|
||||
*/
|
||||
@Column(name = "is_service_site", length = 3)
|
||||
private String isServiceSite;
|
||||
|
||||
/**
|
||||
* 是否默认注册组织
|
||||
* 0:否,1:是
|
||||
*/
|
||||
@Column(name = "is_default_orgnization", length = 3)
|
||||
private String isDefaultOrganization;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* 0:临时,1:正常,2:停用
|
||||
*/
|
||||
@Column(name = "status", length = 3)
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 组织全路径
|
||||
*/
|
||||
@Column(name = "orgnization_name_path")
|
||||
private String namePath;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
@Column(name = "version", length = 11)
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 数据来源
|
||||
*/
|
||||
@Column(name = "data_from", length = 150)
|
||||
private String dataFrom;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
@Column(name = "created_by", length = 150)
|
||||
private String createdBy;
|
||||
|
||||
// /**
|
||||
// * 创建时间
|
||||
// */
|
||||
// @Column(name = "created_at")
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
// private Date createdAt;
|
||||
//
|
||||
// /**
|
||||
// * 创建来源
|
||||
// */
|
||||
// @Column(name = "created_from", length = 150)
|
||||
// private String createdFrom;
|
||||
//
|
||||
// /**
|
||||
// * 创建IP
|
||||
// */
|
||||
// @Column(name = "created_ip", length = 150)
|
||||
// private String createdIp;
|
||||
//
|
||||
// /**
|
||||
// * 更新人ID
|
||||
// */
|
||||
// @Column(name = "updated_by", length = 150)
|
||||
// private String updatedBy;
|
||||
//
|
||||
// /**
|
||||
// * 更新时间
|
||||
// */
|
||||
// @Column(name = "updated_at")
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
// private Date updatedAt;
|
||||
//
|
||||
// /**
|
||||
// * 更新来源
|
||||
// */
|
||||
// @Column(name = "updated_from", length = 150)
|
||||
// private String updatedFrom;
|
||||
//
|
||||
// /**
|
||||
// * 更新IP
|
||||
// */
|
||||
// @Column(name = "updated_ip", length = 150)
|
||||
// private String updatedIp;
|
||||
|
||||
/**
|
||||
* 删除标记;0:正常,1:已删除
|
||||
*/
|
||||
@Column(name = "is_deleted", length = 3)
|
||||
private String isDeleted;
|
||||
|
||||
}
|
||||
@@ -5,8 +5,6 @@ import com.xboe.core.orm.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
@@ -19,58 +17,43 @@ import javax.persistence.Table;
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE + "organization")
|
||||
public class Organization extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 原系统ID
|
||||
*/
|
||||
@Column(name = "kid", length = 36)
|
||||
private String kid;
|
||||
@Column(name = "sys_id", length = 36)
|
||||
private String sysId;
|
||||
|
||||
/**
|
||||
* 旧系统父id
|
||||
*/
|
||||
@Column(name = "sys_parent_id", length = 36)
|
||||
private String sysParentId;
|
||||
|
||||
/**
|
||||
* 组织部门代码
|
||||
*/
|
||||
@Column(name = "code", length = 50)
|
||||
@Column(name = "code", nullable = false, length = 50)
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 组织名
|
||||
*/
|
||||
@Column(name = "name", nullable = false, length = 100)
|
||||
@Column(name = "name", nullable = false, length = 50)
|
||||
private String name;
|
||||
|
||||
|
||||
/**
|
||||
* 路径,不用每次都去计算了,用默认tree的
|
||||
* 组织全路径
|
||||
*/
|
||||
@Column(name = "name_path", length = 300)
|
||||
@Column(name = "name_path")
|
||||
private String namePath;
|
||||
|
||||
|
||||
/**
|
||||
* 机构名称简称
|
||||
* 父组织部门ID
|
||||
*/
|
||||
@Column(name = "short_name",length = 30)
|
||||
private String shortName;
|
||||
|
||||
/**
|
||||
* 多租户下的id,此机构属于哪个sass用户
|
||||
*/
|
||||
@Column(name = "sass_id",length = 36)
|
||||
private String sassId;
|
||||
|
||||
/**
|
||||
* 系统级别
|
||||
*/
|
||||
@Column(name = "sys_level",length = 2)
|
||||
private Integer sysLevel;
|
||||
|
||||
/**
|
||||
* 是否是默认注册组织机构
|
||||
*/
|
||||
@Column(name = "is_default",length = 1)
|
||||
private Boolean isDefault;
|
||||
|
||||
@Column(name = "parent_id", length = 18)
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
@@ -79,22 +62,22 @@ public class Organization extends BaseEntity {
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 数据来源
|
||||
* 企业ID
|
||||
*/
|
||||
@Column(name = "data_from", length = 100)
|
||||
private String dataFrom;
|
||||
@Column(name = "company_id", length = 36)
|
||||
private String companyId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
* 域ID
|
||||
*/
|
||||
// @Column(name = "create_time", length = 36)
|
||||
// private LocalDateTime createTime;
|
||||
@Column(name = "domain_id", length = 36)
|
||||
private String domainId;
|
||||
|
||||
/**
|
||||
* 创建来源
|
||||
* 组织部门经理ID
|
||||
*/
|
||||
@Column(name = "create_from", length = 100)
|
||||
private String createFrom;
|
||||
@Column(name = "orgnization_manager_id", length = 36)
|
||||
private String orgnizationManagerId;
|
||||
|
||||
/**
|
||||
* 组织级别
|
||||
@@ -114,16 +97,17 @@ public class Organization extends BaseEntity {
|
||||
@Column(name = "is_service_site", length = 1)
|
||||
private Boolean isServiceSite;
|
||||
|
||||
/**
|
||||
* 是否默认注册组织
|
||||
*/
|
||||
@Column(name = "is_default_organization", length = 1)
|
||||
private Boolean isDefaultOrganization;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* 0:临时,1:正常,2:停用
|
||||
*/
|
||||
@Column(name = "status", nullable = false, length = 1)
|
||||
private Integer status;
|
||||
|
||||
@Column(name = "remark", length = 200)
|
||||
private String remark;
|
||||
|
||||
// @Column(name = "deleted")
|
||||
// private Boolean deleted;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.xboe.basic.service;
|
||||
|
||||
import com.xboe.basic.entity.FwOrganization;
|
||||
import com.xboe.basic.entity.Organization;
|
||||
import com.xboe.common.OrderCondition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IFwOrganizationService {
|
||||
|
||||
/**
|
||||
* 查询指定条数的机构信息
|
||||
*
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @param org
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
List<FwOrganization> list(FwOrganization org, OrderCondition order);
|
||||
|
||||
|
||||
/**
|
||||
* 更新或者添加机构 -----读上面数据往新系统加
|
||||
* */
|
||||
void saveOrg(List<Organization> list);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.xboe.basic.service;
|
||||
|
||||
import com.xboe.basic.entity.Organization;
|
||||
|
||||
public interface IOrganizationService {
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.xboe.basic.dao.UserDao;
|
||||
import com.xboe.basic.entity.Account;
|
||||
import com.xboe.basic.entity.ErrorLog;
|
||||
import com.xboe.basic.entity.OrgTree;
|
||||
import com.xboe.basic.entity.Organization;
|
||||
import com.xboe.basic.entity.Person;
|
||||
import com.xboe.basic.entity.User;
|
||||
import com.xboe.basic.service.IBasicDataSyncService;
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.xboe.basic.service.impl;
|
||||
|
||||
import com.xboe.basic.dao.FwOrganizationDao;
|
||||
import com.xboe.basic.entity.FwOrganization;
|
||||
import com.xboe.basic.entity.Organization;
|
||||
import com.xboe.basic.service.IFwOrganizationService;
|
||||
import com.xboe.common.OrderCondition;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 老系统的机构
|
||||
* */
|
||||
@Service
|
||||
public class FWOrganizationServiceImpl implements IFwOrganizationService {
|
||||
|
||||
@Resource
|
||||
FwOrganizationDao dao;
|
||||
|
||||
@Override
|
||||
public List<FwOrganization> list(FwOrganization org, OrderCondition order) {
|
||||
List<FwOrganization> list = dao.list(org, order);
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveOrg(List<Organization> list) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private Organization organizationToEntity(FwOrganization org) {
|
||||
Organization ov = new Organization();
|
||||
// ov.setChildren();
|
||||
// ov.setParentName();
|
||||
ov.setCode(org.getOrgnizationCode());
|
||||
ov.setName(org.getOrgnizationName());
|
||||
ov.setSysId(org.getKid());
|
||||
ov.setSysParentId(org.getParentOrgnizationId());
|
||||
ov.setDescription(org.getDescription());
|
||||
ov.setCompanyId(org.getCompanyId());
|
||||
ov.setDomainId(org.getDomainId());
|
||||
ov.setNamePath(org.getNamePath());
|
||||
ov.setOrgnizationManagerId(org.getOrgnizationManagerId());
|
||||
ov.setOrganizationLevel(org.getOrganizationLevel());
|
||||
if(StringUtils.isNotBlank(org.getIsMakeOrg())){
|
||||
ov.setIsMakeOrg("1".equals(org.getIsMakeOrg()));//0:否,1:是
|
||||
}
|
||||
if(StringUtils.isNotBlank(org.getIsServiceSite())) {
|
||||
ov.setIsServiceSite("1".equals(org.getIsServiceSite()));//0:否,1:是
|
||||
}
|
||||
if(StringUtils.isNotBlank(org.getIsDefaultOrganization())) {
|
||||
ov.setIsDefaultOrganization("1".equals(org.getIsDefaultOrganization()));//0:否,1:是
|
||||
}
|
||||
if(StringUtils.isNotBlank(org.getStatus())) {
|
||||
ov.setStatus(Integer.parseInt(org.getStatus()));
|
||||
}else{
|
||||
ov.setStatus(1);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(org.getIsDeleted())) {
|
||||
ov.setDeleted("1".equals(org.getIsDeleted())); //0:正常,1:已删除
|
||||
}
|
||||
return ov;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,25 +1,5 @@
|
||||
package com.xboe;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import com.xboe.basic.dao.BasicOrganizationDao;
|
||||
import com.xboe.basic.dao.ErrorLogDao;
|
||||
import com.xboe.basic.entity.Organization;
|
||||
import com.xboe.basic.service.IBasicDataSyncService;
|
||||
import com.xboe.common.utils.IDGenerator;
|
||||
import com.xboe.dto.OrganizationDto;
|
||||
import com.xboe.primary.dao.MainAccountDao;
|
||||
import com.xboe.primary.dao.MainOrganizationDao;
|
||||
import com.xboe.primary.entity.MainOrganization;
|
||||
import com.xboe.primary.service.IMainDbSyncService;
|
||||
|
||||
//@SpringBootTest
|
||||
public class MultiDbTest {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user