组织导入
This commit is contained in:
parent
26ef362eb4
commit
655933236c
|
|
@ -1,34 +0,0 @@
|
|||
package com.engine.organization.service;
|
||||
|
||||
import com.engine.organization.entity.hrmresource.param.HrmResourceImportParam;
|
||||
import weaver.file.FileUploadToPath;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/06/27
|
||||
* @version: 1.0
|
||||
*/
|
||||
public interface HrmResourceImportAdaptService {
|
||||
/**
|
||||
* 用于生成需要导入系统的人员与组织架构数据并放入Map中,同时包含参数和数据有效性验证
|
||||
* 其格式是:
|
||||
*
|
||||
* @return 返回错误提示
|
||||
*/
|
||||
List<String> creatImportMap(FileUploadToPath fu);
|
||||
|
||||
/**
|
||||
* 获得HrmImportMap
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, HrmResourceImportParam> getHrmImportMap();
|
||||
|
||||
/**
|
||||
* 传递同步的人员语言id
|
||||
*/
|
||||
void setUserlanguage(int userlanguage);
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
package com.engine.organization.service;
|
||||
|
||||
import com.engine.organization.entity.hrmresource.param.HrmResourceImportParam;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/06/27
|
||||
* @version: 1.0
|
||||
*/
|
||||
public interface HrmResourceImportProcessService {
|
||||
/**
|
||||
* 初始化数据
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
Map<String, Object> init(HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 用于处理把所得到的组织和人员结构信息放入系统
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
void processMap(Map<String, HrmResourceImportParam> map);
|
||||
}
|
||||
|
|
@ -2,9 +2,9 @@ package com.engine.organization.service.impl;
|
|||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.entity.hrmresource.param.HrmResourceImportParam;
|
||||
import com.engine.organization.service.HrmResourceImportAdaptService;
|
||||
import com.engine.organization.service.HrmResourceImportProcessService;
|
||||
import com.engine.organization.service.ImportCommonService;
|
||||
import com.engine.organization.util.saveimport.HrmResourceImportAdaptUtil;
|
||||
import com.engine.organization.util.saveimport.HrmResourceImportProcessUtil;
|
||||
import com.engine.organization.util.saveimport.SaveImportProcessUtil;
|
||||
import weaver.file.FileUploadToPath;
|
||||
import weaver.general.BaseBean;
|
||||
|
|
@ -32,17 +32,17 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
try {
|
||||
/*综合考虑多数据源后,实现通过配置文件配置适配器和解析类*/
|
||||
List<Object> lsErrorInfo = new ArrayList<>();
|
||||
HrmResourceImportAdaptService importAdapt = new HrmResourceImportAdaptServiceImpl();
|
||||
HrmResourceImportAdaptUtil importAdaptUtil = new HrmResourceImportAdaptUtil();
|
||||
FileUploadToPath fu = new FileUploadToPath(request);
|
||||
int language = this.user.getLanguage();
|
||||
importAdapt.setUserlanguage(language);
|
||||
List<String> errorInfo = importAdapt.creatImportMap(fu);
|
||||
importAdaptUtil.setUserlanguage(language);
|
||||
List<String> errorInfo = importAdaptUtil.creatImportMap(fu);
|
||||
//如果读取数据和验证模板没有发生错误
|
||||
if (errorInfo.isEmpty()) {
|
||||
Map<String, HrmResourceImportParam> hrMap = importAdapt.getHrmImportMap();
|
||||
HrmResourceImportProcessService importProcess = new HrmResourceImportProcessServiceImpl();
|
||||
importProcess.init(request);
|
||||
importProcess.processMap(hrMap);
|
||||
Map<String, HrmResourceImportParam> hrMap = importAdaptUtil.getHrmImportMap();
|
||||
HrmResourceImportProcessUtil importProcessUtil = new HrmResourceImportProcessUtil();
|
||||
importProcessUtil.init(request);
|
||||
importProcessUtil.processMap(hrMap);
|
||||
} else {
|
||||
Map<String, Object> error;
|
||||
for (String s : errorInfo) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@ import com.engine.hrm.entity.RuleCodeType;
|
|||
import com.engine.hrm.util.CodeRuleManager;
|
||||
import com.engine.hrm.util.HrmTriggerUtil;
|
||||
import com.engine.hrm.util.face.HrmFaceCheckManager;
|
||||
import com.engine.organization.entity.company.po.CompPO;
|
||||
import com.engine.organization.entity.department.po.DepartmentPO;
|
||||
import com.engine.organization.mapper.comp.CompMapper;
|
||||
import com.engine.organization.mapper.department.DepartmentMapper;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
|
|
@ -17,19 +23,21 @@ import weaver.rtx.OrganisationCom;
|
|||
import weaver.systeminfo.SysMaintenanceLog;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/06/30
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class CompanyImportUtil {
|
||||
private final RecordSet recordSet=new RecordSet();
|
||||
private final OrganisationCom rtxService=new OrganisationCom(); //添加到rtx
|
||||
private final RecordSet recordSet = new RecordSet();
|
||||
private final OrganisationCom rtxService = new OrganisationCom(); //添加到rtx
|
||||
private int id;
|
||||
private String subcompanyname="";
|
||||
private String departmentname="";
|
||||
private String subcompanyname = "";
|
||||
private String departmentname = "";
|
||||
private String subcompanycode = "";
|
||||
private Float subcompanyshoworder;
|
||||
private Integer subcompanyshoworder;
|
||||
private String departmentcode = "";
|
||||
private Float departmentshoworder;
|
||||
private int userlanguage = 7;
|
||||
|
|
@ -37,20 +45,29 @@ public class CompanyImportUtil {
|
|||
private String operateType;
|
||||
private String message = "";
|
||||
|
||||
private CompMapper getCompMapper() {
|
||||
return MapperProxyFactory.getProxy(CompMapper.class);
|
||||
}
|
||||
|
||||
private DepartmentMapper getDepartmentMapper() {
|
||||
return MapperProxyFactory.getProxy(DepartmentMapper.class);
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public void setUserLanguage(String userlanguage){
|
||||
public void setUserLanguage(String userlanguage) {
|
||||
this.userlanguage = Util.getIntValue(userlanguage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验数据有效性
|
||||
*/
|
||||
public String valExcelData(){
|
||||
public String valExcelData() {
|
||||
String errorInfo = "";
|
||||
if(Util.null2String(this.subcompanyname).length()==0){
|
||||
errorInfo = SystemEnv.getHtmlLabelName(125704,userlanguage);
|
||||
if (Util.null2String(this.subcompanyname).length() == 0) {
|
||||
errorInfo = SystemEnv.getHtmlLabelName(125704, userlanguage);
|
||||
return errorInfo;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(operateType) && operateType.equals("add")) {
|
||||
|
|
@ -63,22 +80,22 @@ public class CompanyImportUtil {
|
|||
/**
|
||||
* 保存数据
|
||||
*/
|
||||
public String save(){
|
||||
public String save() {
|
||||
boolean flag = false;
|
||||
try{
|
||||
if(StringUtils.isNotEmpty(operateType)) {
|
||||
try {
|
||||
if (StringUtils.isNotEmpty(operateType)) {
|
||||
if (operateType.equals("add")) {
|
||||
int subcompanyid = 0;
|
||||
int departmentid;
|
||||
if(Util.null2String(this.subcompanyname).length()>0){
|
||||
if (Util.null2String(this.subcompanyname).length() > 0) {
|
||||
//取分部
|
||||
subcompanyid = getSubCompanyId(this.subcompanyname);
|
||||
subcompanyid = getCompanyId(this.subcompanyname);
|
||||
}
|
||||
departmentid = getDeptId(this.departmentname,subcompanyid);
|
||||
if(Util.null2String(this.departmentname).length()>0){
|
||||
if(departmentid!=0)flag=true;
|
||||
}else{
|
||||
if(subcompanyid!=0)flag=true;
|
||||
departmentid = getDeptId(this.departmentname, subcompanyid);
|
||||
if (Util.null2String(this.departmentname).length() > 0) {
|
||||
if (departmentid != 0) flag = true;
|
||||
} else {
|
||||
if (subcompanyid != 0) flag = true;
|
||||
}
|
||||
} else if (operateType.equals("update")) {
|
||||
int subcompanyid = updateSubCompany();
|
||||
|
|
@ -88,23 +105,38 @@ public class CompanyImportUtil {
|
|||
flag = true;
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
} catch (Exception e) {
|
||||
new BaseBean().writeLog(e);
|
||||
}
|
||||
|
||||
return String.valueOf(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验分部编号是否重复
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
private boolean verifySubCompanyCode(String code) {
|
||||
if (StringUtils.isEmpty(code)) return true;
|
||||
RecordSet recordSet = new RecordSet();
|
||||
String sql = "select id from HrmSubCompany where subcompanycode = ?";
|
||||
recordSet.executeQuery(sql, code);
|
||||
return recordSet.getCounts() <= 0;
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
return true;
|
||||
}
|
||||
List<CompPO> compPOS = getCompMapper().listByNo(code);
|
||||
return CollectionUtils.isEmpty(compPOS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param code
|
||||
* @param name
|
||||
* @param supsubcomid
|
||||
* @return
|
||||
*/
|
||||
private boolean verifySubCompanyCode(String code, String name, int supsubcomid) {
|
||||
if (StringUtils.isEmpty(code)) return true;
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
return true;
|
||||
}
|
||||
// TODO 部门重复编号验证
|
||||
RecordSet recordSet = new RecordSet();
|
||||
String sql = "select id from HrmSubCompany where subcompanyname = ? and supsubcomid = ?";
|
||||
recordSet.executeQuery(sql, name, supsubcomid);
|
||||
|
|
@ -117,15 +149,22 @@ public class CompanyImportUtil {
|
|||
return verifySubCompanyCode(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验部门编号是否重复
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
private boolean verifyDeptCode(String code) {
|
||||
if (StringUtils.isEmpty(code)) return true;
|
||||
RecordSet recordSet = new RecordSet();
|
||||
String sql = "select id from HrmDepartment where departmentcode = ?";
|
||||
recordSet.executeQuery(sql, code);
|
||||
return recordSet.getCounts() <= 0;
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
return true;
|
||||
}
|
||||
List<DepartmentPO> departmentPOS = getDepartmentMapper().listByNo(code);
|
||||
return CollectionUtils.isEmpty(departmentPOS);
|
||||
}
|
||||
|
||||
private boolean verifyDeptCode(String code, String name, int subcompanyid, int supdepid) {
|
||||
// TODO 部门编号校验
|
||||
if (StringUtils.isEmpty(code)) return true;
|
||||
RecordSet recordSet = new RecordSet();
|
||||
String sql = "select id from HrmDepartment where departmentname = ? and subcompanyid1 = ? and supdepid = ?";
|
||||
|
|
@ -147,7 +186,7 @@ public class CompanyImportUtil {
|
|||
Float departmentshoworder = null;
|
||||
for (int i = 0; i < deptNames.length; i++) {
|
||||
if (StringUtils.isEmpty(deptNames[i])) continue;
|
||||
String sql = "select * from HrmDepartment where subcompanyid1="+ subcompanyid + " and departmentname='"+ deptNames[i].trim() + "' and supdepid=" + parentId +" and (canceled !=1 or canceled is null)";
|
||||
String sql = "select * from HrmDepartment where subcompanyid1=" + subcompanyid + " and departmentname='" + deptNames[i].trim() + "' and supdepid=" + parentId + " and (canceled !=1 or canceled is null)";
|
||||
currentId = getResultSetId(sql);
|
||||
if (currentId == 0) {
|
||||
// 部门不存在
|
||||
|
|
@ -163,8 +202,10 @@ public class CompanyImportUtil {
|
|||
if (StringUtils.isNotEmpty(departmentcode) || departmentshoworder != null) {
|
||||
recordSet.executeQuery(sql);
|
||||
recordSet.next();
|
||||
if (departmentshoworder == null) departmentshoworder = Float.valueOf(Util.null2s(recordSet.getString("showorder"), "0"));
|
||||
if (StringUtils.isEmpty(departmentcode)) departmentcode = Util.null2String(recordSet.getString("departmentcode"), "");
|
||||
if (departmentshoworder == null)
|
||||
departmentshoworder = Float.valueOf(Util.null2s(recordSet.getString("showorder"), "0"));
|
||||
if (StringUtils.isEmpty(departmentcode))
|
||||
departmentcode = Util.null2String(recordSet.getString("departmentcode"), "");
|
||||
if (verifyDeptCode(departmentcode, deptNames[i], subcompanyid, parentId)) {
|
||||
sql = "update hrmdepartment set departmentcode = ? , showorder = ? where departmentname = ? and subcompanyid1 = ? and supdepid = ? and (canceled !=1 or canceled is null)";
|
||||
recordSet.executeUpdate(sql, departmentcode, departmentshoworder, deptNames[i], subcompanyid, parentId);
|
||||
|
|
@ -177,12 +218,13 @@ public class CompanyImportUtil {
|
|||
}
|
||||
return currentId;
|
||||
}
|
||||
private int updateSubCompany(){
|
||||
|
||||
private int updateSubCompany() {
|
||||
String[] subcompanynames = subcompanyname.split(">");
|
||||
int parentId = 0;
|
||||
int currentId = 0;
|
||||
String subcompanycode = "";
|
||||
Float subcompanyshoworder = null;
|
||||
Integer subcompanyshoworder = null;
|
||||
for (int i = 0; i < subcompanynames.length; i++) {
|
||||
if (StringUtils.isEmpty(subcompanynames[i])) continue;
|
||||
String sql = "select * from HrmSubCompany where subcompanyname='"
|
||||
|
|
@ -202,8 +244,10 @@ public class CompanyImportUtil {
|
|||
if (StringUtils.isNotEmpty(subcompanycode) || subcompanyshoworder != null) {
|
||||
recordSet.executeQuery(sql);
|
||||
recordSet.next();
|
||||
if (subcompanyshoworder == null) subcompanyshoworder = Float.valueOf(Util.null2s(recordSet.getString("showorder"), "0"));
|
||||
if (StringUtils.isEmpty(subcompanycode)) subcompanycode = Util.null2String(recordSet.getString("subcompanycode"), "");
|
||||
if (subcompanyshoworder == null)
|
||||
subcompanyshoworder = Integer.valueOf(Util.null2s(recordSet.getString("showorder"), "0"));
|
||||
if (StringUtils.isEmpty(subcompanycode))
|
||||
subcompanycode = Util.null2String(recordSet.getString("subcompanycode"), "");
|
||||
if (verifySubCompanyCode(subcompanycode, subcompanynames[i], parentId)) {
|
||||
sql = "update HrmSubCompany set subcompanycode= ? , showorder = ? where subcompanyname = ? and supsubcomid = ?";
|
||||
recordSet.executeUpdate(sql, subcompanycode, subcompanyshoworder, subcompanynames[i], parentId);
|
||||
|
|
@ -219,46 +263,49 @@ public class CompanyImportUtil {
|
|||
|
||||
/**
|
||||
* 根据分部名称获取分部Id,不存在就创建
|
||||
* @param subcompanyname 分部名称 eg:泛微广东>泛微深圳
|
||||
*
|
||||
* @param companyName 分部名称 eg:泛微广东>泛微深圳
|
||||
*/
|
||||
public int getSubCompanyId(String subcompanyname) {
|
||||
String[] subcompanynames = subcompanyname.split(">");
|
||||
public int getCompanyId(String companyName) {
|
||||
String[] companyNames = companyName.split(">");
|
||||
int currentId = 0;
|
||||
int parentId = 0;
|
||||
String sql;
|
||||
String sqlInsert;
|
||||
String subcompanycode = "";
|
||||
Float subcompanyshoworder = null;
|
||||
for (int i = 0; i < subcompanynames.length; i++) {
|
||||
if(subcompanynames[i] ==null && subcompanynames[i].equals("")){
|
||||
String companyCode = "";
|
||||
Integer companyShowOrder = null;
|
||||
for (int i = 0; i < companyNames.length; i++) {
|
||||
if (companyNames[i] == null && companyNames[i].equals("")) {
|
||||
continue;
|
||||
}
|
||||
sql = "select id from HrmSubCompany where subcompanyname='"
|
||||
+ subcompanynames[i].trim() + "' and supsubcomid=" + parentId;
|
||||
+ companyNames[i].trim() + "' and supsubcomid=" + parentId;
|
||||
|
||||
currentId = getResultSetId(sql);
|
||||
|
||||
//added by wcd 2015-02-06 [限制分部数]
|
||||
if (currentId == 0) {
|
||||
if (i == subcompanynames.length - 1) {
|
||||
if (i == companyNames.length - 1) {
|
||||
// 最后一层级 赋值编码和顺序
|
||||
subcompanycode = this.subcompanycode;
|
||||
subcompanyshoworder = this.subcompanyshoworder;
|
||||
if (subcompanyshoworder == null) subcompanyshoworder = 0.00F;
|
||||
companyCode = this.subcompanycode;
|
||||
companyShowOrder = this.subcompanyshoworder;
|
||||
if (companyShowOrder == null) {
|
||||
companyShowOrder = 0;
|
||||
}
|
||||
}
|
||||
if(AjaxManager.getData("", "getLnScCount;mf").equals("true")){
|
||||
if (AjaxManager.getData("", "getLnScCount;mf").equals("true")) {
|
||||
// 如果编码为空 自动生成编码
|
||||
try {
|
||||
subcompanycode = CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.SUBCOMPANY, subcompanycode);
|
||||
companyCode = CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.SUBCOMPANY, companyCode);
|
||||
} catch (Exception e) {
|
||||
setMessage("," + e.getMessage());
|
||||
new BaseBean().writeLog(e);
|
||||
return -1;
|
||||
}
|
||||
sqlInsert = "insert into HrmSubCompany(subcompanyname,subcompanydesc,companyid,supsubcomid,subcompanycode,showorder,"+ DbFunctionUtil.getInsertColumnSql()+") values('"
|
||||
+ subcompanynames[i] +"','"+subcompanynames[i]+"',1" + "," + parentId + ",'" + subcompanycode+ "'," + subcompanyshoworder + ","+DbFunctionUtil.getInsertColumnValueSql(new RecordSet().getDBType(), 1)+")"; // 创建
|
||||
sqlInsert = "insert into HrmSubCompany(subcompanyname,subcompanydesc,companyid,supsubcomid,subcompanycode,showorder," + DbFunctionUtil.getInsertColumnSql() + ") values('"
|
||||
+ companyNames[i] + "','" + companyNames[i] + "',1" + "," + parentId + ",'" + companyCode + "'," + companyShowOrder + "," + DbFunctionUtil.getInsertColumnValueSql(new RecordSet().getDBType(), 1) + ")"; // 创建
|
||||
boolean isSuccess = execSql(sqlInsert);
|
||||
HrmTriggerUtil.generateSubcompanyPinyin(subcompanynames[i], null);
|
||||
HrmTriggerUtil.generateSubcompanyPinyin(companyNames[i], null);
|
||||
currentId = getResultSetId(sql);
|
||||
HrmTriggerUtil.Tri_I_SubComKPICheckFlow(String.valueOf(currentId));
|
||||
sql = "insert into leftmenuconfig (userid,infoid,visible,viewindex,resourceid,resourcetype,locked,lockedbyid,usecustomname,customname,customname_e) select distinct userid,infoid,visible,viewindex," + currentId + ",2,locked,lockedbyid,usecustomname,customname,customname_e from leftmenuconfig where resourcetype=1 and resourceid=1";
|
||||
|
|
@ -266,19 +313,19 @@ public class CompanyImportUtil {
|
|||
sql = "insert into mainmenuconfig (userid,infoid,visible,viewindex,resourceid,resourcetype,locked,lockedbyid,usecustomname,customname,customname_e) select distinct userid,infoid,visible,viewindex," + currentId + ",2,locked,lockedbyid,usecustomname,customname,customname_e from mainmenuconfig where resourcetype=1 and resourceid=1";
|
||||
execSql(sql);
|
||||
|
||||
if(isSuccess){
|
||||
if (isSuccess) {
|
||||
//同步分部数据到矩阵
|
||||
MatrixUtil.updateSubcompayData("" + currentId);
|
||||
HrmFaceCheckManager.sync(currentId+"",HrmFaceCheckManager.getOptInsert(),"hrm_import_subcompany",HrmFaceCheckManager.getOaSubcompany());
|
||||
HrmFaceCheckManager.sync(currentId + "", HrmFaceCheckManager.getOptInsert(), "hrm_import_subcompany", HrmFaceCheckManager.getOaSubcompany());
|
||||
}
|
||||
|
||||
insertSysLog(subcompanynames[i]);
|
||||
insertSysLog(companyNames[i]);
|
||||
} else {
|
||||
currentId = -1;
|
||||
}
|
||||
}
|
||||
parentId = currentId;
|
||||
if(currentId != -1)
|
||||
if (currentId != -1)
|
||||
rtxService.addSubCompany(parentId); //同步RTX
|
||||
}
|
||||
return currentId;
|
||||
|
|
@ -286,10 +333,11 @@ public class CompanyImportUtil {
|
|||
|
||||
/**
|
||||
* 获取部门id,不存在就创建
|
||||
* @param deptNames 部门名称
|
||||
* @param subCompanyId 所属分部id
|
||||
*
|
||||
* @param deptNames 部门名称
|
||||
* @param subCompanyId 所属分部id
|
||||
*/
|
||||
public int getDeptId(String deptNames, int subCompanyId){
|
||||
public int getDeptId(String deptNames, int subCompanyId) {
|
||||
String[] deptName = deptNames.split(">");
|
||||
int currentId = 0;
|
||||
int parentId = 0;
|
||||
|
|
@ -299,14 +347,14 @@ public class CompanyImportUtil {
|
|||
String departmentcode = "";
|
||||
Float departmentshoworder = null;
|
||||
for (int i = 0; i < deptName.length; i++) {
|
||||
if(deptName[i] == null || deptName[i].equals("")){
|
||||
if (deptName[i] == null || deptName[i].equals("")) {
|
||||
continue;
|
||||
}
|
||||
sql = "select id from HrmDepartment where subcompanyid1="+ subCompanyId + " and departmentname='"+ deptName[i].trim() + "' and supdepid=" + parentId +" and (canceled !=1 or canceled is null)";
|
||||
sql = "select id from HrmDepartment where subcompanyid1=" + subCompanyId + " and departmentname='" + deptName[i].trim() + "' and supdepid=" + parentId + " and (canceled !=1 or canceled is null)";
|
||||
currentId = getResultSetId(sql);
|
||||
|
||||
if (currentId == 0) {
|
||||
if (i == deptName.length -1) {
|
||||
if (i == deptName.length - 1) {
|
||||
departmentcode = this.departmentcode;
|
||||
departmentshoworder = this.departmentshoworder;
|
||||
if (departmentshoworder == null) departmentshoworder = 0.00F;
|
||||
|
|
@ -319,16 +367,16 @@ public class CompanyImportUtil {
|
|||
new BaseBean().writeLog(e);
|
||||
return -1;
|
||||
}
|
||||
sqlInsert = "insert into HrmDepartment (departmentname,Departmentmark,subcompanyid1,supdepid,departmentcode,showorder,"+DbFunctionUtil.getInsertColumnSql()+") values('"
|
||||
+ deptName[i]+"','"+deptName[i]+"',"+ subCompanyId+ ","+ parentId + ",'"+ departmentcode + "',"+ departmentshoworder + ","+DbFunctionUtil.getInsertColumnValueSql(new RecordSet().getDBType(), 1)+")"; // 创建
|
||||
sqlInsert = "insert into HrmDepartment (departmentname,Departmentmark,subcompanyid1,supdepid,departmentcode,showorder," + DbFunctionUtil.getInsertColumnSql() + ") values('"
|
||||
+ deptName[i] + "','" + deptName[i] + "'," + subCompanyId + "," + parentId + ",'" + departmentcode + "'," + departmentshoworder + "," + DbFunctionUtil.getInsertColumnValueSql(new RecordSet().getDBType(), 1) + ")"; // 创建
|
||||
boolean isSuccess = execSql(sqlInsert);
|
||||
HrmTriggerUtil.generateDepartmentPinyin(deptName[i], null);
|
||||
currentId = getResultSetId(sql);
|
||||
HrmTriggerUtil.Tri_I_DeptKPICheckFlow(String.valueOf(currentId));
|
||||
if(isSuccess){
|
||||
if (isSuccess) {
|
||||
//同步部门数据到矩阵
|
||||
MatrixUtil.updateDepartmentData("" + currentId);
|
||||
HrmFaceCheckManager.sync(currentId+"",HrmFaceCheckManager.getOptInsert(),"hrm_import_deptment",HrmFaceCheckManager.getOaDepartment());
|
||||
HrmFaceCheckManager.sync(currentId + "", HrmFaceCheckManager.getOptInsert(), "hrm_import_deptment", HrmFaceCheckManager.getOaDepartment());
|
||||
}
|
||||
|
||||
insertSysLog(deptName[i]);
|
||||
|
|
@ -341,7 +389,8 @@ public class CompanyImportUtil {
|
|||
|
||||
/**
|
||||
* 获得查询结果Id
|
||||
* @param sql 查询语句
|
||||
*
|
||||
* @param sql 查询语句
|
||||
*/
|
||||
public int getResultSetId(String sql) {
|
||||
int currentId = 0;
|
||||
|
|
@ -358,14 +407,15 @@ public class CompanyImportUtil {
|
|||
|
||||
/**
|
||||
* 执行插入操作
|
||||
*
|
||||
* @param sql
|
||||
*/
|
||||
public boolean execSql(String sql) {
|
||||
return recordSet.execute(sql);
|
||||
}
|
||||
|
||||
public void removeCache(){
|
||||
try{
|
||||
public void removeCache() {
|
||||
try {
|
||||
|
||||
weaver.matrix.MatrixUtil.sysSubcompayData();
|
||||
weaver.matrix.MatrixUtil.sysDepartmentData();
|
||||
|
|
@ -377,7 +427,7 @@ public class CompanyImportUtil {
|
|||
DepartmentComInfo.removeCompanyCache();
|
||||
//初始化应用分权
|
||||
new weaver.hrm.appdetach.AppDetachComInfo().initSubDepAppData();
|
||||
}catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
new BaseBean().writeLog(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -414,11 +464,11 @@ public class CompanyImportUtil {
|
|||
this.subcompanycode = subcompanycode;
|
||||
}
|
||||
|
||||
public Float getSubcompanyshoworder() {
|
||||
public Integer getSubcompanyshoworder() {
|
||||
return subcompanyshoworder;
|
||||
}
|
||||
|
||||
public void setSubcompanyshoworder(Float subcompanyshoworder) {
|
||||
public void setSubcompanyshoworder(Integer subcompanyshoworder) {
|
||||
this.subcompanyshoworder = subcompanyshoworder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
package com.engine.organization.service.impl;
|
||||
package com.engine.organization.util.saveimport;
|
||||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.hrm.util.HrmWeakPasswordUtil;
|
||||
import com.engine.organization.entity.extend.po.ExtendInfoPO;
|
||||
import com.engine.organization.entity.hrmresource.param.HrmResourceImportParam;
|
||||
import com.engine.organization.mapper.extend.ExtendInfoMapper;
|
||||
import com.engine.organization.service.HrmResourceImportAdaptService;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import com.engine.organization.util.saveimport.SaveImportProcessUtil;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import weaver.common.DateUtil;
|
||||
|
|
@ -34,7 +31,7 @@ import java.util.regex.Pattern;
|
|||
* @createTime: 2022/06/27
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class HrmResourceImportAdaptServiceImpl extends Service implements HrmResourceImportAdaptService {
|
||||
public class HrmResourceImportAdaptUtil {
|
||||
|
||||
private String fileName;
|
||||
|
||||
|
|
@ -142,7 +139,6 @@ public class HrmResourceImportAdaptServiceImpl extends Service implements HrmRes
|
|||
* @param fu 上传参数
|
||||
* @return List
|
||||
*/
|
||||
@Override
|
||||
public List<String> creatImportMap(FileUploadToPath fu) {
|
||||
try {
|
||||
new BaseBean().writeLog("lxr2018>>>language2=" + userlanguage);
|
||||
|
|
@ -197,9 +193,7 @@ public class HrmResourceImportAdaptServiceImpl extends Service implements HrmRes
|
|||
/**
|
||||
* 获取人员map
|
||||
*/
|
||||
@Override
|
||||
public Map<String, HrmResourceImportParam> getHrmImportMap() {
|
||||
|
||||
return hrmResourceMap;
|
||||
}
|
||||
|
||||
|
|
@ -444,9 +438,9 @@ public class HrmResourceImportAdaptServiceImpl extends Service implements HrmRes
|
|||
|
||||
}
|
||||
}
|
||||
String currentDate = weaver.common.DateUtil.getCurrentDate();
|
||||
String currentDate = DateUtil.getCurrentDate();
|
||||
if (Util.null2String(importParam.getWork_start_date()).length() > 0 && Util.null2String(importParam.getWork_year()).length() == 0) {//计算工龄
|
||||
int day = weaver.common.DateUtil.dayDiff(importParam.getWork_start_date(), currentDate);
|
||||
int day = DateUtil.dayDiff(importParam.getWork_start_date(), currentDate);
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
importParam.setWork_year(df.format(day / 365.0));
|
||||
}
|
||||
|
|
@ -1059,7 +1053,6 @@ public class HrmResourceImportAdaptServiceImpl extends Service implements HrmRes
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserlanguage(int userlanguage) {
|
||||
this.userlanguage = userlanguage;
|
||||
}
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
package com.engine.organization.service.impl;
|
||||
package com.engine.organization.util.saveimport;
|
||||
|
||||
import com.engine.common.entity.EncryptFieldEntity;
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.encrypt.biz.EncryptFieldConfigComInfo;
|
||||
import com.engine.hrm.entity.RuleCodeType;
|
||||
import com.engine.hrm.service.ImportLogService;
|
||||
|
|
@ -26,7 +25,6 @@ import com.engine.organization.mapper.hrmresource.HrmResourceMapper;
|
|||
import com.engine.organization.mapper.job.JobMapper;
|
||||
import com.engine.organization.mapper.post.PostInfoMapper;
|
||||
import com.engine.organization.mapper.post.PostMapper;
|
||||
import com.engine.organization.service.HrmResourceImportProcessService;
|
||||
import com.engine.organization.util.PageInfoSortUtil;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import ln.LN;
|
||||
|
|
@ -61,10 +59,10 @@ import java.util.regex.Pattern;
|
|||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/06/27
|
||||
* @createTime: 2022/06/30
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class HrmResourceImportProcessServiceImpl extends Service implements HrmResourceImportProcessService {
|
||||
public class HrmResourceImportProcessUtil {
|
||||
|
||||
|
||||
private final Map<String, Integer> keyMap = new HashMap<>(); //看数据库是否有重复,将数据库现有的数据查出<id,workcode_lastname>
|
||||
|
|
@ -133,12 +131,10 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
|
|||
return MapperProxyFactory.getProxy(PostMapper.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> init(HttpServletRequest request) {
|
||||
Map<String, Object> retmap = new HashMap<>();
|
||||
try {
|
||||
|
|
@ -231,7 +227,6 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
|
|||
*
|
||||
* @param hrMap 人员数据Map集合
|
||||
*/
|
||||
@Override
|
||||
public void processMap(Map<String, HrmResourceImportParam> hrMap) {//增加同步锁,防止同时多次调用
|
||||
List<ImportLog> resultList = new ArrayList<>(); //导入结果
|
||||
RecordSet recordSet = new RecordSet();
|
||||
|
|
@ -107,7 +107,7 @@ public class SaveImportProcessUtil {
|
|||
|
||||
public SaveImportProcessUtil() {
|
||||
// TODO 组织导入类
|
||||
mapImportSource.put("company", new String[]{HrmCompany.class.getName()});
|
||||
mapImportSource.put("company", new String[]{CompanyImportUtil.class.getName()});
|
||||
|
||||
mapImportSource.put("jobtitle", new String[]{HrmJobTitle.class.getName()});
|
||||
mapImportSource.put("group", new String[]{HrmGroup.class.getName()});
|
||||
|
|
@ -268,9 +268,7 @@ public class SaveImportProcessUtil {
|
|||
method = importSourceClass.getMethod("valExcelData");
|
||||
try {
|
||||
valErrorInfo = (String) method.invoke(obj);
|
||||
//TimeUnit.SECONDS.sleep(2);
|
||||
} catch (Exception e) {
|
||||
//this.errorInfo.add("【"+ importSourceName+ "】第"+(i+1)+"行数据,验证失败!");
|
||||
//验证出错返回错误信息
|
||||
params = new HashMap<>();
|
||||
params.put("pId", this.pId);
|
||||
|
|
|
|||
Loading…
Reference in New Issue