mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-07 18:06:50 +08:00
更新
This commit is contained in:
@@ -1,9 +1,22 @@
|
||||
package com.xboe;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.xboe.basic.entity.OldOrganization;
|
||||
import com.xboe.basic.entity.OldUser;
|
||||
import com.xboe.basic.service.IOldService;
|
||||
import com.xboe.primary.entity.MainOrganization;
|
||||
import com.xboe.primary.entity.MainUser;
|
||||
import com.xboe.primary.service.IMainDbSyncService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
@@ -15,11 +28,49 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Component
|
||||
public class StartRunner implements ApplicationRunner {
|
||||
|
||||
@Autowired
|
||||
IOldService oldService;
|
||||
|
||||
@Autowired
|
||||
IMainDbSyncService mainService;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
|
||||
//用于存放 kid=newId
|
||||
Map<String,String> mainOrgMap=new HashMap<String,String>();
|
||||
try {
|
||||
//启动执行一次
|
||||
//同步机构
|
||||
List<OldOrganization> allList =oldService.listAll();
|
||||
for(OldOrganization org :allList) {
|
||||
MainOrganization mainOrg = mainService.findByKid(org.getKid());
|
||||
if(mainOrg==null) {
|
||||
//添加
|
||||
mainOrg=organizationToEntity(org);
|
||||
mainService.save(mainOrg);
|
||||
}else {
|
||||
//更新
|
||||
copyOrganizationToEntity(mainOrg,org);
|
||||
mainService.update(mainOrg);
|
||||
}
|
||||
mainOrgMap.put(org.getKid(),mainOrg.getId());//
|
||||
}
|
||||
//同步用户信息
|
||||
//查询出本地用户
|
||||
List<MainUser> allUsers=mainService.findAll();
|
||||
for(MainUser mainUser : allUsers) {
|
||||
OldUser oldUser = oldService.getByUserKid(mainUser.getSysId());
|
||||
if(oldUser!=null) {
|
||||
String newId=mainOrgMap.get(oldUser.getKid());
|
||||
if(StringUtils.isBlank(newId)) {
|
||||
log.error("未找到【"+oldUser.getKid()+"】对应的机构id,不更新用户");
|
||||
}else {
|
||||
mainUser.setSysDepartId(oldUser.getOrgnizationId());
|
||||
mainUser.setCompanyId(oldUser.getCompanyId());
|
||||
mainUser.setDepartId(newId);
|
||||
mainService.updateUser(mainUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("执行失败",e);
|
||||
@@ -27,5 +78,50 @@ public class StartRunner implements ApplicationRunner {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void copyOrganizationToEntity(MainOrganization ov ,OldOrganization org) {
|
||||
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(org.getIsDeleted()!=null) {
|
||||
ov.setDeleted(org.getIsDeleted()==0? false:true); //0:正常,1:已删除
|
||||
}else {
|
||||
ov.setDeleted(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 转化对象
|
||||
* @param org
|
||||
* @return
|
||||
*/
|
||||
private MainOrganization organizationToEntity(OldOrganization org) {
|
||||
MainOrganization ov = new MainOrganization();
|
||||
copyOrganizationToEntity(ov,org);
|
||||
return ov;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.xboe.basic.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.basic.entity.Account;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
|
||||
/**
|
||||
* 账号信息DAO
|
||||
*/
|
||||
@Repository
|
||||
public class AccountDao extends BaseDao<Account> {
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.xboe.basic.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface BasicOrganizationDao extends JpaRepository<Organization,String>{
|
||||
|
||||
@Query(value = "from Organization where kid=?1")
|
||||
public List<Organization> getByKid(String id);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.xboe.basic.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.basic.entity.ErrorLog;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
|
||||
@Repository
|
||||
public class ErrorLogDao extends BaseDao<ErrorLog>{
|
||||
|
||||
}
|
||||
@@ -1,24 +1,24 @@
|
||||
package com.xboe.basic.dao;
|
||||
|
||||
import com.xboe.basic.entity.FwOrganization;
|
||||
import com.xboe.common.OrderCondition;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.basic.entity.OldOrganization;
|
||||
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;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 老系统的机构
|
||||
* */
|
||||
@Slf4j
|
||||
@Repository
|
||||
public class FwOrganizationDao extends BaseDao<FwOrganizationDao> {
|
||||
public class OldOrganizationDao extends BaseDao<OldOrganization> {
|
||||
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ public class FwOrganizationDao extends BaseDao<FwOrganizationDao> {
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
public List<FwOrganization> list(FwOrganization org, OrderCondition order) {
|
||||
public List<OldOrganization> listAll() {
|
||||
// 删除状态的也同步,用于解决删除数据问题
|
||||
//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";
|
||||
@@ -37,21 +37,16 @@ public class FwOrganizationDao extends BaseDao<FwOrganizationDao> {
|
||||
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>();
|
||||
query.addFilter(FieldFilters.eq("org.isDeleted", 0));
|
||||
|
||||
|
||||
List<OldOrganization> list=new ArrayList<OldOrganization>();
|
||||
|
||||
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];
|
||||
OldOrganization fworg=(OldOrganization)objs[0];
|
||||
String namePath=(String)objs[1];
|
||||
fworg.setNamePath(namePath);
|
||||
list.add(fworg);
|
||||
@@ -2,10 +2,10 @@ package com.xboe.basic.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.basic.entity.Person;
|
||||
import com.xboe.basic.entity.OldUser;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
|
||||
@Repository
|
||||
public class PersonDao extends BaseDao<Person>{
|
||||
public class OldUserDao extends BaseDao<OldUser>{
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.xboe.basic.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.basic.entity.OrgTree;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
|
||||
@Repository
|
||||
public class OrgTreeDao extends BaseDao<OrgTree> {
|
||||
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.xboe.basic.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
|
||||
@Repository
|
||||
public class OrganizationDao extends BaseDao<Organization> {
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.xboe.basic.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.basic.entity.User;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
|
||||
@Repository
|
||||
public class UserDao extends BaseDao<User> {
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.xboe.basic.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.basic.entity.ViewUser;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
|
||||
//@Repository
|
||||
public class ViewUserDao extends BaseDao<ViewUser> {
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package com.xboe.basic.entity;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
import com.xboe.core.orm.annotation.MetaInfo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 账号表,只是记录登录的账号信息,无任务业务实名类的信息
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE + "account")
|
||||
public class Account extends IdEntity{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**0 临时数据*/
|
||||
public static final int STATUS_TEMPORARY=0;
|
||||
|
||||
/**1 正常数据*/
|
||||
public static final int STATUS_NORMAL=1;
|
||||
|
||||
/**2 停用数据*/
|
||||
public static final int STATUS_DEAD=2;
|
||||
|
||||
@MetaInfo("人员id")
|
||||
@Column(name = "person_id", length = 36)
|
||||
private String personId;
|
||||
|
||||
@MetaInfo("登录名")
|
||||
@Column(name = "login_name", nullable = true, length = 30)
|
||||
private String loginName;
|
||||
|
||||
@MetaInfo("用户头像地址")
|
||||
@Column(name = "avatar", nullable = true, length = 100)
|
||||
private String avatar;
|
||||
|
||||
@MetaInfo("手机号")
|
||||
@Column(name = "mobile", length = 11)
|
||||
private String mobile;
|
||||
|
||||
@Column(name = "email", length = 100)
|
||||
private String email;
|
||||
|
||||
@Column(name = "nick_name", length = 20)
|
||||
private String nickName;
|
||||
|
||||
@Column(name = "pass_key", length = 6)
|
||||
private String passKey;
|
||||
|
||||
@Column(name = "pass_value", length = 32)
|
||||
private String passValue;
|
||||
|
||||
@Column(name = "reg_time" )
|
||||
private LocalDateTime regTime;
|
||||
|
||||
@MetaInfo("语言")
|
||||
@Column(name = "language",length=30)
|
||||
private String language;
|
||||
|
||||
/**
|
||||
* 0临时,1 正常,2停用
|
||||
*/
|
||||
@Column(name = "status", length = 1)
|
||||
private Integer status;
|
||||
|
||||
@Column(name = "deleted", length = 1)
|
||||
private Boolean deleted;
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.xboe.basic.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
import com.xboe.core.orm.annotation.MetaInfo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE + "log_error")
|
||||
public class ErrorLog extends IdEntity{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@MetaInfo("日志时间")
|
||||
@Column(name = "log_time" )
|
||||
private LocalDateTime logTime;
|
||||
|
||||
@MetaInfo("日志对象")
|
||||
@Column(name = "log_object", columnDefinition = "text")
|
||||
private String logObject;
|
||||
|
||||
@MetaInfo("日志错误内容")
|
||||
@Column(name = "log_error", length=500)
|
||||
private String logError;
|
||||
|
||||
@MetaInfo("数据的id")
|
||||
@Column(name = "data_id", length=36)
|
||||
private String dataId;
|
||||
|
||||
@MetaInfo("生成的新的id")
|
||||
@Column(name = "new_id", length=36)
|
||||
private String newId;
|
||||
|
||||
@MetaInfo("数据类型,1表同步机构,2表同步用户,3表删除机构,4表删除用户")
|
||||
@Column(name = "data_type", length=1)
|
||||
private Integer dataType;
|
||||
|
||||
@Column(name = "error_type", length=1)
|
||||
private Integer type;//1是同步,2是内部同步
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import javax.persistence.Table;
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = "eln_fw_orgnization")
|
||||
public class FwOrganization {
|
||||
public class OldOrganization {
|
||||
|
||||
/**
|
||||
* 组织部门ID
|
||||
@@ -177,6 +177,6 @@ public class FwOrganization {
|
||||
* 删除标记;0:正常,1:已删除
|
||||
*/
|
||||
@Column(name = "is_deleted", length = 3)
|
||||
private String isDeleted;
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.xboe.basic.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 用户信息表
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = "eln_fw_user")
|
||||
public class OldUser implements java.io.Serializable{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "kid", length = 150)
|
||||
private String kid;
|
||||
|
||||
/**
|
||||
* 员工编号
|
||||
*/
|
||||
@Column(name = "user_no", length = 90)
|
||||
private String userNo;
|
||||
|
||||
|
||||
/**
|
||||
* 状态;0:临时,1:正常,2:停用
|
||||
*/
|
||||
@Column(name = "status", length = 3)
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 企业ID
|
||||
*/
|
||||
@Column(name = "company_id", length = 150)
|
||||
private String companyId;
|
||||
|
||||
/**
|
||||
* 组织部门ID
|
||||
*/
|
||||
@Column(name = "orgnization_id", length = 150)
|
||||
private String orgnizationId;
|
||||
|
||||
/**
|
||||
* 删除标记;0:正常,1:已删除
|
||||
*/
|
||||
@Column(name = "is_deleted", length = 3)
|
||||
private String isDeleted;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.xboe.basic.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE+"org_tree")
|
||||
public class OrgTree extends IdEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 机构id
|
||||
* */
|
||||
@Column(name = "org_id",length = 20)
|
||||
private String orgId;
|
||||
|
||||
/**
|
||||
* 上级id
|
||||
* */
|
||||
@Column(name = "parent_id",length = 36)
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 原系统的上级id
|
||||
*/
|
||||
@Column(name = "old_parent_id",length = 36)
|
||||
private String oldParentId;
|
||||
|
||||
/**
|
||||
* 体系标识
|
||||
* */
|
||||
@Column(name = "tree_type",length = 20)
|
||||
private String treeType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
* */
|
||||
@Column(name = "remark",length = 200)
|
||||
private String remark;
|
||||
|
||||
/**机构的路径,下次更新应该加上*/
|
||||
@Column(name = "name_path",length = 200)
|
||||
private String namePath;
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
package com.xboe.basic.entity;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* 机构实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE + "organization")
|
||||
public class Organization extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 原系统ID
|
||||
*/
|
||||
@Column(name = "sys_id", length = 36)
|
||||
private String sysId;
|
||||
|
||||
/**
|
||||
* 旧系统父id
|
||||
*/
|
||||
@Column(name = "sys_parent_id", length = 36)
|
||||
private String sysParentId;
|
||||
|
||||
/**
|
||||
* 组织部门代码
|
||||
*/
|
||||
@Column(name = "code", nullable = false, length = 50)
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 组织名
|
||||
*/
|
||||
@Column(name = "name", nullable = false, length = 50)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 组织全路径
|
||||
*/
|
||||
@Column(name = "name_path")
|
||||
private String namePath;
|
||||
|
||||
/**
|
||||
* 父组织部门ID
|
||||
*/
|
||||
@Column(name = "parent_id", length = 18)
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Column(name = "description", columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 企业ID
|
||||
*/
|
||||
@Column(name = "company_id", length = 36)
|
||||
private String companyId;
|
||||
|
||||
/**
|
||||
* 域ID
|
||||
*/
|
||||
@Column(name = "domain_id", length = 36)
|
||||
private String domainId;
|
||||
|
||||
/**
|
||||
* 组织部门经理ID
|
||||
*/
|
||||
@Column(name = "orgnization_manager_id", length = 36)
|
||||
private String orgnizationManagerId;
|
||||
|
||||
/**
|
||||
* 组织级别
|
||||
*/
|
||||
@Column(name = "organization_level", length = 50)
|
||||
private String organizationLevel;
|
||||
|
||||
/**
|
||||
* 是否制造组织
|
||||
*/
|
||||
@Column(name = "is_make_org", length = 1)
|
||||
private Boolean isMakeOrg;
|
||||
|
||||
/**
|
||||
* 是否服务现地
|
||||
*/
|
||||
@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;
|
||||
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
package com.xboe.basic.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE+"person")
|
||||
public class Person extends IdEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**临时数据*/
|
||||
public static final int STATUS_TEMPORARY=0;
|
||||
|
||||
/**正常数据*/
|
||||
public static final int STATUS_NORMAL=1;
|
||||
|
||||
/**死数据*/
|
||||
public static final int STATUS_DEAD=4;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
* */
|
||||
@Column(name = "name",length = 100)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
* */
|
||||
@Column(name = "gender",length = 1)
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 出生日期
|
||||
* */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Column(name = "birthday")
|
||||
private LocalDateTime birthday;
|
||||
|
||||
/**
|
||||
* 证件类型
|
||||
* */
|
||||
@Column(name = "id_type")
|
||||
private String idType;
|
||||
|
||||
/**
|
||||
* 证件号码
|
||||
* */
|
||||
@Column(name = "id_number",length = 18)
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 家庭电话
|
||||
*/
|
||||
@Column(name = "home_phone_no", length = 50)
|
||||
private String homePhoneNo;
|
||||
|
||||
/**
|
||||
* 国籍
|
||||
*/
|
||||
@Column(name = "nationality", length = 50)
|
||||
private String nationality;
|
||||
|
||||
|
||||
/**
|
||||
* 民族
|
||||
* */
|
||||
@Column(name = "nation")
|
||||
private String nation;
|
||||
|
||||
/**
|
||||
* 毕业院校
|
||||
*/
|
||||
@Column(name = "graduated_from", length = 50)
|
||||
private String graduatedFrom;
|
||||
|
||||
/**
|
||||
* 毕业专业
|
||||
*/
|
||||
@Column(name = "graduated_major", length = 50)
|
||||
private String graduatedMajor;
|
||||
|
||||
/**
|
||||
* 最高学历
|
||||
*/
|
||||
@Column(name = "highest_education", length = 50)
|
||||
private String highestEducation;
|
||||
|
||||
/**
|
||||
* 数据来源说明
|
||||
* */
|
||||
@Column(name = "data_from",length = 500)
|
||||
private String dataFrom;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* 0表临时,1表正常。。。4表已删除
|
||||
* */
|
||||
@Column(name = "status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
*备注
|
||||
* */
|
||||
@Column(name = "remark")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
package com.xboe.basic.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 用户信息表
|
||||
* 存储所有的用户信息,原表中的部分信息
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE + "user")
|
||||
public class User extends IdEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 人员基本信息id
|
||||
*/
|
||||
@Column(name = "person_id", length = 19)
|
||||
private String personId;
|
||||
|
||||
/**
|
||||
* 原系统的kid
|
||||
*/
|
||||
@Column(name = "kid", length = 36)
|
||||
private String kid;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Column(name = "mobile", length = 30)
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 默认的组织机构体系
|
||||
*/
|
||||
@Column(name = "org_tree_type", length = 19)
|
||||
private String orgTreeType;
|
||||
|
||||
|
||||
@Column(name = "old_enterprise_id", length = 36)
|
||||
private String oldEnterpriseId;
|
||||
|
||||
/**
|
||||
* 旧系统机构id
|
||||
*/
|
||||
@Column(name = "old_depart_id", length = 36)
|
||||
private String oldDepartId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@Column(name = "name", length = 30)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 员工编号
|
||||
*/
|
||||
@Column(name = "user_no", length = 30)
|
||||
private String userNo;
|
||||
|
||||
/**
|
||||
* 所在公司
|
||||
*/
|
||||
@Column(name = "enterprise_id", length = 36)
|
||||
private String enterpriseId;
|
||||
|
||||
/**级别代码*/
|
||||
@Column(name = "band_code", length = 20)
|
||||
private String bandCode;
|
||||
|
||||
/**级别描述*/
|
||||
@Column(name = "band_desc", length = 200)
|
||||
private String bandDesc;
|
||||
|
||||
/**
|
||||
* 发薪地id
|
||||
*/
|
||||
@Column(name = "payroll_place_id",length=36)
|
||||
private String payrollPlaceId;
|
||||
|
||||
/**
|
||||
* 发薪地名称
|
||||
*/
|
||||
@Column(name = "payroll_place_name",length=150)
|
||||
private String payrollPlaceName;
|
||||
|
||||
|
||||
/**
|
||||
* 管理序列职级
|
||||
*/
|
||||
@Column(name = "position_mgr_level", length = 150)
|
||||
private String positionMgrLevel;
|
||||
|
||||
/**
|
||||
* 所在部门
|
||||
*/
|
||||
@Column(name = "depart_id", length = 18)
|
||||
private String departId;
|
||||
|
||||
/**
|
||||
* 机构名称/分隔的全路径
|
||||
*/
|
||||
@Column(name = "org_name_path", length = 300)
|
||||
private String orgNamePath;
|
||||
|
||||
|
||||
/**
|
||||
* 所在域
|
||||
*/
|
||||
@Column(name = "domain_id", length = 36)
|
||||
private String domainId;
|
||||
|
||||
/**
|
||||
* 扩展字段,多租户系统的标识值,原系统的companyId
|
||||
*/
|
||||
@Column(name = "sass_id", length = 36)
|
||||
private String sassId;
|
||||
|
||||
|
||||
/**
|
||||
* 办公电话
|
||||
*/
|
||||
@Column(name = "telephone_no", length = 50)
|
||||
private String telephoneNo;
|
||||
|
||||
/**
|
||||
* 职务
|
||||
*/
|
||||
@Column(name = "duty", length = 50)
|
||||
private String duty;
|
||||
|
||||
/**
|
||||
* 职级
|
||||
*/
|
||||
@Column(name = "rank", length = 50)
|
||||
private String rank;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Column(name = "description")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* boe的时长,和系统时长单独保存
|
||||
*/
|
||||
@Column(name = "learning_Duration", length = 11)
|
||||
private Integer learningDuration;
|
||||
|
||||
/**
|
||||
* 在职状态,2在职,3是离职
|
||||
*/
|
||||
@Column(name = "employee_status", length = 1)
|
||||
private Integer employeeStatus;
|
||||
|
||||
/**
|
||||
* 0临时,1是正常,2是停用
|
||||
*/
|
||||
@Column(name = "status", length = 1)
|
||||
private Integer status;
|
||||
|
||||
@Column(name = "deleted")
|
||||
private Boolean deleted;
|
||||
|
||||
}
|
||||
@@ -1,358 +0,0 @@
|
||||
package com.xboe.basic.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
import com.xboe.core.orm.annotation.MetaInfo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 账户,人员,机构,用户的合表
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
//@Entity
|
||||
//@Table(name = SysConstant.TABLE_PRE + "view_user")
|
||||
public class ViewUser extends IdEntity{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@MetaInfo("原系统中的id")
|
||||
@Column(name = "sys_id", length = 36)
|
||||
private String sysId;
|
||||
|
||||
@MetaInfo("登录名")
|
||||
@Column(name = "login_name", nullable = true, length = 30)
|
||||
private String loginName;
|
||||
|
||||
@MetaInfo("用户头像地址")
|
||||
@Column(name = "avatar", nullable = true, length = 100)
|
||||
private String avatar;
|
||||
|
||||
@MetaInfo("手机号")
|
||||
@Column(name = "mobile", length = 11)
|
||||
private String mobile;
|
||||
|
||||
@Column(name = "email", length = 100)
|
||||
private String email;
|
||||
|
||||
@Column(name = "nick_name", length = 20)
|
||||
private String nickName;
|
||||
|
||||
@Column(name = "pass_key", length = 6)
|
||||
private String passKey;
|
||||
|
||||
@Column(name = "pass_value", length = 32)
|
||||
private String passValue;
|
||||
|
||||
@Column(name = "reg_time" )
|
||||
private LocalDateTime regTime;
|
||||
|
||||
@MetaInfo("关联的公司id")
|
||||
@Column(name = "company_id", length = 36)
|
||||
private String companyId;
|
||||
|
||||
// 状态1, 正常,2停用
|
||||
@Column(name = "status", length = 1)
|
||||
private Integer status;
|
||||
|
||||
@Column(name = "deleted", length = 1)
|
||||
private Boolean deleted;
|
||||
|
||||
/*
|
||||
* 旧系统父id
|
||||
*/
|
||||
@Column(name = "sys_parent_id", length = 36)
|
||||
private String sysParentId;
|
||||
|
||||
/**
|
||||
* 组织部门代码
|
||||
*/
|
||||
@Column(name = "code", nullable = false, length = 50)
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 组织名
|
||||
*/
|
||||
@Column(name = "org_name", nullable = false, length = 50)
|
||||
private String orgName;
|
||||
|
||||
/**
|
||||
* 组织全路径
|
||||
*/
|
||||
@Column(name = "name_path")
|
||||
private String namePath;
|
||||
|
||||
/**
|
||||
* 父组织部门ID
|
||||
*/
|
||||
@Column(name = "parent_id", length = 18)
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Column(name = "description", columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 域ID
|
||||
*/
|
||||
@Column(name = "domain_id", length = 36)
|
||||
private String domainId;
|
||||
|
||||
/**
|
||||
* 组织部门经理ID
|
||||
*/
|
||||
@Column(name = "orgnization_manager_id", length = 36)
|
||||
private String orgnizationManagerId;
|
||||
|
||||
/**
|
||||
* 组织级别
|
||||
*/
|
||||
@Column(name = "organization_level", length = 50)
|
||||
private String organizationLevel;
|
||||
|
||||
/**
|
||||
* 是否制造组织
|
||||
*/
|
||||
@Column(name = "is_make_org", length = 1)
|
||||
private Boolean isMakeOrg;
|
||||
|
||||
/**
|
||||
* 是否服务现地
|
||||
*/
|
||||
@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 = "org_status", nullable = false, length = 1)
|
||||
private Integer orgStatus;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
* */
|
||||
@Column(name = "name",length = 100)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
* */
|
||||
@Column(name = "gender",length = 1)
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 出生日期
|
||||
* */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Column(name = "birthday")
|
||||
private LocalDateTime birthday;
|
||||
|
||||
/**
|
||||
* 证件类型
|
||||
* */
|
||||
@Column(name = "id_type")
|
||||
private String idType;
|
||||
|
||||
/**
|
||||
* 证件号码
|
||||
* */
|
||||
@Column(name = "id_number",length = 18)
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 家庭电话
|
||||
*/
|
||||
@Column(name = "home_phone_no", length = 50)
|
||||
private String homePhoneNo;
|
||||
|
||||
/**
|
||||
* 国籍
|
||||
*/
|
||||
@Column(name = "nationality", length = 50)
|
||||
private String nationality;
|
||||
|
||||
|
||||
/**
|
||||
* 民族
|
||||
* */
|
||||
@Column(name = "nation")
|
||||
private String nation;
|
||||
|
||||
/**
|
||||
* 毕业院校
|
||||
*/
|
||||
@Column(name = "graduated_from", length = 50)
|
||||
private String graduatedFrom;
|
||||
|
||||
/**
|
||||
* 毕业专业
|
||||
*/
|
||||
@Column(name = "graduated_major", length = 50)
|
||||
private String graduatedMajor;
|
||||
|
||||
/**
|
||||
* 最高学历
|
||||
*/
|
||||
@Column(name = "highest_education", length = 50)
|
||||
private String highestEducation;
|
||||
|
||||
/**
|
||||
* 数据来源说明
|
||||
* */
|
||||
@Column(name = "data_from",length = 500)
|
||||
private String dataFrom;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* 0表临时,1表正常。。。9表不存在
|
||||
* */
|
||||
@Column(name = "user_status")
|
||||
private Integer userStatus;
|
||||
|
||||
/**
|
||||
*备注
|
||||
* */
|
||||
@Column(name = "remark")
|
||||
private String remark;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 旧系统机构id
|
||||
*/
|
||||
@Column(name = "sys_depart_id", length = 36)
|
||||
private String sysDepartId;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 员工编号
|
||||
*/
|
||||
@Column(name = "user_no", length = 30)
|
||||
private String userNo;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Column(name = "mobile_no", length = 11)
|
||||
private String mobileNo;
|
||||
|
||||
/**
|
||||
* 办公电话
|
||||
*/
|
||||
@Column(name = "telephone_no", length = 50)
|
||||
private String telephoneNo;
|
||||
|
||||
/**
|
||||
* 职务
|
||||
*/
|
||||
@Column(name = "duty", length = 50)
|
||||
private String duty;
|
||||
|
||||
/**
|
||||
* 职级
|
||||
*/
|
||||
@Column(name = "rank", length = 50)
|
||||
private String rank;
|
||||
|
||||
|
||||
|
||||
@Transient
|
||||
private String departName;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 扩展字段,多租户系统的标识值
|
||||
*/
|
||||
@Column(name = "sass_id", length = 18)
|
||||
private String sassId;
|
||||
|
||||
/**
|
||||
* 用户类型,1表学员,2表教师,3表管理员
|
||||
* 该字段暂用于表示是否前台管理员
|
||||
*/
|
||||
@Column(name = "user_type", length = 1)
|
||||
private Integer userType;
|
||||
|
||||
/**
|
||||
* 学习总时长
|
||||
*/
|
||||
@Column(name = "study_total", length = 11)
|
||||
private Integer studyTotal;
|
||||
|
||||
/**
|
||||
* boe的时长,和系统时长单独保存
|
||||
*/
|
||||
@Column(name = "learning_Duration", length = 11)
|
||||
private Integer learningDuration;
|
||||
|
||||
/**
|
||||
* 最近一次登录时间
|
||||
*/
|
||||
@Column(name = "last_login_at")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime lastLoginAt;
|
||||
|
||||
/**
|
||||
* 最近一次登录IP
|
||||
*/
|
||||
@Column(name = "last_login_ip", length = 30)
|
||||
private String lastLoginIp;
|
||||
|
||||
/**
|
||||
* 最近一次登录MAC地址
|
||||
*/
|
||||
@Column(name = "last_login_mac", length = 30)
|
||||
private String lastLoginMac;
|
||||
|
||||
/**
|
||||
* 最近一次操作时间
|
||||
*/
|
||||
@Column(name = "last_action_at")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime lastActionAt;
|
||||
|
||||
/**
|
||||
* 最近一次操作IP
|
||||
*/
|
||||
@Column(name = "last_action_ip", length = 30)
|
||||
private String lastActionIp;
|
||||
|
||||
/**
|
||||
* 最近一次操作MAC地址
|
||||
*/
|
||||
@Column(name = "last_action_mac", length = 30)
|
||||
private String lastActionMac;
|
||||
|
||||
/**
|
||||
* 在线状态;
|
||||
* 0:离线,1:在线
|
||||
*/
|
||||
@Column(name = "online", length = 1)
|
||||
private Boolean online;
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.xboe.basic.service;
|
||||
|
||||
import com.xboe.basic.entity.ErrorLog;
|
||||
import com.xboe.basic.entity.User;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.dto.OrganizationDto;
|
||||
import com.xboe.dto.UserDto;
|
||||
|
||||
/**
|
||||
* 基本数据同步的相关处理
|
||||
* @author seastar
|
||||
*
|
||||
*/
|
||||
public interface IBasicDataSyncService {
|
||||
|
||||
/**
|
||||
* 同步机构数据
|
||||
* @param dto
|
||||
*/
|
||||
void syncOrganization(OrganizationDto dto);
|
||||
|
||||
/**
|
||||
* 同步人员数据
|
||||
* @param dto
|
||||
*/
|
||||
void syncUser(UserDto dto);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 同步删除机构 kid 老系统id
|
||||
* @param id
|
||||
*/
|
||||
String syncDeleteOrganization(String kid);
|
||||
|
||||
/**
|
||||
* 同步删除用户
|
||||
* @param kid,老系统id
|
||||
* @param code
|
||||
*/
|
||||
String syncDeleteUser(String kid,String code);
|
||||
|
||||
|
||||
void saveError(ErrorLog error);
|
||||
|
||||
PageList<ErrorLog> findLogs(int pageIndex,int pageSize,ErrorLog err);
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
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);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.xboe.basic.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.xboe.basic.entity.OldOrganization;
|
||||
import com.xboe.basic.entity.OldUser;
|
||||
|
||||
public interface IOldService {
|
||||
|
||||
/**
|
||||
* 查询指定条数的机构信息
|
||||
*
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
List<OldOrganization> listAll();
|
||||
|
||||
/**
|
||||
* 根据kid获取用户信息
|
||||
* @param kid
|
||||
* @return
|
||||
*/
|
||||
OldUser getByUserKid(String kid);
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.xboe.basic.service;
|
||||
|
||||
public interface IOrganizationService {
|
||||
|
||||
/**
|
||||
* 根据kid获取机构信息
|
||||
* @param kid
|
||||
* @return
|
||||
*/
|
||||
Organization getByKid(String kid);
|
||||
}
|
||||
@@ -1,338 +0,0 @@
|
||||
package com.xboe.basic.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.xboe.basic.dao.AccountDao;
|
||||
import com.xboe.basic.dao.ErrorLogDao;
|
||||
import com.xboe.basic.dao.OrgTreeDao;
|
||||
import com.xboe.basic.dao.OrganizationDao;
|
||||
import com.xboe.basic.dao.PersonDao;
|
||||
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.Person;
|
||||
import com.xboe.basic.entity.User;
|
||||
import com.xboe.basic.service.IBasicDataSyncService;
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.common.utils.IDGenerator;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.QueryBuilder;
|
||||
import com.xboe.dto.OrganizationDto;
|
||||
import com.xboe.dto.UserDto;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service("basicService")
|
||||
public class BasicDataSyncServiceImpl implements IBasicDataSyncService{
|
||||
|
||||
@Autowired
|
||||
OrganizationDao orgDao;
|
||||
|
||||
@Autowired
|
||||
OrgTreeDao orgTreeDao;
|
||||
|
||||
@Autowired
|
||||
AccountDao accountDao;
|
||||
|
||||
@Autowired
|
||||
PersonDao personDao;
|
||||
|
||||
@Autowired
|
||||
UserDao userDao;
|
||||
|
||||
@Autowired
|
||||
ErrorLogDao errorDao;
|
||||
|
||||
@Override
|
||||
@Transactional("transactionManagerBasic")
|
||||
public synchronized void syncOrganization(OrganizationDto dto) {
|
||||
|
||||
Organization org=orgDao.findOne(FieldFilters.eq("kid", dto.getKid()));
|
||||
if(org==null) {//新增加
|
||||
org=new Organization();
|
||||
org.setId(IDGenerator.generate());
|
||||
org.setKid(dto.getKid());//老系统的id
|
||||
|
||||
org.setCode(org.getCode());
|
||||
org.setCreateFrom(dto.getCreateFrom());
|
||||
org.setSysCreateTime(dto.getCreateTime());
|
||||
org.setDataFrom(dto.getDataFrom());
|
||||
org.setDeleted(false);
|
||||
org.setDescription(dto.getDescription());
|
||||
org.setIsDefault(dto.getIsDefault());
|
||||
org.setIsMakeOrg(dto.getIsMakeOrg());
|
||||
org.setIsServiceSite(dto.getIsServiceSite());
|
||||
org.setName(dto.getName());
|
||||
org.setNamePath(dto.getNamePath());
|
||||
|
||||
//org.setOrganizationLevel(dto.getSysLevel());
|
||||
org.setSysLevel(dto.getSysLevel());
|
||||
org.setRemark(dto.getRemark());
|
||||
org.setSassId(dto.getSassId());
|
||||
org.setShortName(dto.getShortName());
|
||||
org.setStatus(dto.getStatus());
|
||||
org.setOrganizationLevel(dto.getOrganizationLevel());
|
||||
dto.setId(org.getId());
|
||||
orgDao.save(org);
|
||||
|
||||
OrgTree treeNode=new OrgTree();
|
||||
treeNode.setOrgId(org.getId());
|
||||
treeNode.setTreeType(dto.getTreeType());
|
||||
treeNode.setParentId("");
|
||||
treeNode.setRemark("系统同步");
|
||||
treeNode.setOldParentId(dto.getParentId());//保原机构的父id
|
||||
if(StringUtils.isNotBlank(dto.getParentId())){
|
||||
//检查它的上级id是哪个
|
||||
String parentId=(String)orgDao.findField("id",FieldFilters.eq("kid",dto.getParentId()));
|
||||
//如果没有orgId,应该再去获取,但是这里没有再去获取的途径,
|
||||
if(StringUtils.isNotBlank(parentId)){
|
||||
treeNode.setParentId(parentId);
|
||||
dto.setParentId(parentId);//设置dto的parentId;
|
||||
}else {
|
||||
//这种情况,本地无机构,应该去远程获取
|
||||
log.error("本地未找到机构【"+dto.getKid()+"】的上级parentId【"+dto.getParentId()+"】对应的机构,机构新id【"+org.getId()+"】");
|
||||
dto.setParentId("-1");//如果没有情况,设置为-1
|
||||
}
|
||||
}
|
||||
orgTreeDao.save(treeNode);
|
||||
}else {//更新
|
||||
dto.setId(org.getId());
|
||||
// org.setCode(org.getCode());
|
||||
// org.setCreateFrom(dto.getCreateFrom());
|
||||
// org.setCreateTime(dto.getCreateTime());
|
||||
// org.setDataFrom(dto.getDataFrom());
|
||||
//已经删除的,需要还原,因为新的同步过来了
|
||||
if(dto.getDeleted()!=null && dto.getDeleted()) {
|
||||
org.setDeleted(dto.getDeleted());
|
||||
}
|
||||
org.setDescription(dto.getDescription());
|
||||
org.setIsDefault(dto.getIsDefault());
|
||||
org.setIsMakeOrg(dto.getIsMakeOrg());
|
||||
org.setIsServiceSite(dto.getIsServiceSite());
|
||||
org.setName(dto.getName());
|
||||
org.setNamePath(dto.getNamePath());
|
||||
org.setSysLevel(dto.getSysLevel());
|
||||
org.setRemark(dto.getRemark());
|
||||
org.setSassId(dto.getSassId());
|
||||
org.setShortName(dto.getShortName());
|
||||
org.setOrganizationLevel(dto.getOrganizationLevel());
|
||||
org.setStatus(dto.getStatus());
|
||||
orgDao.update(org);
|
||||
|
||||
OrgTree treeNode=orgTreeDao.findOne(FieldFilters.eq("orgId",org.getId()));
|
||||
//得到对应的parentId,有可能修改了对应的上级关系
|
||||
String parentId="";
|
||||
if(StringUtils.isNotBlank(dto.getParentId())){
|
||||
parentId=(String)orgDao.findField("id",FieldFilters.eq("kid",dto.getParentId()));
|
||||
}
|
||||
dto.setParentId(parentId);
|
||||
if(treeNode!=null){
|
||||
treeNode.setParentId(parentId);
|
||||
treeNode.setOldParentId(dto.getParentId());
|
||||
orgTreeDao.update(treeNode);
|
||||
}else {
|
||||
treeNode=new OrgTree();
|
||||
treeNode.setOrgId(org.getId());
|
||||
treeNode.setTreeType(dto.getTreeType());
|
||||
treeNode.setParentId(parentId);
|
||||
treeNode.setRemark("系统同步");
|
||||
orgTreeDao.save(treeNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional("transactionManagerBasic")
|
||||
public synchronized void syncUser(UserDto dto) {
|
||||
|
||||
Integer employeeStatus=dto.getEmployeeStatus();
|
||||
//获取原机构的id
|
||||
if(StringUtils.isNotBlank(dto.getOldDepartId())) {
|
||||
Object idObj = orgDao.findField("id", FieldFilters.eq("kid", dto.getOldDepartId()));
|
||||
if(idObj!=null) {
|
||||
dto.setDepartId(idObj.toString());
|
||||
}
|
||||
}
|
||||
//同一个用户工号对应 多个kid的情况,所以直接根据kid查询是不对的,所以这里按工号查询,不使用kid
|
||||
User user = userDao.findOne(FieldFilters.eq("userNo", dto.getUserNo()));
|
||||
if(user==null) {
|
||||
//人员基本信息
|
||||
Person person=new Person();
|
||||
person.setId(IDGenerator.generate());
|
||||
//person.setBirthday(dto.getBirthday());
|
||||
person.setDataFrom(dto.getDataFrom());
|
||||
person.setGender(dto.toGenderInteger());
|
||||
person.setGraduatedFrom(dto.getGraduatedFrom());
|
||||
person.setGraduatedMajor(dto.getGraduatedMajor());
|
||||
person.setHighestEducation(dto.getHighestEducation());
|
||||
person.setHomePhoneNo(dto.getHomePhoneNo());
|
||||
person.setIdNumber(dto.getIdNumber());
|
||||
person.setIdType(dto.getIdType());
|
||||
person.setName(dto.getName());
|
||||
person.setNation(dto.getNation());
|
||||
person.setNationality(dto.getNationality());
|
||||
person.setRemark("用户同步");
|
||||
person.setStatus(Person.STATUS_NORMAL);//
|
||||
|
||||
//账号信息
|
||||
Account a=new Account();
|
||||
//同步过程中一样,可以不一样。因为此系统当前是一致的,所以统一使用一个
|
||||
a.setId(person.getId());
|
||||
a.setPersonId(person.getId());
|
||||
a.setAvatar(dto.getAvatar());
|
||||
a.setDeleted(false);
|
||||
a.setEmail(dto.getEmail());
|
||||
a.setLanguage(dto.getLanguage());
|
||||
a.setLoginName(dto.getLoginName());
|
||||
a.setMobile(dto.getMobile());
|
||||
a.setPassKey("");
|
||||
a.setPassValue("");
|
||||
a.setStatus(Account.STATUS_NORMAL);//正常状态
|
||||
if(employeeStatus==3) {
|
||||
a.setDeleted(true);
|
||||
}else {
|
||||
a.setDeleted(false);
|
||||
}
|
||||
|
||||
user=new User();
|
||||
//同步过程中一样,可以不一样。因为此系统当前是一致的,所以统一使用一个
|
||||
user.setId(a.getId());
|
||||
user.setPersonId(person.getId());
|
||||
user.setEnterpriseId(dto.getEnterpriseId());
|
||||
user.setDepartId(dto.getDepartId());
|
||||
user.setDescription(dto.getDescription());
|
||||
user.setDomainId(dto.getDomainId());
|
||||
user.setDuty(dto.getDuty());
|
||||
user.setKid(dto.getKid());
|
||||
user.setLearningDuration(dto.getLearningDuration());
|
||||
user.setMobile(dto.getMobile());
|
||||
user.setName(dto.getName());
|
||||
user.setOldEnterpriseId(dto.getOldEnterpriseId());
|
||||
user.setOldDepartId(dto.getOldDepartId());
|
||||
user.setOrgNamePath(dto.getOrgNamePath());
|
||||
user.setOrgTreeType(dto.getOrgTreeType());
|
||||
user.setRank(dto.getRank());
|
||||
user.setSassId(dto.getSassId());
|
||||
user.setTelephoneNo(dto.getTelephoneNo());
|
||||
user.setUserNo(dto.getUserNo());
|
||||
user.setPayrollPlaceId(dto.getPayrollPlaceId());
|
||||
user.setPayrollPlaceName(dto.getPayrollPlaceName());
|
||||
user.setEmployeeStatus(dto.getEmployeeStatus());
|
||||
|
||||
|
||||
if(user.getStatus()==null) {
|
||||
user.setStatus(1);//如果为空,就是正常
|
||||
}
|
||||
if(user.getEmployeeStatus()==null) {
|
||||
user.setEmployeeStatus(2);//在职状态
|
||||
}
|
||||
if(employeeStatus==3) {
|
||||
user.setDeleted(true);
|
||||
}else {
|
||||
user.setDeleted(false);
|
||||
}
|
||||
|
||||
|
||||
personDao.save(person);
|
||||
accountDao.save(a);
|
||||
userDao.save(user);
|
||||
dto.setId(user.getId());
|
||||
|
||||
}else {
|
||||
//更新时不更新用户基本信息和账户信息
|
||||
user.setDescription(dto.getDescription());
|
||||
user.setKid(dto.getKid());
|
||||
user.setDomainId(dto.getDomainId());
|
||||
user.setDuty(dto.getDuty());
|
||||
user.setLearningDuration(dto.getLearningDuration());
|
||||
user.setMobile(dto.getMobile());
|
||||
user.setOldEnterpriseId(dto.getOldEnterpriseId());
|
||||
user.setOldDepartId(dto.getOldDepartId());
|
||||
user.setOrgNamePath(dto.getOrgNamePath());
|
||||
user.setOrgTreeType(dto.getOrgTreeType());
|
||||
user.setEnterpriseId(dto.getEnterpriseId());
|
||||
user.setDepartId(dto.getDepartId());
|
||||
user.setRank(dto.getRank());
|
||||
user.setSassId(dto.getSassId());
|
||||
user.setTelephoneNo(dto.getTelephoneNo());
|
||||
user.setPayrollPlaceId(dto.getPayrollPlaceId());
|
||||
user.setPayrollPlaceName(dto.getPayrollPlaceName());
|
||||
user.setEmployeeStatus(dto.getEmployeeStatus());
|
||||
|
||||
if(employeeStatus==3) {
|
||||
user.setDeleted(true);
|
||||
}else {
|
||||
user.setDeleted(false);
|
||||
}
|
||||
|
||||
userDao.update(user);
|
||||
dto.setId(user.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageList<ErrorLog> findLogs(int pageIndex, int pageSize,ErrorLog log) {
|
||||
|
||||
QueryBuilder builder = QueryBuilder.from(ErrorLog.class);
|
||||
if(log.getDataType()!=null){
|
||||
builder.addFilter(FieldFilters.eq("dataType",log.getDataType()));
|
||||
}
|
||||
if(log.getType()!=null){
|
||||
builder.addFilter(FieldFilters.eq("type",log.getType()));
|
||||
}
|
||||
builder.setPageIndex(pageIndex);
|
||||
builder.setPageSize(pageSize);
|
||||
builder.addOrder(OrderCondition.desc("logTime"));
|
||||
return errorDao.findPage(builder.builder());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional("transactionManagerBasic")
|
||||
public void saveError(ErrorLog error) {
|
||||
if(error.getLogTime()==null) {
|
||||
error.setLogTime(LocalDateTime.now());
|
||||
}
|
||||
errorDao.save(error);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional("transactionManagerBasic")
|
||||
public String syncDeleteOrganization(String kid) {
|
||||
|
||||
//如果机构下有用户怎么办? 第二 ,是否也同步删除机构关系中的数据?
|
||||
Organization org=orgDao.findOne(FieldFilters.eq("kid",kid));
|
||||
//System.out.println(org.getId()+"1313131312312");
|
||||
if(org!=null) {
|
||||
orgDao.setDeleted(org.getId());
|
||||
return org.getId();
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional("transactionManagerBasic")
|
||||
public String syncDeleteUser(String kid,String code) {
|
||||
//同一个code,不同的id的部分,
|
||||
User user = userDao.findOne(FieldFilters.eq("kid", kid));
|
||||
if(user!=null) {
|
||||
userDao.setDeleted(user.getId());
|
||||
accountDao.setDeleted(user.getId());
|
||||
return user.getId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xboe.basic.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.xboe.basic.dao.OldOrganizationDao;
|
||||
import com.xboe.basic.dao.OldUserDao;
|
||||
import com.xboe.basic.entity.OldOrganization;
|
||||
import com.xboe.basic.entity.OldUser;
|
||||
import com.xboe.basic.service.IOldService;
|
||||
import com.xboe.common.OrderCondition;
|
||||
|
||||
|
||||
/**
|
||||
* 老系统的机构
|
||||
* */
|
||||
@Service
|
||||
public class OldServiceImpl implements IOldService {
|
||||
|
||||
@Resource
|
||||
OldOrganizationDao dao;
|
||||
|
||||
@Resource
|
||||
OldUserDao userDao;
|
||||
|
||||
@Override
|
||||
public List<OldOrganization> listAll() {
|
||||
List<OldOrganization> list = dao.listAll();
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OldUser getByUserKid(String kid) {
|
||||
|
||||
return userDao.get(kid);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,4 +23,7 @@ public interface MainOrganizationDao extends JpaRepository<MainOrganization,Stri
|
||||
|
||||
@Query(value = "from MainOrganization where id=?1")
|
||||
public MainOrganization get(String id);
|
||||
|
||||
@Query(value = "from MainOrganization where sysId=?1")
|
||||
public List<MainOrganization> findBySysId(String sysId);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package com.xboe.primary.dao;
|
||||
|
||||
import com.xboe.basic.entity.User;
|
||||
import com.xboe.primary.entity.MainOrganization;
|
||||
import io.lettuce.core.dynamic.annotation.Param;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.primary.entity.MainUser;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 用户DAO
|
||||
@@ -20,8 +18,15 @@ public interface MainUserDao extends JpaRepository<MainUser,String> {
|
||||
@Modifying
|
||||
@Query(value = "update MainUser set deleted=true where id=?1")
|
||||
public Integer setDeleted(String id);
|
||||
|
||||
@Modifying
|
||||
@Query(value = "upate MainUser set departId=?1, sysDepartId=?2,companyId=?3 where id=?4")
|
||||
public Integer update(String departId,String sysDepartId,String companyId,String id);
|
||||
|
||||
|
||||
@Query(value = "from MainUser where id=?1")
|
||||
public MainUser get(String id);
|
||||
|
||||
@Query(value = "Select new MainUser(id,sysId,userNo) from MainUser where id=?1")
|
||||
public List<MainUser> findAll(String id);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
package com.xboe.primary.entity;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
|
||||
@@ -50,92 +45,7 @@ public class MainUser extends IdEntity {
|
||||
@Column(name = "user_no", length = 30)
|
||||
private String userNo;
|
||||
|
||||
/**
|
||||
* 性别 1:男 2:女
|
||||
*/
|
||||
@Column(name = "gender", length = 1)
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
@Column(name = "birthday")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate birthday;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
@Column(name = "id_number", length = 18)
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Column(name = "mobile_no", length = 11)
|
||||
private String mobileNo;
|
||||
|
||||
/**
|
||||
* 家庭电话
|
||||
*/
|
||||
@Column(name = "home_phone_no", length = 50)
|
||||
private String homePhoneNo;
|
||||
|
||||
/**
|
||||
* 国籍
|
||||
*/
|
||||
@Column(name = "nationality", length = 50)
|
||||
private String nationality;
|
||||
|
||||
/**
|
||||
* 毕业院校
|
||||
*/
|
||||
@Column(name = "graduated_from", length = 50)
|
||||
private String graduatedFrom;
|
||||
|
||||
/**
|
||||
* 毕业专业
|
||||
*/
|
||||
@Column(name = "graduated_major", length = 50)
|
||||
private String graduatedMajor;
|
||||
|
||||
/**
|
||||
* 最高学历
|
||||
*/
|
||||
@Column(name = "highest_education", length = 50)
|
||||
private String highestEducation;
|
||||
|
||||
/**
|
||||
* 办公电话
|
||||
*/
|
||||
@Column(name = "telephone_no", length = 50)
|
||||
private String telephoneNo;
|
||||
|
||||
/**发薪地*/
|
||||
@Column(name = "payroll_place", length = 150)
|
||||
private String payrollPlace;
|
||||
|
||||
/**管理序列职级*/
|
||||
@Column(name = "position_mgr_level", length = 150)
|
||||
private String positionMgrLevel;
|
||||
|
||||
/**
|
||||
* 职务
|
||||
*/
|
||||
@Column(name = "duty", length = 50)
|
||||
private String duty;
|
||||
|
||||
/**
|
||||
* 职级
|
||||
*/
|
||||
@Column(name = "rank", length = 50)
|
||||
private String rank;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Column(name = "description")
|
||||
private String description;
|
||||
|
||||
|
||||
/**
|
||||
* 所在公司
|
||||
@@ -149,89 +59,25 @@ public class MainUser extends IdEntity {
|
||||
@Column(name = "depart_id", length = 18)
|
||||
private String departId;
|
||||
|
||||
@Transient
|
||||
private String departName;
|
||||
|
||||
|
||||
/**
|
||||
* 所在域
|
||||
*/
|
||||
@Column(name = "domain_id", length = 36)
|
||||
private String domainId;
|
||||
|
||||
/**
|
||||
* 扩展字段,多租户系统的标识值
|
||||
*/
|
||||
@Column(name = "sass_id", length = 36)
|
||||
private String sassId;
|
||||
|
||||
/**
|
||||
* 用户类型,1表学员,2表教师,3表管理员
|
||||
* 该字段暂用于表示是否前台管理员
|
||||
*/
|
||||
@Column(name = "user_type", length = 1)
|
||||
private Integer userType;
|
||||
|
||||
/**
|
||||
* 学习总时长
|
||||
*/
|
||||
@Column(name = "study_total", length = 11)
|
||||
private Integer studyTotal;
|
||||
|
||||
/**
|
||||
* boe的时长,和系统时长单独保存
|
||||
*/
|
||||
@Column(name = "learning_Duration", length = 11)
|
||||
private Integer learningDuration;
|
||||
|
||||
/**
|
||||
* 最近一次登录时间
|
||||
*/
|
||||
@Column(name = "last_login_at")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime lastLoginAt;
|
||||
|
||||
/**
|
||||
* 最近一次登录IP
|
||||
*/
|
||||
@Column(name = "last_login_ip", length = 30)
|
||||
private String lastLoginIp;
|
||||
|
||||
/**
|
||||
* 最近一次登录MAC地址
|
||||
*/
|
||||
@Column(name = "last_login_mac", length = 30)
|
||||
private String lastLoginMac;
|
||||
|
||||
/**
|
||||
* 最近一次操作时间
|
||||
*/
|
||||
@Column(name = "last_action_at")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime lastActionAt;
|
||||
|
||||
/**
|
||||
* 最近一次操作IP
|
||||
*/
|
||||
@Column(name = "last_action_ip", length = 30)
|
||||
private String lastActionIp;
|
||||
|
||||
/**
|
||||
* 最近一次操作MAC地址
|
||||
*/
|
||||
@Column(name = "last_action_mac", length = 30)
|
||||
private String lastActionMac;
|
||||
|
||||
/**
|
||||
* 在线状态;
|
||||
* 0:离线,1:在线
|
||||
*/
|
||||
@Column(name = "online", length = 1)
|
||||
private Boolean online;
|
||||
|
||||
/**
|
||||
* 删除标识
|
||||
* */
|
||||
@Column(name="deleted",length = 1)
|
||||
private Boolean deleted;
|
||||
|
||||
public MainUser() {
|
||||
|
||||
}
|
||||
|
||||
public MainUser(String id,String sysId,String userNo) {
|
||||
this.setId(id);
|
||||
this.sysId=sysId;
|
||||
this.userNo=userNo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.xboe.primary.service;
|
||||
|
||||
import com.xboe.dto.OrganizationDto;
|
||||
import com.xboe.dto.UserDto;
|
||||
import java.util.List;
|
||||
|
||||
import com.xboe.primary.entity.MainOrganization;
|
||||
import com.xboe.primary.entity.MainUser;
|
||||
|
||||
/**
|
||||
* 基本数据同步的相关处理
|
||||
@@ -9,32 +11,19 @@ import com.xboe.dto.UserDto;
|
||||
*
|
||||
*/
|
||||
public interface IMainDbSyncService {
|
||||
|
||||
/**
|
||||
* 查询所有的用户
|
||||
* @return
|
||||
*/
|
||||
List<MainUser> findAll();
|
||||
|
||||
MainOrganization findByKid(String kid);
|
||||
|
||||
void save(MainOrganization mainOrg);
|
||||
|
||||
void update(MainOrganization mainOrg);
|
||||
|
||||
void updateUser(MainUser muser);
|
||||
|
||||
/**
|
||||
* 同步机构数据
|
||||
* @param dto
|
||||
*/
|
||||
void syncOrganization(OrganizationDto dto);
|
||||
|
||||
/**
|
||||
* 同步人员数据
|
||||
* @param dto
|
||||
*/
|
||||
void syncUser(UserDto dto);
|
||||
|
||||
/**
|
||||
* 同步删除机构 id.
|
||||
* 内部同步不是新的id
|
||||
* @param id
|
||||
*/
|
||||
String syncDeleteOrganization(String id);
|
||||
|
||||
/**
|
||||
* 同步删除用户
|
||||
* @param id,新系统调用是数据中心的id
|
||||
* @param code
|
||||
*/
|
||||
String syncDeleteUser(String id,String code);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
package com.xboe.primary.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.xboe.basic.entity.Account;
|
||||
import com.xboe.dto.OrganizationDto;
|
||||
import com.xboe.dto.UserDto;
|
||||
import com.xboe.primary.dao.MainAccountDao;
|
||||
import com.xboe.primary.dao.MainOrganizationDao;
|
||||
import com.xboe.primary.dao.MainTeacherDao;
|
||||
import com.xboe.primary.dao.MainUserDao;
|
||||
import com.xboe.primary.entity.MainAccount;
|
||||
import com.xboe.primary.entity.MainOrganization;
|
||||
import com.xboe.primary.entity.MainUser;
|
||||
import com.xboe.primary.service.IMainDbSyncService;
|
||||
@@ -38,134 +34,35 @@ public class MainDbSyncServiceImpl implements IMainDbSyncService {
|
||||
|
||||
@Override
|
||||
@Transactional("transactionManagerPrimary")
|
||||
public synchronized void syncOrganization(OrganizationDto dto) {
|
||||
MainOrganization hasOrg =orgDao.get(dto.getId());
|
||||
if(hasOrg!=null) {
|
||||
if(dto.getDeleted()!=null && dto.getDeleted()) {
|
||||
hasOrg.setDeleted(dto.getDeleted());
|
||||
}
|
||||
hasOrg.setDescription(dto.getDescription());
|
||||
hasOrg.setIsMakeOrg(dto.getIsMakeOrg());
|
||||
hasOrg.setIsServiceSite(dto.getIsServiceSite());
|
||||
hasOrg.setName(dto.getName());
|
||||
hasOrg.setParentId(dto.getParentId());
|
||||
hasOrg.setNamePath(dto.getNamePath());
|
||||
hasOrg.setStatus(dto.getStatus());
|
||||
orgDao.save(hasOrg);
|
||||
}else {
|
||||
//hasOrg =orgDao.getBySysId(dto.getKid());
|
||||
hasOrg=new MainOrganization();
|
||||
hasOrg.setId(dto.getId());
|
||||
hasOrg.setCode(dto.getCode());
|
||||
hasOrg.setCompanyId(dto.getSassId());
|
||||
hasOrg.setDeleted(false);
|
||||
hasOrg.setDescription(dto.getDescription());
|
||||
//hasOrg.setDomainId(dto.getD);
|
||||
hasOrg.setIsDefaultOrganization(true);
|
||||
hasOrg.setStatus(dto.getStatus());
|
||||
hasOrg.setIsMakeOrg(dto.getIsMakeOrg());
|
||||
hasOrg.setIsServiceSite(dto.getIsServiceSite());
|
||||
hasOrg.setName(dto.getName());
|
||||
hasOrg.setNamePath(dto.getNamePath());
|
||||
hasOrg.setOrganizationLevel(dto.getOrganizationLevel());
|
||||
//hasOrg.setOrgnizationManagerId(dto.get);
|
||||
hasOrg.setParentId(dto.getParentId());
|
||||
//hasOrg.setSysCreateAid();//创建人没有这个数据
|
||||
hasOrg.setSysCreateBy("同步基础数据");
|
||||
hasOrg.setSysCreateTime(LocalDateTime.now());
|
||||
hasOrg.setSysId(dto.getKid());
|
||||
hasOrg.setSysParentId(dto.getParentId());
|
||||
hasOrg.setSysUpdateBy("");
|
||||
hasOrg.setSysUpdateTime(hasOrg.getSysCreateTime());
|
||||
orgDao.save(hasOrg);
|
||||
|
||||
public MainOrganization findByKid(String kid) {
|
||||
List<MainOrganization> orgs=orgDao.findBySysId(kid);
|
||||
if(orgs!=null && !orgs.isEmpty()) {
|
||||
return orgs.get(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional("transactionManagerPrimary")
|
||||
public void syncUser(UserDto dto) {
|
||||
//System.out.println("dto.name="+dto.getName());
|
||||
Integer employeeStatus=dto.getEmployeeStatus();
|
||||
//同一个用户工号对应 多个kid的情况,所以直接根据kid查询是不对的,同步过来的,使用sysId查询
|
||||
MainUser user = userDao.get(dto.getId());
|
||||
if(user!=null) {
|
||||
//更新用户信息,更新账号信息
|
||||
user.setSysId(dto.getKid());
|
||||
//hasUser.setBirthday(null);
|
||||
}else {
|
||||
//账号信息
|
||||
MainAccount a=new MainAccount();
|
||||
//同步过程中一样,可以不一样。因为此系统当前是一致的,所以统一使用一个
|
||||
a.setId(dto.getId());
|
||||
a.setAvatar(dto.getAvatar());
|
||||
a.setDeleted(false);
|
||||
a.setEmail(dto.getEmail());
|
||||
a.setLoginName(dto.getLoginName());
|
||||
a.setSysId(dto.getKid());
|
||||
a.setRegTime(LocalDateTime.now());
|
||||
|
||||
a.setMobile(dto.getMobile());
|
||||
a.setPassKey("");
|
||||
a.setPassValue("");
|
||||
a.setStatus(Account.STATUS_NORMAL);//正常状态
|
||||
if(employeeStatus==3) {
|
||||
a.setDeleted(true);
|
||||
}else {
|
||||
a.setDeleted(false);
|
||||
}
|
||||
|
||||
user=new MainUser();
|
||||
//同步过程中一样,可以不一样。因为此系统当前是一致的,所以统一使用一个
|
||||
user.setId(a.getId());
|
||||
user.setDepartId(dto.getDepartId());
|
||||
user.setDescription(dto.getDescription());
|
||||
user.setDomainId(dto.getDomainId());
|
||||
user.setDuty(dto.getDuty());
|
||||
user.setSysId(dto.getKid());
|
||||
user.setLearningDuration(dto.getLearningDuration());
|
||||
user.setName(dto.getName());
|
||||
user.setRank(dto.getRank());
|
||||
user.setSassId(dto.getSassId());
|
||||
user.setTelephoneNo(dto.getTelephoneNo());
|
||||
user.setUserNo(dto.getUserNo());
|
||||
user.setGender(dto.toGenderInteger()==3? 1:dto.toGenderInteger());
|
||||
user.setGraduatedFrom(dto.getGraduatedFrom());
|
||||
user.setGraduatedMajor(dto.getGraduatedMajor());
|
||||
user.setHighestEducation(dto.getHighestEducation());
|
||||
user.setHomePhoneNo(dto.getHomePhoneNo());
|
||||
user.setIdNumber(dto.getIdNumber());
|
||||
user.setMobileNo(dto.getMobile());
|
||||
user.setNationality(dto.getNationality());
|
||||
user.setOnline(true);
|
||||
user.setDeleted(false);
|
||||
accountDao.save(a);
|
||||
userDao.save(user);
|
||||
}
|
||||
|
||||
public void save(MainOrganization mainOrg) {
|
||||
orgDao.save(mainOrg);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional("transactionManagerPrimary")
|
||||
public String syncDeleteOrganization(String id){
|
||||
//注意这里调用的是机构的id
|
||||
orgDao.setDeleted(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional("transactionManagerPrimary")
|
||||
public String syncDeleteUser(String id,String code) {
|
||||
MainAccount a = accountDao.getById(id);
|
||||
if(a!=null) {
|
||||
accountDao.setDeleted(id);
|
||||
//设置教师是离职状态
|
||||
teacherDao.updateStatus(id, 1);
|
||||
}
|
||||
//当前系统User相当于Person
|
||||
return id;
|
||||
public void update(MainOrganization mainOrg) {
|
||||
orgDao.save(mainOrg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MainUser> findAll() {
|
||||
|
||||
return userDao.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUser(MainUser muser) {
|
||||
userDao.update(muser.getDepartId(),muser.getSysDepartId(),muser.getCompanyId(),muser.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user