人员导入

pull/128/MERGE^2
dxfeng 3 years ago
parent 2fb33877f5
commit ff06d705e7

@ -43,7 +43,7 @@ public class PostInfoSearchParam {
/** /**
* *
*/ */
private Integer postId; private Long postId;
/** /**
* *
*/ */

@ -45,7 +45,7 @@ public class PostInfoPO {
/** /**
* *
*/ */
private Integer postId; private Long postId;
/** /**
* *
*/ */

@ -25,8 +25,11 @@ public interface PostInfoMapper {
*/ */
List<PostInfoPO> listByNo(@Param("postInfoNo") String postInfoNo); List<PostInfoPO> listByNo(@Param("postInfoNo") String postInfoNo);
PostInfoPO getPostInfoByNameAndPostId(@Param("postInfoName") String postInfoName, @Param("postId") Long postId);
/** /**
* ID * ID
*
* @param id * @param id
* @return * @return
*/ */
@ -43,6 +46,7 @@ public interface PostInfoMapper {
/** /**
* *
*
* @param postInfoPO * @param postInfoPO
* @return * @return
*/ */
@ -63,6 +67,7 @@ public interface PostInfoMapper {
* @return * @return
*/ */
int updateForbiddenTagById(PostInfoPO postInfoPO); int updateForbiddenTagById(PostInfoPO postInfoPO);
/** /**
* *
* *

@ -60,6 +60,11 @@
#{id} #{id}
</foreach> </foreach>
</select> </select>
<select id="getPostInfoByNameAndPostId" resultMap="BaseResultMap">
select
<include refid="baseColumns"/>
from jcl_org_post_info t where post_info_name = #{postInfoName} and post_id = #{postId} AND delete_type = 0
</select>
<update id="updatePostInfo" parameterType="com.engine.organization.entity.postion.po.PostInfoPO"> <update id="updatePostInfo" parameterType="com.engine.organization.entity.postion.po.PostInfoPO">
update jcl_org_post_info update jcl_org_post_info

@ -26,6 +26,8 @@ public interface PostMapper {
*/ */
PostPO getPostByID(@Param("id") long id); PostPO getPostByID(@Param("id") long id);
List<PostPO> listByName(@Param("postName") String postName);
/** /**
* ID * ID
* *

@ -51,6 +51,11 @@
<select id="getTreeData" resultMap="TreeResultMap"> <select id="getTreeData" resultMap="TreeResultMap">
select id , post_name from jcl_org_post where delete_type ='0' select id , post_name from jcl_org_post where delete_type ='0'
</select> </select>
<select id="listByName" resultMap="BaseResultMap">
select
<include refid="baseColumns"/>
from jcl_org_post t where post_name = #{postName} AND delete_type = 0
</select>
<update id="updatePost" parameterType="com.engine.organization.entity.postion.po.PostPO"> <update id="updatePost" parameterType="com.engine.organization.entity.postion.po.PostPO">
update jcl_org_post update jcl_org_post

@ -841,10 +841,9 @@ public class HrmResourceImportAdaptServiceImpl extends Service implements HrmRes
if (fieldType.equals("java.lang.String")) if (fieldType.equals("java.lang.String"))
method.invoke(importParam, cellValue); method.invoke(importParam, cellValue);
else if (fieldType.equals("java.lang.Integer")) { else if (fieldType.equals("java.lang.Integer")) {
if (!cellValue.equals("")) if (!cellValue.equals("")) {
method.invoke(importParam, Integer.parseInt(cellValue)); method.invoke(importParam, Integer.parseInt(cellValue));
else }
method.invoke(importParam, 0x7fffffff);
} else if (fieldType.equals("java.lang.Float") && !cellValue.equals("")) } else if (fieldType.equals("java.lang.Float") && !cellValue.equals(""))
method.invoke(importParam, Float.parseFloat(cellValue)); method.invoke(importParam, Float.parseFloat(cellValue));
else if (fieldType.equals("java.lang.Short") && !cellValue.equals("")) { else if (fieldType.equals("java.lang.Short") && !cellValue.equals("")) {

@ -9,7 +9,6 @@ import com.engine.hrm.entity.RuleCodeType;
import com.engine.hrm.service.ImportLogService; import com.engine.hrm.service.ImportLogService;
import com.engine.hrm.service.impl.ImportLogServiceImpl; import com.engine.hrm.service.impl.ImportLogServiceImpl;
import com.engine.hrm.util.CodeRuleManager; import com.engine.hrm.util.CodeRuleManager;
import com.engine.hrm.util.HrmTriggerUtil;
import com.engine.hrm.util.HrmWeakPasswordUtil; import com.engine.hrm.util.HrmWeakPasswordUtil;
import com.engine.hrm.util.face.HrmFaceCheckManager; import com.engine.hrm.util.face.HrmFaceCheckManager;
import com.engine.hrm.util.face.ValidateFieldManager; import com.engine.hrm.util.face.ValidateFieldManager;
@ -19,6 +18,8 @@ import com.engine.organization.entity.department.po.DepartmentPO;
import com.engine.organization.entity.hrmresource.param.HrmResourceImportParam; import com.engine.organization.entity.hrmresource.param.HrmResourceImportParam;
import com.engine.organization.entity.hrmresource.po.HrmResourcePO; import com.engine.organization.entity.hrmresource.po.HrmResourcePO;
import com.engine.organization.entity.job.po.JobPO; import com.engine.organization.entity.job.po.JobPO;
import com.engine.organization.entity.postion.po.PostInfoPO;
import com.engine.organization.entity.postion.po.PostPO;
import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.comp.CompMapper;
import com.engine.organization.mapper.department.DepartmentMapper; import com.engine.organization.mapper.department.DepartmentMapper;
import com.engine.organization.mapper.hrmresource.HrmResourceMapper; import com.engine.organization.mapper.hrmresource.HrmResourceMapper;
@ -28,39 +29,27 @@ import com.engine.organization.mapper.post.PostMapper;
import com.engine.organization.service.HrmResourceImportProcessService; import com.engine.organization.service.HrmResourceImportProcessService;
import com.engine.organization.util.PageInfoSortUtil; import com.engine.organization.util.PageInfoSortUtil;
import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.db.MapperProxyFactory;
import com.weaver.integration.ldap.sync.oa.OaSync;
import com.weaver.integration.ldap.util.AuthenticUtil;
import ln.LN; import ln.LN;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject; import org.json.JSONObject;
import weaver.common.DateUtil;
import weaver.common.StringUtil; import weaver.common.StringUtil;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.encrypt.EncryptUtil; import weaver.encrypt.EncryptUtil;
import weaver.general.BaseBean; import weaver.general.BaseBean;
import weaver.general.PasswordUtil; import weaver.general.PasswordUtil;
import weaver.general.TimeUtil;
import weaver.general.Util; import weaver.general.Util;
import weaver.hrm.User; import weaver.hrm.User;
import weaver.hrm.common.DbFunctionUtil;
import weaver.hrm.common.database.dialect.DbDialectFactory; import weaver.hrm.common.database.dialect.DbDialectFactory;
import weaver.hrm.common.database.dialect.DialectUtil; import weaver.hrm.common.database.dialect.DialectUtil;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.definedfield.HrmFieldManager; import weaver.hrm.definedfield.HrmFieldManager;
import weaver.hrm.job.JobActivitiesComInfo;
import weaver.hrm.job.JobGroupsComInfo;
import weaver.hrm.job.JobTitlesComInfo;
import weaver.hrm.job.UseKindComInfo;
import weaver.hrm.location.LocationComInfo;
import weaver.hrm.passwordprotection.manager.HrmResourceManager; import weaver.hrm.passwordprotection.manager.HrmResourceManager;
import weaver.hrm.resource.ResourceComInfo; import weaver.hrm.resource.ResourceComInfo;
import weaver.hrm.settings.ChgPasswdReminder; import weaver.hrm.settings.ChgPasswdReminder;
import weaver.hrm.settings.RemindSettings; import weaver.hrm.settings.RemindSettings;
import weaver.hrm.tools.HrmDateCheck;
import weaver.interfaces.hrm.HrmServiceManager;
import weaver.join.hrm.in.ImportLog; import weaver.join.hrm.in.ImportLog;
import weaver.join.hrm.in.processImpl.HrmTlevelManager; import weaver.join.hrm.in.processImpl.HrmTlevelManager;
import weaver.rtx.OrganisationCom;
import weaver.systeminfo.SystemEnv; import weaver.systeminfo.SystemEnv;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -80,8 +69,6 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
private final Map<String, Integer> keyMap = new HashMap<>(); //看数据库是否有重复,将数据库现有的数据查出<id,workcode_lastname> private final Map<String, Integer> keyMap = new HashMap<>(); //看数据库是否有重复,将数据库现有的数据查出<id,workcode_lastname>
private final Map<String, String> isADAccountMap = new HashMap<>();
private final Map<String, Integer> certificateNums = new HashMap<>();//已存在的身份证 private final Map<String, Integer> certificateNums = new HashMap<>();//已存在的身份证
Map<String, Map<String, String>> checkInfos = new HashMap<>(); Map<String, Map<String, String>> checkInfos = new HashMap<>();
@ -94,8 +81,6 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
private final int userlanguage = 7; //登录语言 private final int userlanguage = 7; //登录语言
char separator = Util.getSeparator();
LN license = new LN(); //license LN license = new LN(); //license
String keyField = ""; String keyField = "";
@ -260,16 +245,6 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
getKeyMap(keyField); //获取重复性验证字段Map getKeyMap(keyField); //获取重复性验证字段Map
Long id; Long id;
ResourceComInfo resourcecominfo = new ResourceComInfo();
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
JobActivitiesComInfo jobActivitiesComInfo = new JobActivitiesComInfo();
JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo();
JobGroupsComInfo jobGroupsComInfo = new JobGroupsComInfo();
LocationComInfo locationComInfo = new LocationComInfo();
UseKindComInfo useKindComInfo = new UseKindComInfo();
Set<String> keySet = hrMap.keySet(); Set<String> keySet = hrMap.keySet();
Object[] keyArray = keySet.toArray(); Object[] keyArray = keySet.toArray();
@ -304,15 +279,14 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
new BaseBean().writeLog(e); new BaseBean().writeLog(e);
} }
Object obj; String obj;
HrmResourcePO hrmResourcePO; HrmResourcePO hrmResourcePO;
for (Object o : keyArray) { for (Object o : keyArray) {
obj = o; obj = o.toString();
hrmResourceImportParam = hrMap.get(obj); hrmResourceImportParam = hrMap.get(obj.toString());
key = (String) obj; key = (String) obj;
hrmResourcePO = new HrmResourcePO(); hrmResourcePO = new HrmResourcePO();
this.rowNum++; this.rowNum++;
//TimeUnit.SECONDS.sleep(1);
try { // 异常处理 try { // 异常处理
if (operateType.equals("add")) { if (operateType.equals("add")) {
@ -376,6 +350,7 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
continue; continue;
} }
} }
companyId = 0 == companyId ? null : companyId;
hrmResourcePO.setCompanyId(companyId); hrmResourcePO.setCompanyId(companyId);
} else { } else {
resultList.add(createLog(hrmResourceImportParam, "创建", "失败", SystemEnv.getHtmlLabelName(83526, userlanguage))); resultList.add(createLog(hrmResourceImportParam, "创建", "失败", SystemEnv.getHtmlLabelName(83526, userlanguage)));
@ -452,15 +427,15 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
//上级id //上级id
if (hrmResourceImportParam.getManager_id() != null) { if (hrmResourceImportParam.getManager_id() != null) {
int managerid = getManagerId("", hrmResourceImportParam.getManager_id(), keyField); int managerid = getManagerId(hrmResourceImportParam.getManager_id(), keyField);
hrmResourcePO.setManagerId(managerid); hrmResourcePO.setManagerId(0 == managerid ? null : managerid);
//如果vo.getManagerid()有值但manageid未找到说明填写有误 //如果vo.getManagerid()有值但manageid未找到说明填写有误
if (!hrmResourceImportParam.getManager_id().equals("") && managerid == 0) { if (!hrmResourceImportParam.getManager_id().equals("") && managerid == 0) {
resultList.add(createLog(hrmResourceImportParam, "创建", "失败", SystemEnv.getHtmlLabelName(83532, userlanguage))); resultList.add(createLog(hrmResourceImportParam, "创建", "失败", SystemEnv.getHtmlLabelName(83532, userlanguage)));
continue; continue;
} }
} else { } else {
hrmResourcePO.setManagerId(0); hrmResourcePO.setManagerId(null);
} }
// 助理id // 助理id
@ -617,22 +592,49 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
//职级 //职级
if (isInteger(hrmResourceImportParam.getJob_level())) { if (isInteger(hrmResourceImportParam.getJob_level())) {
// TODO // TODO 职级
Long jobLevel = hrmResourceImportParam.getJob_level().equals("") ? 0 : Long.parseLong(hrmResourceImportParam.getJob_level()); Long jobLevel = hrmResourceImportParam.getJob_level().equals("") ? 0 : Long.parseLong(hrmResourceImportParam.getJob_level());
hrmResourcePO.setJobLevel(jobLevel); hrmResourcePO.setJobLevel(jobLevel);
} else { } else {
hrmResourcePO.setJobLevel(0L); hrmResourcePO.setJobLevel(0L);
} }
Long jobGroupId = null; Long jobGroupId = null;
//TODO 职务类别
if (hrmResourceImportParam.getJob_group_id() != null) { if (hrmResourceImportParam.getJob_group_id() != null) {
List<PostPO> postPOS = getPostMapper().listByName(hrmResourceImportParam.getJob_group_id());
if (CollectionUtils.isNotEmpty(postPOS)) {
jobGroupId = postPOS.get(0).getId();
} else {
PostPO postPO = PostPO.builder()
.postName(hrmResourceImportParam.getJob_group_id())
.creator((long) user.getUID())
.deleteType(0)
.createTime(new Date())
.build();
getPostMapper().insertIgnoreNull(postPO);
jobGroupId = postPO.getId();
}
hrmResourcePO.setJobGroupId(jobGroupId);
} }
// 职务 // 职务
if (hrmResourceImportParam.getJob_activity() != null) { if (hrmResourceImportParam.getJob_activity() != null) {
// TODO 职务 if (null == jobGroupId) {
hrmResourcePO.setJobActivity(null); resultList.add(createLog(hrmResourceImportParam, "创建", "失败", "职务导入错误,未找到对应职务类别"));
continue;
}
PostInfoPO postInfoPO = getPostInfoMapper().getPostInfoByNameAndPostId(hrmResourceImportParam.getJob_activity(), jobGroupId);
if (null == postInfoPO) {
postInfoPO = PostInfoPO.builder()
.postInfoNo(hrmResourceImportParam.getJob_activity())
.postInfoName(hrmResourceImportParam.getJob_activity())
.postId(jobGroupId)
.creator((long) user.getUID())
.deleteType(0)
.createTime(new Date())
.build();
getPostInfoMapper().insertIgnoreNull(postInfoPO);
}
hrmResourcePO.setJobActivity(postInfoPO.getId());
} }
//用工性质 //用工性质
@ -642,7 +644,6 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
} else { } else {
hrmResourcePO.setUseKind(0); hrmResourcePO.setUseKind(0);
} }
//如果新增导入的时候登陆名不为空需要校验一下当前的license
// 手机 办公电话 // 手机 办公电话
@ -684,6 +685,12 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
} }
} }
} }
// 显示顺序
if (null != hrmResourceImportParam.getShow_order()) {
hrmResourcePO.setShowOrder(hrmResourceImportParam.getShow_order());
} else {
hrmResourcePO.setShowOrder(id.intValue());
}
String[] encrypts = PasswordUtil.encrypt(password_tmp); String[] encrypts = PasswordUtil.encrypt(password_tmp);
HrmFaceCheckManager.setUserPassowrd(id + "", password_tmp); HrmFaceCheckManager.setUserPassowrd(id + "", password_tmp);
@ -699,9 +706,9 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
StringBuilder insertFields = new StringBuilder(); StringBuilder insertFields = new StringBuilder();
StringBuilder insertValues = new StringBuilder(); StringBuilder insertValues = new StringBuilder();
String workcode = hrmResourceImportParam.getWork_code(); String workCode = hrmResourceImportParam.getWork_code();
workcode = CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.USER, workcode); workCode = CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.USER, workCode);
hrmResourceImportParam.setWork_code(workcode); hrmResourceImportParam.setWork_code(workCode);
for (String s : fields) { for (String s : fields) {
Field resourcePOClassField = resourcePOClass.getDeclaredField(PageInfoSortUtil.underlineToHump(s)); Field resourcePOClassField = resourcePOClass.getDeclaredField(PageInfoSortUtil.underlineToHump(s));
@ -714,11 +721,12 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
paramClassDeclaredField.setAccessible(true); paramClassDeclaredField.setAccessible(true);
//首先取hrm对象中的数据没有去vo中的 //首先取hrm对象中的数据没有去vo中的
boolean isNumber = hrmFieldType.endsWith("Long") || hrmFieldType.endsWith("Integer") || hrmFieldType.endsWith("Short") || hrmFieldType.endsWith("Float");
if (resourcePOClassField.get(hrmResourcePO) != null) { if (resourcePOClassField.get(hrmResourcePO) != null) {
if (hrmFieldType.endsWith("String")) { if (hrmFieldType.endsWith("String")) {
insertFields.append(s).append(","); insertFields.append(s).append(",");
insertValues.append("'").append(resourcePOClassField.get(hrmResourcePO)).append("',"); insertValues.append("'").append(resourcePOClassField.get(hrmResourcePO)).append("',");
} else if (hrmFieldType.endsWith("Integer") || hrmFieldType.endsWith("Short") || hrmFieldType.endsWith("Float")) { } else if (isNumber) {
insertFields.append(s).append(","); insertFields.append(s).append(",");
String insertValueStr = Util.null2String(resourcePOClassField.get(hrmResourcePO)); String insertValueStr = Util.null2String(resourcePOClassField.get(hrmResourcePO));
if ("".equals(insertValueStr) && recordSet.getDBType().equalsIgnoreCase("postgresql")) { if ("".equals(insertValueStr) && recordSet.getDBType().equalsIgnoreCase("postgresql")) {
@ -741,7 +749,7 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
insertFields.append(s).append(","); insertFields.append(s).append(",");
insertValues.append("'").append(paramClassDeclaredField.get(hrmResourceImportParam)).append("',"); insertValues.append("'").append(paramClassDeclaredField.get(hrmResourceImportParam)).append("',");
} }
} else if (hrmFieldType.endsWith("Integer") || hrmFieldType.endsWith("Short") || hrmFieldType.endsWith("Float")) { } else if (isNumber) {
insertFields.append(s).append(","); insertFields.append(s).append(",");
String insertValueStr = Util.null2String(paramClassDeclaredField.get(hrmResourceImportParam)); String insertValueStr = Util.null2String(paramClassDeclaredField.get(hrmResourceImportParam));
if ("".equals(insertValueStr) && recordSet.getDBType().equalsIgnoreCase("postgresql")) { if ("".equals(insertValueStr) && recordSet.getDBType().equalsIgnoreCase("postgresql")) {
@ -754,8 +762,6 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
} }
} }
insertStr = insertStr + insertFields + "creator,delete_type,create_time,update_time) values(" + insertValues + createrid + ",'" + 0 + "','" + date + "','" + date + "')"; insertStr = insertStr + insertFields + "creator,delete_type,create_time,update_time) values(" + insertValues + createrid + ",'" + 0 + "','" + date + "','" + date + "')";
boolean resourceInsertFlag = true; boolean resourceInsertFlag = true;
if (!execSql(insertStr)) {//添加人员信息 if (!execSql(insertStr)) {//添加人员信息
flag = false; flag = false;
@ -763,18 +769,10 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
} }
if (resourceInsertFlag) {// 仅当人员插入成功后才进行自定义字段操作 if (resourceInsertFlag) {// 仅当人员插入成功后才进行自定义字段操作
PasswordUtil.updateResourceSalt(id + "", salt); PasswordUtil.updateResourceSalt(id + "", salt);
if (!updateBaseData(hrmResourceImportParam.getBaseFields(), hrmResourceImportParam.getBaseFieldsValue(), id.intValue())) //添加基础字段信息 // TODO 更新自定义字段
flag = false; //if (!updateBaseData(hrmResourceImportParam.getBaseFields(), hrmResourceImportParam.getBaseFieldsValue(), id.intValue())) {
} // flag = false;
//}
/*添加人员缓存人员默认按id显示顺序,HrmResource_Trigger_Insert 人员共享 入职维护项目状态*/
if (flag) {
//人员显示顺序
if (hrmResourceImportParam.getShow_order() == null) {
// TODO
// String taxissql = ("update HrmResource set dsporder = " + id + " where id = " + id);
// recordSet.executeSql(taxissql);
}
} }
/*写日志*/ /*写日志*/
@ -825,9 +823,7 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
subCompanyName = subCompanyNames; subCompanyName = subCompanyNames;
companyId = getSubCompanyId(subCompanyName); companyId = getSubCompanyId(subCompanyName);
issameSub = false; issameSub = false;
} }
if (companyId == -9) { if (companyId == -9) {
resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getErrorMsgName(56, userlanguage))); resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getErrorMsgName(56, userlanguage)));
continue; continue;
@ -849,7 +845,8 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
continue; continue;
} }
} }
hrmResourcePO.setCompanyId((long) companyId); companyId = 0 == companyId ? null : companyId;
hrmResourcePO.setCompanyId(companyId);
} }
// 部门id // 部门id
@ -857,18 +854,8 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
if (!"".equals(Util.null2String(departmentNames))) { //部门存在时 if (!"".equals(Util.null2String(departmentNames))) { //部门存在时
if (!issameSub || !departmentNames.equals(departmentName)) { if (!issameSub || !departmentNames.equals(departmentName)) {
departmentName = departmentNames; departmentName = departmentNames;
departmentId = getDeptId(departmentName, (long) companyId);
if (departmentId == 0) {
resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getHtmlLabelName(83537, userlanguage)));
continue;
} }
if (departmentId == -2) { departmentId = getDeptId(departmentName, companyId);
resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getHtmlLabelName(126275, userlanguage)));
continue;
}
} else { //add sjh 50102需要考虑不同公司名称相同部门架构情况 此时部门ID是不同的
departmentId = getDeptId(departmentName, (long) companyId);
if (departmentId == 0) { if (departmentId == 0) {
resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getHtmlLabelName(83537, userlanguage))); resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getHtmlLabelName(83537, userlanguage)));
continue; continue;
@ -877,8 +864,7 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getHtmlLabelName(126275, userlanguage))); resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getHtmlLabelName(126275, userlanguage)));
continue; continue;
} }
} hrmResourcePO.setDepartmentId(departmentId);
hrmResourcePO.setDepartmentId((long) departmentId);
} }
//主账号id-sunjsh //主账号id-sunjsh
@ -915,48 +901,29 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
} }
} }
// 岗位id // TODO 岗位id
if ("".equals(Util.null2String(hrmResourceImportParam.getJob_title())) && (!"".equals(Util.null2String(hrmResourceImportParam.getJob_activity())) || !"".equals(Util.null2String(hrmResourceImportParam.getJob_group_id())))) { if ("".equals(Util.null2String(hrmResourceImportParam.getJob_title())) && (!"".equals(Util.null2String(hrmResourceImportParam.getJob_activity())) || !"".equals(Util.null2String(hrmResourceImportParam.getJob_group_id())))) {
resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getHtmlLabelName(83544, userlanguage))); resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getHtmlLabelName(83544, userlanguage)));
continue; continue;
} }
if (!"".equals(Util.null2String(hrmResourceImportParam.getJob_title()))) { if (!"".equals(Util.null2String(hrmResourceImportParam.getJob_title()))) {
String jobtitle; String jobNames = hrmResourceImportParam.getJob_title();
String jobactivityid; hrmResourcePO.setJobTitle(getJobTitles(companyId, departmentId, jobNames));
String jobactivityname;
String jobgroupid;
String jobgroupname;
if (hrmResourceImportParam.getJob_activity() == null) {
jobtitle = resourcecominfo.getJobTitle(hrmId);
jobactivityid = jobTitlesComInfo.getJobactivityid(jobtitle);
jobactivityname = jobActivitiesComInfo.getJobActivitiesname(jobactivityid);
} else jobactivityname = hrmResourceImportParam.getJob_activity();
if (hrmResourceImportParam.getJob_group_id() == null) {
jobtitle = resourcecominfo.getJobTitle(hrmId);
jobactivityid = jobTitlesComInfo.getJobactivityid(jobtitle);
jobgroupid = jobActivitiesComInfo.getJobgroupid(jobactivityid);
jobgroupname = jobGroupsComInfo.getJobGroupsname(jobgroupid);
} else {
jobgroupname = hrmResourceImportParam.getJob_group_id();
}
int jobtitleid = getJobTitles(hrmResourceImportParam.getJob_title(), jobactivityname, jobgroupname);
hrmResourcePO.setJobTitle((long) jobtitleid);
} }
if (Util.getIntValue(hrmId) < 0) continue; if (Util.getIntValue(hrmId) < 0) continue;
// 级序列 // 级序列
if (!"".equals(Util.null2String(hrmResourceImportParam.getManager_id()))) { if (!"".equals(Util.null2String(hrmResourceImportParam.getManager_id()))) {
int managerid = getManagerId(hrmId, hrmResourceImportParam.getManager_id(), keyField); int managerid = getManagerId(hrmResourceImportParam.getManager_id(), keyField);
//如果vo.getManagerid()有值但manageid未找到说明填写有误 //如果vo.getManagerid()有值但manageid未找到说明填写有误
if (hrmResourceImportParam.getManager_id() != null && !hrmResourceImportParam.getManager_id().equals("") && managerid == 0) { if (hrmResourceImportParam.getManager_id() != null && !hrmResourceImportParam.getManager_id().equals("") && managerid == 0) {
resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getHtmlLabelName(83532, userlanguage))); resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getHtmlLabelName(83532, userlanguage)));
continue; continue;
} }
hrmResourcePO.setManagerId(managerid); hrmResourcePO.setManagerId(0 == managerid ? null : managerid);
} else { } else {
hrmResourcePO.setManagerId(0); hrmResourcePO.setManagerId(null);
} }
// 助理id // 助理id
if (!"".equals(Util.null2String(hrmResourceImportParam.getAssistant_id()))) { if (!"".equals(Util.null2String(hrmResourceImportParam.getAssistant_id()))) {
@ -1068,7 +1035,6 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
int status = getStatus(hrmResourceImportParam.getStatus()); int status = getStatus(hrmResourceImportParam.getStatus());
hrmResourcePO.setStatus(status); hrmResourcePO.setStatus(status);
} else { } else {
// TODO 待验证
hrmResourcePO.setStatus(0); hrmResourcePO.setStatus(0);
} }
@ -1117,7 +1083,7 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
} else { } else {
// TODO // TODO
//安全级别为空时取缓存类中的安全级别 //安全级别为空时取缓存类中的安全级别
hrmResourcePO.setSecLevel(Integer.parseInt(resourcecominfo.getSeclevel(hrmId))); // hrmResourcePO.setSecLevel(Integer.parseInt(resourcecominfo.getSeclevel(hrmId)));
} }
//职级 //职级
@ -1126,20 +1092,50 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
hrmResourcePO.setJobLevel((long) joblevel); hrmResourcePO.setJobLevel((long) joblevel);
} }
//用工性质 // 职务分类
if (hrmResourceImportParam.getUse_kind() != null) { Long jobGroupId = null;
int usekind = getUseKind(hrmResourceImportParam.getUse_kind()); if (hrmResourceImportParam.getJob_group_id() != null) {
hrmResourcePO.setUseKind(usekind); List<PostPO> postPOS = getPostMapper().listByName(hrmResourceImportParam.getJob_group_id());
if (CollectionUtils.isNotEmpty(postPOS)) {
jobGroupId = postPOS.get(0).getId();
} else {
PostPO postPO = PostPO.builder()
.postName(hrmResourceImportParam.getJob_group_id())
.creator((long) user.getUID())
.deleteType(0)
.createTime(new Date())
.build();
getPostMapper().insertIgnoreNull(postPO);
jobGroupId = postPO.getId();
}
hrmResourcePO.setJobGroupId(jobGroupId);
} }
// 职务
//更新导入的时候如果登录名不为空需要校验一下当前的license if (hrmResourceImportParam.getJob_activity() != null) {
if (needCheckLicenseForUpdate(resourcecominfo, hrmId, hrmResourceImportParam)) { if (null == jobGroupId) {
license.reloadLicenseInfo(); resultList.add(createLog(hrmResourceImportParam, "创建", "失败", "职务导入错误,未找到对应职务类别"));
if (license.CkHrmnum() >= 0) {
resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getHtmlLabelName(83522, userlanguage)));
continue; continue;
} }
PostInfoPO postInfoPO = getPostInfoMapper().getPostInfoByNameAndPostId(hrmResourceImportParam.getJob_activity(), jobGroupId);
if (null == postInfoPO) {
postInfoPO = PostInfoPO.builder()
.postInfoNo(hrmResourceImportParam.getJob_activity())
.postInfoName(hrmResourceImportParam.getJob_activity())
.postId(jobGroupId)
.creator((long) user.getUID())
.deleteType(0)
.createTime(new Date())
.build();
getPostInfoMapper().insertIgnoreNull(postInfoPO);
}
hrmResourcePO.setJobActivity(postInfoPO.getId());
}
//用工性质
if (hrmResourceImportParam.getUse_kind() != null) {
int usekind = getUseKind(hrmResourceImportParam.getUse_kind());
hrmResourcePO.setUseKind(usekind);
} }
// 手机 办公电话 // 手机 办公电话
@ -1171,13 +1167,10 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
HrmFaceCheckManager.setUserPassowrd(keyMap.get(key) + "", orgPwd); HrmFaceCheckManager.setUserPassowrd(keyMap.get(key) + "", orgPwd);
} }
boolean flag = true; StringBuilder updateStr = new StringBuilder("update jcl_org_hrmresource set ");
StringBuilder updateStr = new StringBuilder("update hrmresource set ");
String tmpstatus = "";
for (int k = 1; k < fields.length; k++) { for (int k = 1; k < fields.length; k++) {
Field hrmField = resourcePOClass.getDeclaredField(fields[k]); Field hrmField = resourcePOClass.getDeclaredField(PageInfoSortUtil.underlineToHump(fields[k]));
Field paramClassDeclaredField = importParamClass.getDeclaredField(fields[k]); Field paramClassDeclaredField = importParamClass.getDeclaredField(fields[k]);
String hrmFieldType = hrmField.getType().getName(); String hrmFieldType = hrmField.getType().getName();
@ -1187,17 +1180,11 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
paramClassDeclaredField.setAccessible(true); paramClassDeclaredField.setAccessible(true);
if (Util.null2String(hrmField.get(hrmResourcePO)).trim().length() > 0) { if (Util.null2String(hrmField.get(hrmResourcePO)).trim().length() > 0) {
if (hrmFieldType.endsWith("String")) if (hrmFieldType.endsWith("String")) {
updateStr.append(fields[k]).append("='").append(hrmField.get(hrmResourcePO)).append("',"); updateStr.append(fields[k]).append("='").append(hrmField.get(hrmResourcePO)).append("',");
else if (hrmFieldType.endsWith("Integer") || hrmFieldType.endsWith("Short") || hrmFieldType.endsWith("Float")) } else if (hrmFieldType.endsWith("Long") || hrmFieldType.endsWith("Integer") || hrmFieldType.endsWith("Short") || hrmFieldType.endsWith("Float")) {
if (false) {
//0数据的这个临时改回去
} else {
updateStr.append(fields[k]).append("=").append(hrmField.get(hrmResourcePO)).append(","); updateStr.append(fields[k]).append("=").append(hrmField.get(hrmResourcePO)).append(",");
} }
if (fields[k].equals("status"))
tmpstatus = Util.null2String(hrmField.get(hrmResourcePO));
} else if (Util.null2String(paramClassDeclaredField.get(hrmResourceImportParam)).trim().length() > 0) { } else if (Util.null2String(paramClassDeclaredField.get(hrmResourceImportParam)).trim().length() > 0) {
if (voFieldType.endsWith("String")) { if (voFieldType.endsWith("String")) {
if (recordSet.getDBType().equalsIgnoreCase("mysql") || recordSet.getDBType().equalsIgnoreCase("postgresql")) { if (recordSet.getDBType().equalsIgnoreCase("mysql") || recordSet.getDBType().equalsIgnoreCase("postgresql")) {
@ -1209,10 +1196,7 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
} else { } else {
updateStr.append(fields[k]).append("='").append(paramClassDeclaredField.get(hrmResourceImportParam)).append("',"); updateStr.append(fields[k]).append("='").append(paramClassDeclaredField.get(hrmResourceImportParam)).append("',");
} }
} else if (voFieldType.endsWith("Integer") || voFieldType.endsWith("Short") || voFieldType.endsWith("Float")) { } else if (voFieldType.endsWith("Long") || voFieldType.endsWith("Integer") || voFieldType.endsWith("Short") || voFieldType.endsWith("Float")) {
if (paramClassDeclaredField.get(hrmResourceImportParam).equals(0) && false) {
} else {
if (voFieldType.endsWith("Integer") && (paramClassDeclaredField.get(hrmResourceImportParam).equals(0x7fffffff))) { if (voFieldType.endsWith("Integer") && (paramClassDeclaredField.get(hrmResourceImportParam).equals(0x7fffffff))) {
updateStr.append(fields[k]).append("=null,"); updateStr.append(fields[k]).append("=null,");
} else { } else {
@ -1220,134 +1204,14 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
} }
} }
} }
if (fields[k].equals("status"))
tmpstatus = Util.null2String(paramClassDeclaredField.get(hrmResourceImportParam));
}
} }
// TODO // TODO
// updateStr.append(" lastmodid=").append(lastmodid).append(",lastmoddate='").append(lastmoddate).append("',managerstr='").append(hrmResourcePO.getManagerstr()).append("',").append(DbFunctionUtil.getUpdateSetSql(new RecordSet().getDBType(), lastmodid)).append(" where id=").append(keyMap.get(key)); updateStr.append(" update_time ='").append(DateUtil.getCurrentDate()).append("' where id=").append(keyMap.get(key));
if (!execSql(updateStr.toString())) flag = false;
//同步密码到AD
if (flag && !"".equals(Util.null2String(hrmResourceImportParam.getPass_word()))) {
String userid = Util.null2String(keyMap.get(key));
String loginid = Util.null2String(resourcecominfo.getLoginID(userid));
String isADAccount = Util.null2String(isADAccountMap.get(userid));
if ("1".equals(isADAccount) && !"1".equals(userid) && new AuthenticUtil().checkType(loginid)) {
Map<String, String> map = new HashMap<>();
map.put("userid", userid);//OA人员id
map.put("loginid", loginid);//人员帐号
map.put("password", Util.null2String(hrmResourceImportParam.getPass_word()));//新密码
map.put("issysadmin", "true");//是否需要检验旧密码。0是检验。1,不需要检验。
String optype = "4"; //1强制修改密码操作。2首次登录密码操作3忘记密码找回。其它系统修改ad操作。
map.put("optype", optype);
Map<String, Object> retInfo = new OaSync("", "").modifyADPWDNew(map);
if (Util.null2String(retInfo.get("code")).equals("0")) {
//更新修改密码时间
String passwdchgdate = Util.null2String(TimeUtil.getCurrentDateString());
flag = recordSet.executeUpdate("update hrmresource set passwdchgdate=?, haschangepwd='y' where id = ?", passwdchgdate, userid);
} else {
flag = false;
new BaseBean().writeLog("人员导入更新人员密码同步至AD失败___retInfo___" + com.alibaba.fastjson.JSONObject.toJSONString(retInfo));
}
}
}
//如果更新为解聘、离职、退休,处理相关数据
if (("4".equals(tmpstatus) || "5".equals(tmpstatus) || "6".equals(tmpstatus)) && !tmpstatus.equals(resourcecominfo.getStatus("" + keyMap.get(key)))) {
OrganisationCom orgCom = new OrganisationCom();
HrmServiceManager hrmaction = new HrmServiceManager();
String tmpid;
String type = "5";
String procType = "HrmResource_Dismiss";
String statusType = "5";
if ("4".equals(tmpstatus)) {
type = "1";
procType = "HrmResource_Fire";
statusType = "4";
} else if ("6".equals(tmpstatus)) {
type = "6";
procType = "HrmResource_Retire";
statusType = "6";
}
int resourceid = keyMap.get(key);
String changedate = TimeUtil.getCurrentDateString();
String changereason = SystemEnv.getHtmlLabelName(17887, userlanguage);
String changecontractid = "";
String infoman = "";
String oldjobtitleid = resourcecominfo.getJobTitle("" + resourceid);
String para = "" + resourceid + separator + changedate + separator + changereason + separator + changecontractid + separator + infoman + separator + oldjobtitleid + separator + type + separator + "1";
recordSet.executeProc(procType, para);
recordSet.executeSql("select max(id) from HrmStatusHistory");
recordSet.next();
tmpid = recordSet.getString(1);
//删除角色成员
recordSet.executeSql("delete from hrmrolemembers where resourcetype =1 and resourceid=" + resourceid);
//删除手机版中设置的登录人员
recordSet.executeSql("delete from PluginLicenseUser where plugintype='mobile' and sharetype='0' and sharevalue='" + resourceid + "'");
//更新人员未离职,清空账号
recordSet.executeSql("update HrmResource set status = " + statusType + " ,loginid='',password='',account='', email='', tokenkey='', lastmoddate='" + changedate + "' where id = " + resourceid);
//删除自定义组成员
recordSet.executeSql("delete hrmgroupmembers where userid=" + resourceid);
//更新变更记录状态为已处理
recordSet.executeSql("update HrmStatusHistory set isdispose = 1 where id=" + tmpid);
boolean exist = orgCom.checkUser(resourceid);
if (exist) {
orgCom.deleteUser2(resourceid);
}
//OA与第三方接口单条数据同步方法开始
hrmaction.SynInstantHrmResource("" + resourceid, "3");
//OA与第三方接口单条数据同步方法结束
}
if (!updateBaseData(hrmResourceImportParam.getBaseFields(), hrmResourceImportParam.getBaseFieldsValue().trim(), keyMap.get(key)))
flag = false;
/*update HrmResource_Trigger */ execSql(updateStr.toString());
if (flag) { // TODO 更新自定义字段
recordSet.executeSql("select id from HrmResource_Trigger where id=" + hrmId); // updateBaseData(hrmResourceImportParam.getBaseFields(), hrmResourceImportParam.getBaseFieldsValue().trim(), keyMap.get(key));
if (recordSet.next()) {
// TODO recordSet.executeSql("update HrmResource_Trigger set managerid=" + hrmResourcePO.getManagerId() + ",departmentid=" + hrmResourcePO.getDepartmentId() + ",subcompanyid1=" + hrmResourcePO.getCompanyId() + ",seclevel=" + hrmResourcePO.getSecLevel() + ",managerstr='" + hrmResourcePO.getManagerstr() + "' where id=" + hrmId);
} else {
// TODO
// String para = "" + hrmId + separator + hrmResourcePO.getManagerId() + separator + hrmResourcePO.getDepartmentId() + separator + hrmResourcePO.getCompanyId() + separator + hrmResourcePO.getSecLevel() + separator + hrmResourcePO.getManagerstr();
// recordSet.executeProc("HrmResource_Trigger_Insert", para);
}
}
//更新下级managerstr
if (flag) {
HrmFaceCheckManager.sync(keyMap.get(key) + "", HrmFaceCheckManager.getOptUpdate(), "hrm_e9_import_resource", HrmFaceCheckManager.getOaResource());
new HrmDateCheck().calWorkInfo(hrmId);
resultList.add(createLog(hrmResourceImportParam, "更新", "成功", ""));
//qc313055 [80][90][缺陷]IM集成-解决人员导入更新人员信息时无账号列时IM同步会进行删除操作的问题 ---start
RecordSet rst = new RecordSet();
if (hrmResourceImportParam.getLogin_id() != null) {
//此时resourcecominfo对象还没有更新可以直接取
if (!"".equals(hrmResourceImportParam.getLogin_id())) {
} else {
rst.executeSql("select * from hrmresource where id='" + hrmId + "'");
String loginid = "";
if (rst.next()) {
loginid = rst.getString("loginid");
}
}
} else {
rst.executeSql("select * from hrmresource where id='" + hrmId + "'");
String loginid = "";
if (rst.next()) {
loginid = rst.getString("loginid");
}
}
} else {
resultList.add(createLog(hrmResourceImportParam, "更新", "失败", "系统错误,请联系管理员"));
}
} }
} catch (Exception e) { } catch (Exception e) {
//数据异常 //数据异常
@ -1360,20 +1224,6 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
new BaseBean().writeLog(e); new BaseBean().writeLog(e);
} }
//更新人员、分部、部门、职位、岗位、职位类型缓存
resourcecominfo.removeResourceCache();
departmentComInfo.removeCompanyCache();
subCompanyComInfo.removeCompanyCache();
jobActivitiesComInfo.removeJobActivitiesCache();
jobTitlesComInfo.removeJobTitlesCache();
jobGroupsComInfo.removeCompanyCache();
locationComInfo.removeLocationCache();
useKindComInfo.removeUseKindCache();
//初始化应用分权
new weaver.hrm.appdetach.AppDetachComInfo().initSubDepAppData();
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("pId", this.pId); params.put("pId", this.pId);
params.put("status", "over"); params.put("status", "over");
@ -1402,8 +1252,6 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
String[] baseFields = baseFild.split(","); String[] baseFields = baseFild.split(",");
String fielddbType; String fielddbType;
String sql = ""; String sql = "";
String scopeId = "-1";
EncryptUtil encryptUtil = new EncryptUtil();
RecordSet recordSet = new RecordSet(); RecordSet recordSet = new RecordSet();
try { try {
if (baseTypeMap == null) { if (baseTypeMap == null) {
@ -1430,18 +1278,11 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
sql = "insert into cus_fielddata "; sql = "insert into cus_fielddata ";
StringBuilder valueStr = new StringBuilder(); StringBuilder valueStr = new StringBuilder();
for (int i = 0; i < baseFields.length; i++) { for (int i = 0; i < baseFields.length; i++) {
String fieldname = baseFields[i];
JSONObject jsonObject = baseTypeMap.get(baseFields[i]); JSONObject jsonObject = baseTypeMap.get(baseFields[i]);
fielddbType = jsonObject.getString("fielddbtype"); fielddbType = jsonObject.getString("fielddbtype");
jsonObject.put("fieldvalue", baseValues[i]); jsonObject.put("fieldvalue", baseValues[i]);
String fieldvalue = HrmFieldManager.getReallyFieldvalue(jsonObject); String fieldvalue = HrmFieldManager.getReallyFieldvalue(jsonObject);
EncryptFieldEntity encryptFieldEntity = new EncryptFieldConfigComInfo().getFieldEncryptConfig("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId);
if (encryptFieldEntity != null && encryptFieldEntity.getIsEncrypt().equals("1")) {
//是否需要加密
fieldvalue = Util.null2String(encryptUtil.encryt("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId, fieldvalue, fieldvalue));
}
if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text")) if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text"))
valueStr.append(",").append("'").append(!fieldvalue.equals("") ? fieldvalue : "").append("'"); valueStr.append(",").append("'").append(!fieldvalue.equals("") ? fieldvalue : "").append("'");
else valueStr.append(",").append(!fieldvalue.equals("") ? fieldvalue : "NULL"); else valueStr.append(",").append(!fieldvalue.equals("") ? fieldvalue : "NULL");
@ -1465,7 +1306,9 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
* @return * @return
*/ */
public boolean updateBaseData(String baseFild, String baseValue, int id) { public boolean updateBaseData(String baseFild, String baseValue, int id) {
if (baseFild == null || baseFild.equals("")) return true; if (baseFild == null || baseFild.equals("")) {
return true;
}
//检查cus_fielddata表中是否存在对应id人员的基础自定义信息如果不存在则向数据库添加 //检查cus_fielddata表中是否存在对应id人员的基础自定义信息如果不存在则向数据库添加
RecordSet recordSet = new RecordSet(); RecordSet recordSet = new RecordSet();
@ -1567,7 +1410,7 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
currentId = getResultSetId(currentidsql); currentId = getResultSetId(currentidsql);
if (parentId == 0 && currentId == 0) { if (parentId == 0 && currentId == 0) {
recordSet.executeSql("select COUNT(id) from jcl_org_comp where " + supsubcomidConditon + " = 0 "); recordSet.execute("select COUNT(id) from jcl_org_comp where " + supsubcomidConditon + " = 0 ");
if (recordSet.next()) { if (recordSet.next()) {
curCount = recordSet.getInt(1); curCount = recordSet.getInt(1);
} }
@ -1587,8 +1430,7 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
.compNo(compNo) .compNo(compNo)
.compName(companyName.trim()) .compName(companyName.trim())
.compNameShort(companyName.trim()) .compNameShort(companyName.trim())
.parentCompany((long) parentId) .parentCompany(0 == parentId ? null : parentId)
// .forbiddenTag(0)
.creator((long) user.getUID()) .creator((long) user.getUID())
.deleteType(0) .deleteType(0)
.createTime(new Date()) .createTime(new Date())
@ -1649,8 +1491,8 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
.deptNo(deptNo) .deptNo(deptNo)
.deptName(deptName.trim()) .deptName(deptName.trim())
.deptNameShort(deptName.trim()) .deptNameShort(deptName.trim())
.parentComp(companyId) .parentComp(0 == companyId ? null : companyId)
.parentDept(parentId) .parentDept(0 == parentId ? null : parentId)
.forbiddenTag(0) .forbiddenTag(0)
.creator((long) user.getUID()) .creator((long) user.getUID())
.deleteType(0) .deleteType(0)
@ -1669,7 +1511,7 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
String[] jobNameArray = jobNames.split(">"); String[] jobNameArray = jobNames.split(">");
long currentId = 0L; long currentId = 0L;
Long parentId = 0L; long parentId = 0L;
String currentIdSql; String currentIdSql;
String sql; String sql;
RecordSet recordSet = new RecordSet(); RecordSet recordSet = new RecordSet();
@ -1697,9 +1539,9 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
JobPO jobPO = JobPO.builder() JobPO jobPO = JobPO.builder()
.jobNo(jobNo) .jobNo(jobNo)
.jobName(jobName) .jobName(jobName)
.parentComp(companyId) .parentComp(0 == companyId ? null : companyId)
.parentDept(departmentId) .parentDept(0 == departmentId ? null : departmentId)
.parentJob(parentId) .parentJob(0 == parentId ? null : parentId)
.forbiddenTag(0) .forbiddenTag(0)
.creator((long) user.getUID()) .creator((long) user.getUID())
.deleteType(0) .deleteType(0)
@ -1713,88 +1555,6 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
return currentId; return currentId;
} }
/**
* id
*
* @param jobtitlename
* @param jobactivityname
* @param jobgroupname
* @return
*/
public int getJobTitles(String jobtitlename, String jobactivityname, String jobgroupname) {
RecordSet rs = new RecordSet();
RecordSet recordSet = new RecordSet();
String sqlInsert;
jobgroupname = Util.convertInput2DB4(jobgroupname);
jobactivityname = Util.convertInput2DB4(jobactivityname);
/* 获取jobgroupid 职务类别 */
String selSql = "select id from HrmJobGroups where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(jobgroupname))," + userlanguage + ")))='" + jobgroupname + "'";
if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) {
selSql = "select id from HrmJobGroups where ltrim(rtrim(convToMultiLang(ltrim(rtrim(jobgroupname))," + userlanguage + ")))='" + jobgroupname + "'";
}
int jobgroupid = getResultSetId(selSql);
if (jobgroupid == 0) {
if (jobgroupname.length() == 0) {
selSql = "select max(id) as id from HrmJobGroups";
jobgroupid = getResultSetId(selSql);
} else {
sqlInsert = "insert into HrmJobGroups (jobgroupname,jobgroupremark ," + DbFunctionUtil.getInsertColumnSql() + ") values('" + jobgroupname + "','" + jobgroupname + "'," + DbFunctionUtil.getInsertColumnValueSql(recordSet.getDBType(), 1) + ")"; // 创建
execSql(sqlInsert);
jobgroupid = getResultSetId(selSql);
}
}
/* 获取jobactivityid 职务 */
selSql = "select id from HrmJobActivities where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(jobactivityname))," + userlanguage + ")))='" + jobactivityname + "' and jobgroupid=" + jobgroupid;
if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) {
selSql = "select id from HrmJobActivities where ltrim(rtrim(convToMultiLang(ltrim(rtrim(jobactivityname))," + userlanguage + ")))='" + jobactivityname + "' and jobgroupid=" + jobgroupid;
}
int jobactivityid = getResultSetId(selSql);
if (jobactivityid == 0) {
sqlInsert = "insert into HrmJobActivities (jobactivityname,Jobactivitymark,jobgroupid ," + DbFunctionUtil.getInsertColumnSql() + ") values('" + jobactivityname + "','" + jobactivityname + "'," + jobgroupid + " ," + DbFunctionUtil.getInsertColumnValueSql(recordSet.getDBType(), 1) + ")"; // 创建
execSql(sqlInsert);
jobactivityid = getResultSetId(selSql);
}
/*获取岗位id*/
selSql = "select id from HrmJobTitles where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(jobtitlemark))," + userlanguage + ")))='" + jobtitlename + "' and jobactivityid=" + jobactivityid;
if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) {
selSql = "select id from HrmJobTitles where ltrim(rtrim(convToMultiLang(ltrim(rtrim(jobtitlemark))," + userlanguage + ")))='" + jobtitlename + "' and jobactivityid=" + jobactivityid;
}
int jobtitle = getResultSetId(selSql);
if (jobtitle == 0) {
String jobtitlecode = "";
try {
jobtitlecode = CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.JOBTITLES, jobtitlecode);
} catch (Exception e) {
new BaseBean().writeLog(e);
}
sqlInsert = "insert into HrmJobTitles (jobtitlename,Jobtitlemark,jobactivityid ," + DbFunctionUtil.getInsertColumnSql() + ", jobtitlecode) values('" + jobtitlename + "','" + jobtitlename + "'," + jobactivityid + " ," + DbFunctionUtil.getInsertColumnValueSql(recordSet.getDBType(), 1) + ", '" + jobtitlecode + "')"; // 创建
execSql(sqlInsert);
HrmTriggerUtil.generateJobtitlesPinyin(jobtitlename, null);
jobtitle = getResultSetId(selSql);
HrmFaceCheckManager.sync(jobtitle + "", HrmFaceCheckManager.getOptInsert(), "hrm_e9_import_getJobtitles", HrmFaceCheckManager.getOaJobtitle());
} else {
selSql = "select * from HrmJobTitles where id = '" + jobtitle + "' and jobactivityid = '" + jobactivityid + "' ";
recordSet.executeSql(selSql);
if (!recordSet.next()) {//查询这个名称已存在的岗位,对应的职务是否存在。如果对应职务的岗位不存在,则说明岗位对应的职务和职务类别有更新
sqlInsert = "update HrmJobTitles set jobactivityid = '" + jobactivityid + "'," + DbFunctionUtil.getUpdateSetSql(rs.getDBType(), 1) + " where id = '" + jobtitle + "' ";
rs.executeSql(sqlInsert);
}
}
return jobtitle;
}
public static boolean needCheckLicenseForUpdate(ResourceComInfo resourceComInfo, String hrmId, public static boolean needCheckLicenseForUpdate(ResourceComInfo resourceComInfo, String hrmId,
HrmResourceImportParam importParam) { HrmResourceImportParam importParam) {
@ -1840,7 +1600,7 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
* @param keyField * @param keyField
* @return * @return
*/ */
public int getManagerId(String hrmid, String keyFieldValue, String keyField) { public int getManagerId(String keyFieldValue, String keyField) {
int managerId = 0; int managerId = 0;
RecordSet recordSet = new RecordSet(); RecordSet recordSet = new RecordSet();
@ -2148,7 +1908,6 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
cerNum = recordSet.getString("certificate_num"); cerNum = recordSet.getString("certificate_num");
keyMap.put(recordSet.getString(keyField), recordSet.getInt("id")); keyMap.put(recordSet.getString(keyField), recordSet.getInt("id"));
// TODO // TODO
isADAccountMap.put(Util.null2String(recordSet.getString("id")), Util.null2String(recordSet.getString("isADAccount")));
String accounttype = recordSet.getString("account_type"); String accounttype = recordSet.getString("account_type");
if (!"1".equalsIgnoreCase(accounttype)) { if (!"1".equalsIgnoreCase(accounttype)) {
if (StringUtil.isNotNull(cerNum)) { if (StringUtil.isNotNull(cerNum)) {
@ -2217,13 +1976,13 @@ public class HrmResourceImportProcessServiceImpl extends Service implements HrmR
ImportLogService importLogService = ServiceUtil.getService(ImportLogServiceImpl.class, user); ImportLogService importLogService = ServiceUtil.getService(ImportLogServiceImpl.class, user);
String relatedName = ""; String relatedName = "";
switch (this.keyField) { switch (this.keyField) {
case "workcode": case "work_code":
relatedName = log.getWorkCode(); relatedName = log.getWorkCode();
break; break;
case "loginid": case "login_id":
relatedName = log.getLoginid(); relatedName = log.getLoginid();
break; break;
case "lastname": case "last_name":
relatedName = log.getLastname(); relatedName = log.getLastname();
break; break;
} }

Loading…
Cancel
Save