From 3ac7c2b9594dd764525e190b8112455ff1053125 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Wed, 12 Oct 2022 15:28:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=9A=E6=89=8D=E6=9E=97=E8=8A=B1=E5=90=8D?= =?UTF-8?q?=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/hrmresource/vo/HrmResourceVO.java | 7 +- .../service/impl/FieldDefinedServiceImpl.java | 1 - .../service/impl/HrmResourceServiceImpl.java | 13 +- .../service/impl/ImportCommonServiceImpl.java | 17 +- .../thread/OrganizationSyncEc.java | 35 +- .../util/relation/ResourceSyncUtil.java | 615 ++++++++++++++++++ 6 files changed, 662 insertions(+), 26 deletions(-) create mode 100644 src/com/engine/organization/util/relation/ResourceSyncUtil.java diff --git a/src/com/engine/organization/entity/hrmresource/vo/HrmResourceVO.java b/src/com/engine/organization/entity/hrmresource/vo/HrmResourceVO.java index 40bbce2a..251659cf 100644 --- a/src/com/engine/organization/entity/hrmresource/vo/HrmResourceVO.java +++ b/src/com/engine/organization/entity/hrmresource/vo/HrmResourceVO.java @@ -30,11 +30,8 @@ import lombok.NoArgsConstructor; sortway = " asc", primarykey = "id", operates = { - @OrganizationTableOperate(index = "0", text = "发消息"), - @OrganizationTableOperate(index = "1", text = "发送邮件"), - @OrganizationTableOperate(index = "1", text = "发送短信"), - @OrganizationTableOperate(index = "1", text = "新建日程"), - @OrganizationTableOperate(index = "1", text = "系统信息"), + @OrganizationTableOperate(index = "0", text = "查看"), + @OrganizationTableOperate(index = "1", text = "编辑") }, tableType = WeaTableType.CHECKBOX ) diff --git a/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java b/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java index 9f40e5f1..e8393256 100644 --- a/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java +++ b/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java @@ -536,7 +536,6 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ rightName = "PostField:All"; break; case "4": - //TODO 人员自定义按钮权限 rightName = "ResourceField:All"; break; default: diff --git a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java index 0add18a3..d0b68a53 100644 --- a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java +++ b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java @@ -18,7 +18,7 @@ import com.engine.organization.entity.hrmresource.bo.HrmRelationBO; import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam; import com.engine.organization.entity.hrmresource.param.HrmResourceSearchParam; import com.engine.organization.entity.hrmresource.po.HrmRelationPO; -import com.engine.organization.entity.hrmresource.vo.ScHrmResourceVO; +import com.engine.organization.entity.hrmresource.vo.HrmResourceVO; import com.engine.organization.entity.job.bo.JobBO; import com.engine.organization.entity.job.po.JobPO; import com.engine.organization.entity.searchtree.SearchTree; @@ -37,6 +37,7 @@ import com.engine.organization.mapper.scheme.SchemeMapper; import com.engine.organization.mapper.sequence.SequenceMapper; import com.engine.organization.service.ExtService; import com.engine.organization.service.HrmResourceService; +import com.engine.organization.util.HasRightUtil; import com.engine.organization.util.MenuBtn; import com.engine.organization.util.OrganizationAssert; import com.engine.organization.util.OrganizationFormItemUtil; @@ -97,6 +98,8 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic */ private static final String JCL_ORG_HRMEXT_DT1 = "JCL_ORG_HRMRESOURCEEXT_DT1"; + private static final String RIGHT_NAME = "Roster:All"; + private SchemeMapper getSchemeMapper() { return MapperProxyFactory.getProxy(SchemeMapper.class); } @@ -157,15 +160,13 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic @Override public Map listPage(HrmResourceSearchParam params) { - Map resultMap = new HashMap<>(); - OrganizationWeaTable table = new OrganizationWeaTable<>(user, ScHrmResourceVO.class); + OrganizationWeaTable table = new OrganizationWeaTable<>(user, HrmResourceVO.class); String sqlWhere = buildSqlWhere(params); table.setSqlwhere(sqlWhere); WeaResultMsg result = new WeaResultMsg(false); result.putAll(table.makeDataResult()); result.success(); - resultMap.putAll(result.getResultMap()); - return resultMap; + return new HashMap<>(result.getResultMap()); } @Override @@ -184,6 +185,8 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic @Override public Long saveBaseForm(Map params) { + HasRightUtil.hasRight(user, RIGHT_NAME, false); + return getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_HRM, params, "", null); } diff --git a/src/com/engine/organization/service/impl/ImportCommonServiceImpl.java b/src/com/engine/organization/service/impl/ImportCommonServiceImpl.java index d5e703f9..7bdbfdaa 100644 --- a/src/com/engine/organization/service/impl/ImportCommonServiceImpl.java +++ b/src/com/engine/organization/service/impl/ImportCommonServiceImpl.java @@ -22,6 +22,7 @@ import com.engine.organization.entity.jclimport.po.JclImportHistoryPO; import com.engine.organization.entity.jclimport.vo.JclImportHistoryDetailVO; import com.engine.organization.enums.LogModuleNameEnum; import com.engine.organization.enums.OperateTypeEnum; +import com.engine.organization.enums.OrgImportEnum; import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.department.DepartmentMapper; import com.engine.organization.mapper.extend.ExtMapper; @@ -42,7 +43,6 @@ import com.engine.organization.util.excel.ExcelUtil; import com.engine.organization.util.relation.EcHrmRelationUtil; import com.engine.organization.util.saveimport.hrmimport.HrmImportAdaptExcelE9; import com.engine.organization.util.saveimport.hrmimport.HrmImportProcessE9; -import com.engine.organization.enums.OrgImportEnum; import org.apache.commons.lang3.StringUtils; import org.apache.poi.hssf.usermodel.HSSFDateUtil; import org.apache.poi.xssf.usermodel.XSSFCell; @@ -226,11 +226,10 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ break; case "resource": Long importHistoryId = saveImportLog("resource", operateType); - List lsErrorInfo = new ArrayList<>(); HrmImportAdaptExcelE9 importAdapt = new HrmImportAdaptExcelE9(); FileUploadToPath fu = new FileUploadToPath(request); - List errorInfo = importAdapt.creatImportMap(fu); + List errorInfo = importAdapt.creatImportMap(fu); //如果读取数据和验证模板没有发生错误 if (errorInfo.isEmpty()) { @@ -242,12 +241,8 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ importProcess.processMap(hrMap); } else { - Map error; - for (int i = 0; i < errorInfo.size(); i++) { - error = new HashMap<>(); - error.put("message", Util.null2String(errorInfo.get(i))); - lsErrorInfo.add(error); - MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).insertHistoryDetail(JclImportHistoryDetailPO.builder().pid(importHistoryId).operateDetail(Util.null2String(errorInfo.get(i))).status("0").build()); + for (String s : errorInfo) { + MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).insertHistoryDetail(JclImportHistoryDetailPO.builder().pid(importHistoryId).operateDetail(Util.null2String(s)).status("0").build()); } } returnMap.put("pId", importHistoryId); @@ -504,7 +499,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ ConditionFactory conditionFactory = new ConditionFactory(user); //重复验证字段 - List statusOptions = new ArrayList(); + List statusOptions = new ArrayList<>(); statusOptions.add(new SearchConditionOption("workcode", SystemEnv.getHtmlLabelName(714, user.getLanguage()), true)); statusOptions.add(new SearchConditionOption("loginid", SystemEnv.getHtmlLabelName(412, user.getLanguage()))); statusOptions.add(new SearchConditionOption("lastname", SystemEnv.getHtmlLabelName(413, user.getLanguage()))); @@ -513,7 +508,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ itemList.add(searchConditionItem); //导入类型 - List statusOptions1 = new ArrayList(); + List statusOptions1 = new ArrayList<>(); statusOptions1.add(new SearchConditionOption("add", SystemEnv.getHtmlLabelName(611, user.getLanguage()), true)); statusOptions1.add(new SearchConditionOption("update", SystemEnv.getHtmlLabelName(17744, user.getLanguage()))); searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, 24863, "importType", statusOptions1); diff --git a/src/com/engine/organization/thread/OrganizationSyncEc.java b/src/com/engine/organization/thread/OrganizationSyncEc.java index db631845..070b4067 100644 --- a/src/com/engine/organization/thread/OrganizationSyncEc.java +++ b/src/com/engine/organization/thread/OrganizationSyncEc.java @@ -16,6 +16,7 @@ import com.engine.organization.mapper.job.JobMapper; import com.engine.organization.util.OrganizationAssert; import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.relation.EcHrmRelationUtil; +import com.engine.organization.util.relation.ResourceSyncUtil; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; import weaver.general.Util; @@ -33,10 +34,10 @@ import java.util.stream.Collectors; * @version: 1.0 */ public class OrganizationSyncEc { - private LogModuleNameEnum moduleName; - private OperateTypeEnum operateType; - private Map params; - private User user; + private final LogModuleNameEnum moduleName; + private final OperateTypeEnum operateType; + private final Map params; + private final User user; private JobPO oldJobPO; Map resultMap; private boolean throwException = true; @@ -88,6 +89,8 @@ public class OrganizationSyncEc { case JOB: refreshJob(); break; + case RESOURCE: + refreshResource(); default: break; } @@ -152,6 +155,30 @@ public class OrganizationSyncEc { } } + private void refreshResource(){ + switch (operateType) { + case ADD: + addResource(); + break; + case UPDATE: + break; + case CANCELED: + break; + default: + break; + } + } + + private void addResource() { + Map map = ResourceSyncUtil.addResource(user, params); + this.resultMap = map; + } + + private void updateResource() { + + } + + /** * 新增岗位 * diff --git a/src/com/engine/organization/util/relation/ResourceSyncUtil.java b/src/com/engine/organization/util/relation/ResourceSyncUtil.java new file mode 100644 index 00000000..e96b9e4f --- /dev/null +++ b/src/com/engine/organization/util/relation/ResourceSyncUtil.java @@ -0,0 +1,615 @@ +package com.engine.organization.util.relation; + +import com.api.doc.detail.util.DocDownloadCheckUtil; +import com.api.hrm.service.HrmResourceBaseService; +import com.api.hrm.util.ServiceUtil; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogOperateAuditType; +import com.engine.common.constant.BizLogOperateType; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.common.service.impl.HrmCommonServiceImpl; +import com.engine.common.util.LogUtil; +import com.engine.hrm.entity.RuleCodeType; +import com.engine.hrm.util.CodeRuleManager; +import com.engine.hrm.util.HrmWeakPasswordUtil; +import com.engine.hrm.util.face.HrmFaceCheckManager; +import com.engine.hrm.util.face.ValidateFieldManager; +import com.engine.hrm.util.face.bean.CheckItemBean; +import com.weaver.general.BaseBean; +import ln.LN; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.file.Prop; +import weaver.general.GCONST; +import weaver.general.PasswordUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.common.DbFunctionUtil; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.companyvirtual.DepartmentVirtualComInfo; +import weaver.hrm.finance.SalaryManager; +import weaver.hrm.passwordprotection.manager.HrmResourceManager; +import weaver.hrm.privacy.PrivacyComInfo; +import weaver.hrm.privacy.UserPrivacyComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.hrm.settings.ChgPasswdReminder; +import weaver.hrm.settings.RemindSettings; +import weaver.hrm.tools.HrmDateCheck; +import weaver.interfaces.hrm.HrmServiceManager; +import weaver.license.PluginUserCheck; +import weaver.rsa.security.RSA; +import weaver.rtx.OrganisationCom; +import weaver.rtx.OrganisationComRunnable; +import weaver.system.SysRemindWorkflow; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2022/10/11 + * @version: 1.0 + */ +public class ResourceSyncUtil { + private static final char separator = Util.getSeparator(); + private static final String today = DateUtil.getCurrentDate(); + + public static Map addResource(User user, Map params) { + + Map retmap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + boolean canEdit = HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user); + if (!canEdit) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(22620, user.getLanguage())); + return retmap; + } + String loginid = Util.null2String(params.get("loginid")); + String accounttype = Util.null2s(Util.fromScreen3(Util.null2String(params.get(("accounttype"))), user.getLanguage()), "0"); + if (accounttype.equals("1")) loginid = "";//次账号没有loginid + boolean canSave = false; + LN LN = new LN(); + int ckHrmnum = LN.CkHrmnum(); + if (loginid.length() > 0) { + if (ckHrmnum < 0) {//只有License检查人数小于规定人数,才能修改。防止客户直接修改数据库数据 + canSave = true; + } + } else { + canSave = true; + } + if (!canSave) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(84760, user.getLanguage())); + return retmap; + } + + + if (!loginid.equals("") && "0".equals(accounttype)) { + sql = "select count(1) from hrmresourceallview where loginid='" + loginid + "' "; + rs.executeSql(sql); + if (rs.next()) { + if (rs.getInt(1) > 0) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(15094, user.getLanguage())); + return retmap; + } + } + } + + String departmentid = Util.null2String(params.get("departmentid")); + String subcompanyid = departmentComInfo.getSubcompanyid1(departmentid); + if (!loginid.equals("") && !subcompanyid.equals("0") && new HrmResourceManager().noMore(subcompanyid)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(81926, user.getLanguage())); + return retmap; + } + + + ResourceComInfo ResourceComInfo = new ResourceComInfo(); + Map result = ResourceSyncUtil.addResourceBase(user, params); + + String addResourceBaseCode = result.get("status"); + if ("-1".equals(addResourceBaseCode)) { + retmap.put("status", "-1"); + retmap.put("message", result.get("message")); + return retmap; + } + + + int id = Util.getIntValue(result.get("id")); + String password = Util.null2String(params.get("password")); + //是否开启了RSA加密 + String openRSA = Util.null2String(Prop.getPropValue("openRSA", "isrsaopen")); + if ("1".equals(openRSA)) { + password = new RSA().decrypt(password); + } + ChgPasswdReminder reminder = new ChgPasswdReminder(); + RemindSettings settings = reminder.getRemindSettings(); + + //判断是否开启了【启用初始密码】 + String defaultPasswordEnable = Util.null2String(settings.getDefaultPasswordEnable()); + //【初始密码】 + String defaultPassword = Util.null2String(settings.getDefaultPassword()); + //如果管理员设置的密码为空。并且开启了【启用初始密码】,且初始密码不为空,则默认取初始密码作为密码 + if (password.equals("") && defaultPasswordEnable.equals("1") && !defaultPassword.equals("")) { + password = defaultPassword; + } + + //判断是否开启了【禁止弱密码保存】 + String weakPasswordDisable = Util.null2s(settings.getWeakPasswordDisable(), "0"); + if (weakPasswordDisable.equals("1")) { + if (password.equals("")) {//密码为空的情况 + } else { + //判断是否为弱密码 + HrmWeakPasswordUtil hrmWeakPasswordUtil = new HrmWeakPasswordUtil(); + if (hrmWeakPasswordUtil.isWeakPsd(password)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(515420, user.getLanguage())); + return retmap; + } + } + } + + int seclevel = Util.getIntValue(Util.null2String(params.get("seclevel")), 0); + if (id > 0) {//保存系统信息 + SimpleBizLogger logger = new SimpleBizLogger(); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_RSOURCE_CARD);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_RSOURCE_CARD_SYSTEM);//当前小类型 + bizLogContext.setOperateType(BizLogOperateType.ADD); + bizLogContext.setOperateAuditType(BizLogOperateAuditType.WARNING); + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from hrmresource where id=" + id; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("lastname");//当前targetName对应的列(对应日志中的对象名) + logger.before(bizLogContext);//写入操作前日志 + + String workstartdate = Util.null2String(params.get("workstartdate"));//参加工作日期 + String companystartdate = Util.null2String(params.get("companystartdate"));//入职日期 + String dsporder = Util.fromScreen3(Util.null2String(params.get("dsporder")), user.getLanguage()); + if (dsporder.length() == 0) dsporder = "" + id; + if (accounttype.equals("0")) { + + String encrptPassword = ""; + String salt = ""; + if (org.apache.commons.lang3.StringUtils.isNotBlank(password)) { + String[] encrypts = PasswordUtil.encrypt(password); + encrptPassword = encrypts[0]; + salt = encrypts[1]; + } + + sql = " update hrmresource set loginid='" + loginid + "', password='" + encrptPassword + "'," + + "seclevel=" + seclevel + ",dsporder=" + dsporder + + ",salt='" + salt + "',workstartdate='" + workstartdate + "',companystartdate='" + companystartdate + "' where id = " + id; + } else { + sql = " update hrmresource set seclevel=" + seclevel + ",dsporder=" + dsporder + + " ,workstartdate='" + workstartdate + "',companystartdate='" + companystartdate + "' where id = " + id; + } + updateWorkInfo(String.valueOf(id), user, params); + + rs.executeSql(sql); + + HrmFaceCheckManager.setUserPassowrd(id + "", password); + HrmFaceCheckManager.sync(id + "", HrmFaceCheckManager.getOptUpdate(), "HrmResourceAddService_saveSimple_update", HrmFaceCheckManager.getOaResource()); + + LogUtil.writeBizLog(logger.getBizLogContexts()); + } + + //同步RTX端的用户信息. + new OrganisationCom().checkUser(id); + new Thread(new OrganisationComRunnable("user", "add", "" + id)).start(); + ResourceComInfo.updateResourceInfoCache("" + id); + new PluginUserCheck().clearPluginUserCache("messager"); + //OA与第三方接口单条数据同步方法开始 + new HrmServiceManager().SynInstantHrmResource("" + id, "1"); + //OA与第三方接口单条数据同步方法结束 + //BBS集成相关 + String bbsLingUrl = new weaver.general.BaseBean().getPropValue(GCONST.getConfigFile(), "ecologybbs.linkUrl"); + if (!password.equals("0")) { + if (!bbsLingUrl.equals("")) { + new Thread(new weaver.bbs.BBSRunnable(loginid, password)).start(); + } + } + + retmap.put("status", "1"); + } catch (Exception e) { + new BaseBean().writeLog("保存新建人员simple错误:" + e); + retmap.put("status", "-1"); + retmap.put("message", "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(22620, weaver.general.ThreadVarLanguage.getLang()) + ""); + } + return retmap; + } + + private static Map addResourceBase(User user, Map params) { + Map retmap = new HashMap<>(); + try { + retmap.put("id", "0"); + RecordSet rs = new RecordSet(); + DepartmentComInfo DepartmentComInfo = new DepartmentComInfo(); + ResourceComInfo ResourceComInfo = new ResourceComInfo(); + SalaryManager SalaryManager = new SalaryManager(); + ChgPasswdReminder reminder = new ChgPasswdReminder(); + RemindSettings settings = reminder.getRemindSettings(); + SysRemindWorkflow SysRemindWorkflow = new SysRemindWorkflow(); + DepartmentVirtualComInfo DepartmentVirtualComInfo = new DepartmentVirtualComInfo(); + + StringBuilder para; + String cmd = Util.null2String(params.get("cmd")); + String id = Util.null2String(params.get("id")); + String workcode = Util.fromScreen3(Util.null2String(params.get("workcode")), user.getLanguage()); + String lastname = Util.fromScreen3(Util.null2String(params.get("lastname")), user.getLanguage()).trim(); + String sex = Util.fromScreen3(Util.null2String(params.get("sex")), user.getLanguage()); + String resourceimageid = Util.null2String(params.get("resourceimageid")); + if (resourceimageid.length() > 0) { + resourceimageid = "" + DocDownloadCheckUtil.getDownloadfileidstr(resourceimageid); + } + String departmentid = Util.fromScreen3(Util.null2String(params.get("departmentid")), user.getLanguage()); + String costcenterid = Util.fromScreen3(Util.null2String(params.get("costcenterid")), user.getLanguage()); + String jobtitle = Util.fromScreen3(Util.null2String(params.get("jobtitle")), user.getLanguage()); + String joblevel = Util.fromScreen3(Util.null2String(params.get("joblevel")), user.getLanguage()); + String jobactivitydesc = Util.fromScreen3(Util.null2String(params.get("jobactivitydesc")), user.getLanguage()); + String managerid = Util.fromScreen3(Util.null2String(params.get("managerid")), user.getLanguage()); + String assistantid = Util.fromScreen3(Util.null2String(params.get("assistantid")), user.getLanguage()); + String status = Util.fromScreen3(Util.null2String(params.get("status")), user.getLanguage()); + String locationid = Util.fromScreen3(Util.null2String(params.get("locationid")), user.getLanguage()); + String workroom = Util.fromScreen3(Util.null2String(params.get("workroom")), user.getLanguage()); + String telephone = Util.fromScreen3(Util.null2String(params.get("telephone")), user.getLanguage()); + String mobile = Util.fromScreen3(Util.null2String(params.get("mobile")), user.getLanguage()); + String mobileshowtype = Util.fromScreen3(Util.null2String(params.get("mobileshowtype")), user.getLanguage()); + String mobilecall = Util.fromScreen3(Util.null2String(params.get("mobilecall")), user.getLanguage()); + String fax = Util.fromScreen3(Util.null2String(params.get("fax")), user.getLanguage()); + String jobcall = Util.fromScreen3(Util.null2String(params.get("jobcall")), user.getLanguage()); + String email = Util.fromScreen3(Util.null2String(params.get("email")), user.getLanguage()); + String dsporder = Util.fromScreen3(Util.null2String(params.get("dsporder")), user.getLanguage()); + String accounttype = Util.fromScreen3(Util.null2String(params.get("accounttype")), user.getLanguage()); + String systemlanguage = Util.null2String(params.get("systemlanguage")); + if (systemlanguage.equals("") || systemlanguage.equals("0")) systemlanguage = "7"; + String belongto = Util.fromScreen3(Util.null2String(params.get("belongto")), user.getLanguage()); + //应聘人员id + String rcid = Util.null2String(params.get("rcId")); + + CheckItemBean mobileBean = new CheckItemBean("mobile", mobile, id); + ValidateFieldManager.validate(mobileBean); + if (!mobileBean.isPass()) { + retmap.put("status", "-1"); + retmap.put("message", mobileBean.getCheckMsg()); + return retmap; + } + + CheckItemBean telephoneBean = new CheckItemBean("telephone", telephone, id); + ValidateFieldManager.validate(telephoneBean); + if (!telephoneBean.isPass()) { + retmap.put("status", "-1"); + retmap.put("message", telephoneBean.getCheckMsg()); + return retmap; + } + + + if (dsporder.length() == 0) dsporder = id; + if (accounttype.equals("0")) { + belongto = "-1"; + } + String departmentvirtualids = Util.null2String(params.get("departmentvirtualids"));//虚拟部门id; + + //Td9325,解决多账号次账号没有登陆Id在浏览框组织结构中无法显示的问题。 + boolean falg = false; + String loginid = ""; + if (accounttype.equals("1")) { + rs.execute("select loginid from HrmResource where id =" + belongto); + if (rs.next()) { + loginid = rs.getString("loginid"); + } + if (!loginid.equals("")) { + String maxidsql = "select max(id) as id from HrmResource where loginid like '" + loginid + "%'"; + rs.execute(maxidsql); + if (rs.next()) { + loginid = loginid + (rs.getInt("id") + 1); + falg = true; + } + } + } + rs.executeProc("HrmResourceMaxId_Get", ""); + rs.next(); + id = "" + rs.getInt(1); + if (!"".equals(rcid)) { + id = rcid; + } + SimpleBizLogger logger = new SimpleBizLogger(); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_RSOURCE_CARD);//所属大类型 + bizLogContext.setBelongTypeTargetName(SystemEnv.getHtmlLabelName(1361, user.getLanguage())); + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_RSOURCE_CARD_BASE);//当前小类型 + bizLogContext.setOperateType(BizLogOperateType.ADD); + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String cusFieldNames = ServiceUtil.getCusFieldNames("HrmCustomFieldByInfoType", -1, "b"); + String mainSql = "select a.*" + (cusFieldNames.length() > 0 ? "," + cusFieldNames : "") + " from hrmresource a left join cus_fielddata b on a.id=b.id and b.scope='HrmCustomFieldByInfoType' and b.scopeid=-1 where a.id=" + id; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("lastname");//当前targetName对应的列(对应日志中的对象名) + logger.before(bizLogContext);//写入操作前日志 + + String sql = "select managerstr, seclevel from HrmResource where id = " + Util.getIntValue(managerid); + rs.execute(sql); + String managerstr = ""; + while (rs.next()) { + String tmp_managerstr = rs.getString("managerstr"); + //处理managerstr 不以逗号开始或者结束的情况 形如 managerstr:8 begin + if (!tmp_managerstr.startsWith(",")) tmp_managerstr = "," + tmp_managerstr; + if (!tmp_managerstr.endsWith(",")) tmp_managerstr = tmp_managerstr + ","; + //处理managerstr 不以逗号开始或者结束的情况 形如 managerstr:8 end + managerstr += tmp_managerstr; + managerstr = "," + managerid + managerstr; + managerstr = managerstr.endsWith(",") ? managerstr : (managerstr + ","); + } + + String subcmpanyid1 = DepartmentComInfo.getSubcompanyid1(departmentid); + RecordSetTrans rst = new RecordSetTrans(); + rst.setAutoCommit(false); + try { + if (resourceimageid.length() == 0) resourceimageid = "null"; + if (costcenterid.length() == 0) costcenterid = "null"; + if (managerid.length() == 0) managerid = "null"; + if (assistantid.length() == 0) assistantid = "null"; + if (accounttype.length() == 0) accounttype = "null"; + if (belongto.length() == 0) belongto = "null"; + if (jobcall.length() == 0) jobcall = "null"; + if (mobileshowtype.length() == 0) mobileshowtype = "null"; + if (rst.getDBType().equalsIgnoreCase("postgresql")) { + if (joblevel.length() == 0) joblevel = null; + if (dsporder.length() == 0) dsporder = null; + } + workcode = CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.USER, subcmpanyid1, departmentid, jobtitle, workcode); + para = new StringBuilder("" + id + separator + workcode + separator + lastname + separator + sex + separator + resourceimageid + separator + + departmentid + separator + costcenterid + separator + jobtitle + separator + joblevel + separator + jobactivitydesc + separator + + managerid + separator + assistantid + separator + status + separator + locationid + separator + workroom + separator + telephone + + separator + mobile + separator + mobilecall + separator + fax + separator + jobcall + separator + subcmpanyid1 + separator + managerstr + + separator + accounttype + separator + belongto + separator + systemlanguage + separator + email + separator + dsporder + separator + mobileshowtype); + + rst.executeProc("HrmResourceBasicInfo_Insert", para.toString()); + if (Util.null2String(locationid).length() > 0) { + rst.executeSql("update hrmresource set countryid=(select countryid from HrmLocations where id=" + locationid + ")," + + DbFunctionUtil.getInsertUpdateSetSql(rst.getDBType(), user.getUID()) + " where id=" + id); + } + String logidsql, quickSearchStr = new HrmCommonServiceImpl().generateQuickSearchStr(lastname); + if (falg) { + logidsql = "update HrmResource set loginid = ?, pinyinlastname = ?, ecology_pinyin_search = ? where id = ?"; + rst.executeUpdate(logidsql, loginid, quickSearchStr, quickSearchStr, id); + } else { + logidsql = "update HrmResource set pinyinlastname = ?, ecology_pinyin_search = ? where id = ?"; + rst.executeUpdate(logidsql, quickSearchStr, quickSearchStr, id); + } + rst.commit(); + } catch (Exception e) { + rst.rollback(); + e.printStackTrace(); + } + + boolean formdefined = false; + weaver.system.CusFormSettingComInfo CusFormSettingComInfo = new weaver.system.CusFormSettingComInfo(); + weaver.system.CusFormSetting CusFormSetting = CusFormSettingComInfo.getCusFormSetting("hrm", "HrmResourceBase"); + if (CusFormSetting != null) { + if (CusFormSetting.getStatus() == 2) { + //自定义布局页面 + formdefined = true; + } + } + int userid = user.getUID(); + String userpara = "" + userid + separator + today; + para = new StringBuilder("" + id); + for (int i = 0; i < 5; i++) { + int idx = i; + if (formdefined) idx++; + String datefield = Util.null2String(params.get("datefield" + idx)); + String numberfield = "" + Util.getDoubleValue(Util.null2String(params.get("numberfield" + idx)), 0); + String textfield = Util.null2String(params.get("textfield" + idx)); + String tinyintfield = "" + Util.getIntValue(Util.null2String(params.get("tinyintfield" + idx)), 0); + para.append(separator).append(datefield).append(separator).append(numberfield).append(separator).append(textfield).append(separator).append(tinyintfield); + } + rs.executeProc("HrmResourceDefine_Update", para.toString()); + rs.executeProc("HrmResource_CreateInfo", "" + id + separator + userpara + separator + userpara); + + //421944 用户自定义隐私设置 + + UserPrivacyComInfo upc = new UserPrivacyComInfo(); + PrivacyComInfo pc = new PrivacyComInfo(); + Map mapShowSets = pc.getMapShowSets(); + String insertSql; + rs = new RecordSet(); + try { + String deletePriSql = " delete from userprivacysetting where userid= '" + id + "'"; + rs.execute(deletePriSql); + for (Map.Entry me : mapShowSets.entrySet()) { + String fieldName = me.getKey(); + String fieldVal = Util.null2String(mapShowSets.get(fieldName)); + if (fieldVal.equals("1")) { + String tmpPK = id + "__" + fieldName; + String tmpPvalue = Util.null2String(params.get(fieldName + "showtype")); + insertSql = "insert into userprivacysetting (combinedid,userid,ptype,pvalue) values('" + tmpPK + "','" + id + "','" + fieldName + "','" + tmpPvalue + "')"; + rs.execute(insertSql); + } + } + upc.removeUserPrivacyCache(); + } catch (Exception e) { + e.printStackTrace(); + } + + + // 改为只进行该人缓存信息的添加 + ResourceComInfo.addResourceInfoCache(id); + SalaryManager.initResourceSalary(id); + + para = new StringBuilder("" + id + separator + managerid + separator + departmentid + separator + subcmpanyid1 + separator + "0" + separator + managerstr); + rs.executeProc("HrmResource_Trigger_Insert", para.toString()); + + String sql_1 = ("insert into HrmInfoStatus (itemid,hrmid) values(1," + id + ")"); + rs.execute(sql_1); + String sql_2 = ("insert into HrmInfoStatus (itemid,hrmid) values(2," + id + ")"); + rs.execute(sql_2); + String sql_3 = ("insert into HrmInfoStatus (itemid,hrmid) values(3," + id + ")"); + rs.execute(sql_3); + String sql_10 = ("insert into HrmInfoStatus (itemid,hrmid) values(10," + id + ")"); + rs.execute(sql_10); + + String CurrentUser = "" + user.getUID(); + String CurrentUserName = "" + user.getUsername(); + String SWFAccepter; + String SWFTitle; + String SWFRemark; + String SWFSubmiter; + String Subject; + Subject = SystemEnv.getHtmlLabelName(15670, user.getLanguage()); + Subject += ":" + lastname; + + //modifier by lvyi 2013-12-31 + if (settings.getEntervalid().equals("1")) {//入职提醒 + String thesql = "select hrmids from HrmInfoMaintenance where id<4 or id = 10"; + rs.execute(thesql); + StringBuilder members = new StringBuilder(); + while (rs.next()) { + String hrmid_tmp = Util.null2String(rs.getString("hrmids"));//TD9392 + if (hrmid_tmp.length() != 0) { + members.append(",").append(rs.getString("hrmids")); + } + } + if (!members.toString().equals("")) { + members = new StringBuilder(members.substring(1)); + members = new StringBuilder(new HrmResourceBaseService().duplicateRemoval(members.toString(), user.getUID() + "")); + SWFAccepter = members.toString(); + SWFTitle = SystemEnv.getHtmlLabelName(15670, user.getLanguage()); + SWFTitle += ":" + lastname; + SWFTitle += "-" + CurrentUserName; + SWFTitle += "-" + today; + SWFRemark = "" + Util.fromScreen2(Subject, user.getLanguage()) + ""; + SWFSubmiter = CurrentUser; + SysRemindWorkflow.setPrjSysRemind(SWFTitle, 0, Util.getIntValue(SWFSubmiter), SWFAccepter, SWFRemark); + } + } + + //CustomFieldTreeManager.editCustomDataE9Add("HrmCustomFieldByInfoType", -1, fu, Util.getIntValue(id, 0)); + //应聘人员的个人信息18条 + if (!"".equals(rcid)) { + sql = "select * from HrmCareerApply where id = ?"; + rs.executeQuery(sql, id); + if (rs.next()) { + String birthday = Util.null2String(rs.getString("birthday")); + String folk = Util.null2String(rs.getString("folk")); + String nativeplace = Util.null2String(rs.getString("nativeplace")); + String regresidentplace = Util.null2String(rs.getString("regresidentplace")); + + String certificatenum = Util.null2String(rs.getString("certificatenum")); + String maritalstatus = Util.null2String(rs.getString("maritalstatus")); + String policy = Util.null2String(rs.getString("policy")); + String bememberdate = Util.null2String(rs.getString("bememberdate")); + + String bepartydate = Util.null2String(rs.getString("bepartydate")); + String islabouunion = Util.null2String(rs.getString("islabouunion")); + String educationlevel = Util.null2String(rs.getString("educationlevel")); + String degree = Util.null2String(rs.getString("degree")); + + String healthinfo = Util.null2String(rs.getString("healthinfo")); + + String height = Util.null2String(rs.getString("height")); + if (height.contains(".")) height = height.substring(0, height.indexOf(".")); + String weight = Util.null2String(rs.getString("weight")); + if (weight.contains(".")) weight = weight.substring(0, weight.indexOf(".")); + + String residentplace = Util.null2String(rs.getString("residentplace")); + String homeaddress = Util.null2String(rs.getString("homeaddress")); + String tempresidentnumber = Util.null2String(rs.getString("tempresidentnumber")); + + para = new StringBuilder("" + id + separator + birthday + separator + folk + separator + nativeplace + separator + regresidentplace + separator + maritalstatus + separator + policy + separator + bememberdate + separator + bepartydate + separator + islabouunion + separator + educationlevel + separator + degree + separator + healthinfo + separator + height + separator + weight + separator + residentplace + separator + homeaddress + separator + tempresidentnumber + separator + certificatenum); + RecordSet rs1 = new RecordSet(); + rs1.executeProc("HrmResourcePersonalInfo_Insert", para.toString()); + } + } + //更新虚拟组织部门id + if (departmentvirtualids.length() > 0) { + //保存前先删除需要删除的数据,因为有managerid 所以不能全部删除再保存 + sql = "delete from hrmresourcevirtual where resourceid=" + id + " and departmentid not in (" + departmentvirtualids + ")"; + rs.execute(sql); + + String[] departmentvirtualid = departmentvirtualids.split(","); + for (String s : departmentvirtualid) { + rs.execute(" select count(*) from HrmResourceVirtual where departmentid ='" + s + "' and resourceid = " + id); + if (rs.next()) { + //如果已存在 无需处理 + if (rs.getInt(1) > 0) continue; + } + + //写入 + int tmpid = 0; + rs.execute("select max(id) from HrmResourceVirtual "); + if (rs.next()) { + tmpid = rs.getInt(1) + 1; + } + String subcompanyid = DepartmentVirtualComInfo.getSubcompanyid1(s); + sql = " insert into HrmResourceVirtual (id,resourceid,subcompanyid,departmentid ) " + + " values (" + tmpid + "," + id + "," + subcompanyid + "," + s + ")"; + rs.execute(sql); + } + } + + LogUtil.writeBizLog(logger.getBizLogContexts()); + + HrmFaceCheckManager.sync(id, HrmFaceCheckManager.getOptInsert(), "hrm_e9_HrmResourceBaseService_addResourceBase", HrmFaceCheckManager.getOaResource()); + //同步RTX端的用户信息. + new OrganisationCom().checkUser(Util.getIntValue(id)); + new Thread(new OrganisationComRunnable("user", "add", "" + id)).start(); + ResourceComInfo.updateResourceInfoCache("" + id); + new PluginUserCheck().clearPluginUserCache("messager"); + //OA与第三方接口单条数据同步方法开始 + new HrmServiceManager().SynInstantHrmResource("" + id, "1"); + //OA与第三方接口单条数据同步方法结束 + + //新增人员实时同步到CoreMail邮件系统 + //CoreMailAPI.synUser(id); + if (cmd.equals("SaveAndNew")) { + retmap.put("status", "1"); + } else if (cmd.equals("SaveAndNext")) { + retmap.put("status", "2"); + } else { + retmap.put("status", "3"); + } + retmap.put("id", id); + } catch (Exception e) { + new BaseBean().writeLog("新建人员基本信息错误:" + e); + retmap.put("status", "-1"); + } + return retmap; + } + + private static void updateWorkInfo(String id, User user, Map params) { + try { + RecordSet rs = new RecordSet(); + String sql = ""; + String companystartdate = Util.fromScreen3(Util.null2String(params.get("companystartdate")), user.getLanguage()); + String workstartdate = Util.fromScreen3(Util.null2String(params.get("workstartdate")), user.getLanguage()); + + List lsParams = new ArrayList<>(); + lsParams.add(companystartdate.length() == 0 ? null : companystartdate); + lsParams.add(workstartdate.length() == 0 ? null : workstartdate); + lsParams.add(id); + sql = " update hrmresource set companystartdate=?,workstartdate=? where id=?"; + rs.executeUpdate(sql, lsParams); + HrmDateCheck hrmDateCheck = new HrmDateCheck(); + hrmDateCheck.calWorkInfo(id); + } catch (Exception e) { + new BaseBean().writeLog(e); + } + } +}