乐趣区

关于java:实习笔记-主数据更新主数据更新

奴才表信息的更新

1. 代码原理剖析:

子表对象作为更新主表信息的参数进行传递,主表外面须要被子表更新的字段进行更新。

public int updMain(int userId, EmpKeyinfo empKeyinfo, EmpCertinfo certinfo, EmpAppinfo appinfo,EmpContract contract, EmpBank bank, EmpEducation education, EmpContact contact, EmpPayinfo empPayinfo,EmpWealinfo wealinfo, EmpRecord empRecord, EmpSalarypro empSalarypro, EmpAddress empAddress,TalentInventory talentInventory){
        int i = 0;
        EmpInfo empInfo = null;
        if (empKeyinfo != null) {//            logger.info("!---------empKeyinfo: {}", empKeyinfo.toString());
            empInfo = new EmpInfo();
            empInfo.id = empKeyinfo.empId;
            empInfo.empEmpno = empKeyinfo.empkeyEmpno;
            empInfo.empEmpstatus = empKeyinfo.empkeyEmpstatus;
            empInfo.empEmpmode = empKeyinfo.empkeyEmpmode;
            empInfo.empEndate = empKeyinfo.empkeyEndate;
            empInfo.empSendate = empKeyinfo.empkeySendate;
            empInfo.empWorkday = empKeyinfo.empkeyWorkday;
            empInfo.empEzndate = empKeyinfo.empkeyEzndate;
            empInfo.empWorkday = empKeyinfo.empkeyWorkday;

            empInfo.empIsgps = empKeyinfo.empkeyIsgps;
            empInfo.empIscxemp = empKeyinfo.empkeyIscxemp;
            empInfo.empIstxemp = empKeyinfo.empkeyIstxemp;

            empInfo.empRcityid = empKeyinfo.empkeyRcityid;
            empInfo.empIsjoinh = empKeyinfo.empkeyIsjoinh;
            empInfo.empCuplevel = empKeyinfo.empkeyCuplevel;
            empInfo.empEnglevel = empKeyinfo.empkeyEnglevel;
            empInfo.empAnamnesis = empKeyinfo.empkeyAnamnesis;

            empInfo.empQutype = empKeyinfo.empkeyQutype;
            empInfo.empQuid = empKeyinfo.empkeyQuid;
            empInfo.empQuadre = empKeyinfo.empkeyQuadre;
            empInfo.empQudate = empKeyinfo.empkeyQudate;

            empInfo.empHrbp = empKeyinfo.empkeyHrbp;
            empInfo.empHzdjr = empKeyinfo.empkeyHzdjr;
            empInfo.empCpubt = empKeyinfo.empkeyCpubt;
        }
        if (certinfo != null) {if ("1".equals(certinfo.empcerIsadmid)) {//                logger.info("!---------certinfo: {}", certinfo.toString());
                empInfo = new EmpInfo();
                empInfo.id = certinfo.empId;
                empInfo.empPaptype = certinfo.empcerType;
                empInfo.empPopcode = certinfo.empcerNumber;
            }
        }

        if (appinfo != null) {if ("01major".equals(appinfo.empappZjpost)) {//                logger.info("!---------appinfo: {}", appinfo.toString());
                empInfo = new EmpInfo();
                empInfo.id = appinfo.empId;
                empInfo.empZjpost = appinfo.empappZjpost;
                empInfo.empPanel = appinfo.empappPanel;

                empInfo.empUnitid = appinfo.empappUnitid;
                empInfo.empLegalid = appinfo.empappLegalid;
                empInfo.empDeptid = appinfo.empappDeptid;
                empInfo.empPostid = appinfo.empappPostid;

                empInfo.empCotcid = appinfo.empappCotcid;
                empInfo.empCotcratio = appinfo.empappCotcratio;

                empInfo.empZpid = appinfo.empappZpid;
                empInfo.empTeacher = appinfo.empappTeacher;
                empInfo.empEmpcity = appinfo.empappEmpcity;
                empInfo.empWkcity = appinfo.empappWkcity;

                empInfo.empYddate = appinfo.empappYddate;
                empInfo.empYdtype = appinfo.empappYdtype;
                empInfo.empOpreason = appinfo.empappOpreason;

                //2021-1-6
                empInfo.empRole = appinfo.empappRole;
            }
        }
        if (contract != null) {//            logger.info("!---------contract: {}", contract.toString());
            empInfo = new EmpInfo();
            empInfo.id = contract.empId;
            empInfo.empWcityid = contract.empconWcityid;
            empInfo.empCategory = contract.empconCategory;
            empInfo.empCstype = contract.empconCstype;

            empInfo.empDuration = contract.empconDuration;
            empInfo.empSdate = contract.empconSdate;
            empInfo.empYedate = contract.empconYedate;
            empInfo.empEdate = contract.empconEdate;
            empInfo.empQsdate = contract.empconQsdate;
            empInfo.empQdcs = contract.empconQdcs;

            empInfo.empBmxy = contract.empconBmxy;
            empInfo.empWttype = contract.empconWttype;

            empInfo.empIsputoff = contract.empconIsputoff;
            empInfo.empYjedate = contract.empconYjedate;

            empInfo.empDuedate = contract.empconDuedate;
            empInfo.empTrialperiod = contract.empconTrialperiod;
            empInfo.empSydate = contract.empconPsdate;
            empInfo.empPedate = contract.empconPedate;
            empInfo.empPduedate = contract.empconPduedate;

            empInfo.empLegalid = contract.empconFlstid;
        }
        if (bank != null) {if ("01salary".equals(bank.empbkAcctype)) {//                logger.info("!---------bank: {}", bank.toString());
                empInfo = new EmpInfo();
                empInfo.id = bank.empId;
                empInfo.empAcctype = bank.empbkAcctype;
                empInfo.empNameid = bank.empbkNameid;
                empInfo.empDeposit = bank.empbkDeposit;
                empInfo.empAccount = bank.empbkAccount;
            }
        }
        if (education != null) {//            logger.info("!---------education: {}", education.toString());
            empInfo = new EmpInfo();
            empInfo.id = education.empId;
            if ("1".equals(education.empedcIshighest)) {
                empInfo.empEsdateh = education.empedcEsdate;
                empInfo.empBydateh = education.empedcBydate;
                empInfo.empBackgdh = education.empedcBackgd;
                empInfo.empDegreeh = education.empedcDegree;
                empInfo.empContidh = education.empedcContid;
                empInfo.empSchoolh = education.empedcSchool;
                empInfo.empSchooltypeh = education.empedcSchooltype;
                empInfo.empLearntypeh = education.empedcLearntype;
                empInfo.empFirstzyh = education.empedcFirstzy;
                empInfo.empSecondzyh = education.empedcSecondzy;
                empInfo.empIshighest = education.empedcIshighest;

            }
            if ("1".equals(education.empedcFirst)) {
                empInfo.empEsdate = education.empedcEsdate;
                empInfo.empBydate = education.empedcBydate;
                empInfo.empBackgd = education.empedcBackgd;
                empInfo.empDegree = education.empedcDegree;
                empInfo.empContid = education.empedcContid;
                empInfo.empSchool = education.empedcSchool;
                empInfo.empSchooltype = education.empedcSchooltype;
                empInfo.empLearntype = education.empedcLearntype;
                empInfo.empFirstzy = education.empedcFirstzy;
                empInfo.empSecondzy = education.empedcSecondzy;
                empInfo.empFirst = education.empedcFirst;
            }
        }
        if (contact != null) {//            logger.info("!---------contact: {}", contact.toString());
            empInfo = new EmpInfo();
            empInfo.id = contact.empId;
            empInfo.empMobile = contact.empctaMobile;
            empInfo.empPersmail = contact.empctaPersmail;
            empInfo.empCompmail = contact.empctaCompmail;
            empInfo.empEmycontact = contact.empctaEmycontact;
            empInfo.empEmyrelation = contact.empctaEmyrelation;
            empInfo.empEmyphone = contact.empctaEmyphone;
            empInfo.empEmyaddr = contact.empctaEmyaddr;
        }

        if (empPayinfo != null) {//            logger.info("!---------empPayinfo: {}", empPayinfo.toString());
            empInfo = new EmpInfo();
            empInfo.id = empPayinfo.empId;
            empInfo.empCity = empPayinfo.emppayCity;
            empInfo.empCompany = empPayinfo.emppayCompany;
            empInfo.empSalaryset = empPayinfo.emppaySalaryset;
            empInfo.empCurrency = empPayinfo.emppayCurrency;
            empInfo.empPayno = empPayinfo.emppayPayno;
            empInfo.empTraffic = empPayinfo.emppayTraffic;
            empInfo.empCommun = empPayinfo.emppayCommun;
            empInfo.empIscalculate = empPayinfo.emppayIscalculate;
            empInfo.empWork = empPayinfo.emppayWork;
        }
        if (wealinfo != null) {//            logger.info("!---------wealinfo: {}", wealinfo.toString());
            empInfo = new EmpInfo();
            empInfo.id = wealinfo.empId;
            empInfo.empSocial = wealinfo.empwiSocial;
            empInfo.empSocialtime = wealinfo.empwiSocialtime;
            empInfo.empSocialcity = wealinfo.empwiSocialcity;
            empInfo.empAccumla = wealinfo.empwiAccumla;
            empInfo.empSocialsup = wealinfo.empwiSocialsup;
            empInfo.empSocialnum = wealinfo.empwiSocialnum;
            empInfo.empBsaehouse = wealinfo.empwiBsaehouse;

            empInfo.empBusisafe = wealinfo.empwiBusisafe;
            empInfo.empSafetime = wealinfo.empwiSafetime;
            empInfo.empSafetype = wealinfo.empwiSafetype;
            empInfo.empBusipro = wealinfo.empwiBusipro;

            empInfo.empWelfplat = wealinfo.empwiWelfplat;
            empInfo.empWelfpro = wealinfo.empwiWelfpro;
        }

        if (empAddress != null) {//            logger.info("!---------empAddress: {}", empAddress.toString());
            if ("02register".equals(empAddress.empaddType)) {empInfo = new EmpInfo();
                empInfo.id = empAddress.empId;
                empInfo.empNatid = empAddress.empaddNatid;
                empInfo.empPcityid = empAddress.empaddPcityid;
                empInfo.empCityid = empAddress.empaddCityid;
                empInfo.empStreet = empAddress.empaddStreet;
                empInfo.empFulladdr = empAddress.empaddFulladdr;
            } else if("03currentadr".equals(empAddress.empaddType)){empInfo = new EmpInfo();
                empInfo.id = empAddress.empId;
                empInfo.empLivecy = empAddress.empaddNatid;
                empInfo.empLivepro = empAddress.empaddPcityid;
                empInfo.empLivecity = empAddress.empaddCityid;
                empInfo.empLivestr = empAddress.empaddStreet;
                empInfo.empLiveaddr = empAddress.empaddFulladdr;
            }
        }

        // 人才盘点信息
        if (talentInventory != null) {//            logger.info("!---------talentInventory: {}", talentInventory.toString());
            empInfo = new EmpInfo();
            empInfo.id = talentInventory.empId;
            empInfo.empJxresult = talentInventory.talentJxresult;
            empInfo.empQlresult = talentInventory.talentQlresult;
            empInfo.empSudoku = talentInventory.talentSudoku;
            empInfo.empTaedate = talentInventory.talentEdate;
        }

        if (empRecord != null && empRecord != null) {if ("03head".equalsIgnoreCase(empRecord.emprecType)) {//                logger.info("!---------empRecord: {}", empRecord.toString());

                empInfo = new EmpInfo();
                empInfo.id = empRecord.empId;
                empInfo.empHead = empRecord.emprecHead; // 只更新员工头像
            }
        }

        if (empSalarypro != null && StringUtils.isNotBlank(empSalarypro.empspSalarypro)) {empInfo = new EmpInfo();
            empInfo.id = empSalarypro.empId;
//            logger.info("!---------empSalarypro: {}", empSalarypro.toString());
            // 判断值是否为空
            List<PaysSalyman> paysSalymen = paysSalymanService.getByIds(Integer.valueOf(empSalarypro.companyId),
                    PubConstants.C_LANGCN, empSalarypro.empspSalarypro, false);
            if ("PI0032".equals(paysSalymen.get(0).salProcode)) {empInfo.empMongzbz = empSalarypro.empspSum;} else if ("PI0035".equals(paysSalymen.get(0).salProcode)) {empInfo.empMonjxgz = empSalarypro.empspSum;} else if ("PI0040".equals(paysSalymen.get(0).salProcode)) {empInfo.empMonjbgz = empSalarypro.empspSum;} else if ("PI0045".equals(paysSalymen.get(0).salProcode)) {empInfo.empDaygzbz = empSalarypro.empspSum;} else if ("PI0049".equals(paysSalymen.get(0).salProcode)) {empInfo.empTranstandard = empSalarypro.empspSum;} else if ("PI0055".equals(paysSalymen.get(0).salProcode)) {empInfo.empTxjt = empSalarypro.empspSum;} else if ("PI0074".equals(paysSalymen.get(0).salProcode)) {empInfo.empHomecost = empSalarypro.empspSum;}
        }

        if (empInfo != null) {empInfo.updateTime = PubFuns.getCurrentTime();
            empInfo.updateBy = String.valueOf(userId);

//            logger.info("!---------upd empinfo: {}", empInfo.toString());
            if (StringUtils.isBlank(empInfo.id)) {logger.error("更新员工主信息谬误: 员工 id 为空");
            } else {i = empInfoMapper.updateByPrimaryKeySelective(empInfo);
                try {
                    // 推送 OA 主数据
                    EmpInfo empInfoN = empInfoMapper.selectByPrimaryKey(empInfo.id);
                    if (empInfoN != null) {List<EmpInfo> list = new ArrayList<EmpInfo>();
                        list.add(empInfoN);
                        pushEmpMdSynchMsg(list, PubConstants.CS_DEFAULTCOMP, "upd", PubConstants.C_LANGCN);
                    }
                } catch (Exception e) {logger.error("推送员工主信息更新谬误:" + e.getMessage(), e);
                }
            }
        }

        return i;

    }

2. 办法条件的调用卡控

EmpContract 子表中的信息须要更新主表中绝对应的字段,依据更新主信息的办法原理,须要把 EmpContract 作为参数进行传递,同时还须要落位到对应的数据元素,因而要卡控落位和数据的传递,本办法中用 userId 对数据的落位进行了卡控。

非凡解决:

进行了更新的数据要用更新标记 updObj.mdupdFlg = “1”; 进行标记。

/**
     * 更新主数据
     */
    private void updMain(int userId, EmpContract objInfo) {if (TsPubFuns.getCurrentDateEnd().compareToIgnoreCase(objInfo.empconSdate) >= 0) {
            empInfoService.updMain(userId, 1000, null, null, null, null, null, null, null,
                    null, null, objInfo,null,null,null, null, null, null, null);
            updMdupdFlg(objInfo.id);
        }
    }

    // 跟新信息标记
    public void updMdupdFlg(String id) {EmpContract updObj = new EmpContract();
        updObj.id = id;
        updObj.mdupdFlg = "1";
        empContractMapper.updateByPrimaryKeySelective(updObj);
    }

    public List<EmpContract> getNoUpdMDList() {Example example = new Example(EmpContract.class);
        Example.Criteria criteria =example.createCriteria();
        criteria.andEqualTo("deleteFlag", "0");
        criteria.andEqualTo("mdupdFlg", "0");
        criteria.andLessThanOrEqualTo("empctaSdate", PubFuns.getCurrentDate());
        criteria.andGreaterThanOrEqualTo("empctaEdate", PubFuns.getCurrentDate());
        List<EmpContract> objList = empContractMapper.selectByExample(example);
        return objList;
    }
    public List<EmpContract> getValidByObj(int companyId, String language, EmpContract empContract, Boolean isDis){List<EmpContract> list=empContractMapper.selPageByEmpContract(empContract);
        return getDisList(companyId, language, list, isDis);
    }
//        EmpContract   员工合同信息
        if (empContract != null) {//            logger.info("!---------empContract: {}", empContract.toString());
            empInfo = new EmpInfo();
            empInfo.id = empContract.empId;
            empInfo.ncid = empContract.ncid;

3. 更新主数据主动工作的编写

package com.hrocloud.znjs.orgemp.autotask;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.hrocloud.common.constant.PubConstants;
import com.hrocloud.znjs.pub.api.UserInfoService;
import com.hrocloud.znjs.pub.model.UserInfo;
import com.hrocloud.znjs.baseauth.api.AuthPostService;
import com.hrocloud.znjs.baseauth.model.AuthPost;
import com.hrocloud.znjs.orgemp.api.EmpAddressService;
import com.hrocloud.znjs.orgemp.api.EmpAppinfoService;
import com.hrocloud.znjs.orgemp.api.EmpBankService;
import com.hrocloud.znjs.orgemp.api.EmpCertinfoService;
import com.hrocloud.znjs.orgemp.api.EmpContactService;
import com.hrocloud.znjs.orgemp.api.EmpContractService;
import com.hrocloud.znjs.orgemp.api.EmpInfoService;
import com.hrocloud.znjs.orgemp.api.EmpKeyinfoService;
import com.hrocloud.znjs.orgemp.api.EmpPayinfoService;
import com.hrocloud.znjs.orgemp.api.EmpRecordService;
import com.hrocloud.znjs.orgemp.api.EmpSalaryproService;
import com.hrocloud.znjs.orgemp.api.EmpWealinfoService;
import com.hrocloud.znjs.orgemp.model.EmpAddress;
import com.hrocloud.znjs.orgemp.model.EmpAppinfo;
import com.hrocloud.znjs.orgemp.model.EmpBank;
import com.hrocloud.znjs.orgemp.model.EmpCertinfo;
import com.hrocloud.znjs.orgemp.model.EmpContact;
import com.hrocloud.znjs.orgemp.model.EmpContract;
import com.hrocloud.znjs.orgemp.model.EmpKeyinfo;
import com.hrocloud.znjs.orgemp.model.EmpPayinfo;
import com.hrocloud.znjs.orgemp.model.EmpRecord;
import com.hrocloud.znjs.orgemp.model.EmpSalarypro;
import com.hrocloud.znjs.orgemp.model.EmpWealinfo;

// 员工主数据更新:查问员工主信息相干连的子集,如果失效日期为以后日期,则更新对应主数据
public class EmpMainUpdateAutoTaskJob implements SimpleJob {private Logger logger = LoggerFactory.getLogger(EmpMainUpdateAutoTaskJob.class);

    @Resource
    private EmpKeyinfoService empKeyinfoService;

    @Resource
    private EmpInfoService empInfoService;

    @Resource
    private EmpAppinfoService empAppinfoService;

    @Resource
    private EmpCertinfoService empCertinfoService;

    @Resource
    private EmpBankService empBankService;

    @Resource
    private EmpContractService empContractService;

    @Resource
    private EmpSalaryproService empSalaryproService;

    @Resource
    private EmpRecordService empRecordService;
    @Resource
    private EmpAddressService empAddressService;
    @Resource
    private EmpContactService empContactService;
    @Resource
    private EmpWealinfoService empWealinfoService;
    @Resource
    private EmpPayinfoService empPayinfoService;
    @Resource
    private AuthPostService authPostService;
    @Resource
    private UserInfoService userInfoService;



    @Override
    public void execute(ShardingContext shardingContext) {logger.info("!---------- Run");
        List<EmpKeyinfo> updObjList = empKeyinfoService.getNoUpdMDList();
        for (EmpKeyinfo obj : updObjList) {
            try {
                empInfoService.updMain(PubConstants.C_SYSUSERID, obj, null, null, null, null, null, null, null, null,
                        null, null, null, null);
                empKeyinfoService.updMdupdFlg(obj.id);
                if ("02inactive".equals(obj.empkeyEmpstatus)){AuthPost authPost = new AuthPost();
                    authPost.poroEmpid =  obj.empId;
                    authPost.poroBustype =  "6essmss";
                    List<AuthPost> byObj = authPostService.getByObj(Integer.valueOf(obj.companyId), PubConstants.C_LANGCN, authPost, "id", "asc", false);
                    if (CollectionUtils.isNotEmpty(byObj)){List<UserInfo> infos = userInfoService.getByIds(Integer.valueOf(PubConstants.CS_DEFAULTCOMP), PubConstants.C_LANGCN, byObj.get(0).userId,false);
                        if(CollectionUtils.isNotEmpty(infos)){userInfoService.delByIds( byObj.get(0).userId);
                        }else {return;}
                    }
                }
            } catch (Exception e) {logger.info("员工要害信息: {}", obj.toString());
                logger.error("员工要害信息同步主数据谬误:" + e.getMessage(), e);
            }
        }

        // 任职信息的自动更新
        List<String> empIds = new ArrayList<String>();
        List<EmpAppinfo> appList = empAppinfoService.getNoUpdMDList();
        for (EmpAppinfo obj : appList) {
            try {
                empInfoService.updMain(PubConstants.C_SYSUSERID, null, null, obj, null, null, null, null, null, null,
                        null, null, null, null);
                empAppinfoService.updMdupdFlg(obj.id);
                empIds.add(obj.empId);
            } catch (Exception e) {logger.info("员工任职信息: {}", obj.toString());
                logger.error("员工任职信息同步主数据谬误:" + e.getMessage(), e);
            }
        }

        // 证件信息的自动更新
        List<EmpCertinfo> cerList = empCertinfoService.getNoUpdMDList();
        for (EmpCertinfo obj : cerList) {
            try {
                empInfoService.updMain(PubConstants.C_SYSUSERID, null, obj, null, null, null, null, null, null, null,
                        null, null, null, null);
                empCertinfoService.updMdupdFlg(obj.id);
            } catch (Exception e) {logger.info("员工证件信息: {}", obj.toString());
                logger.error("员工证件信息同步主数据谬误:" + e.getMessage(), e);
            }
        }

        // 银行信息的自动更新
        List<EmpBank> bankList = empBankService.getNoUpdMDList();
        for (EmpBank obj : bankList) {
            try {
                empInfoService.updMain(PubConstants.C_SYSUSERID, null, null, null, null, obj, null, null, null, null,
                        null, null, null, null);
                empBankService.updMdupdFlg(obj.id);
            } catch (Exception e) {logger.info("员工银行卡信息: {}", obj.toString());
                logger.error("员工银行卡信息同步主数据谬误:" + e.getMessage(), e);
            }
        }

        // 员工合同信息 (新)
        List<EmpContract> contractList = empContractService.getNoUpdMDList();
        for (EmpContract obj : contractList) {
            try {
                empInfoService.updMain(PubConstants.C_SYSUSERID, null, null, null, obj, null, null, null, null, null,
                        null, null, null, null);
                empContractService.updMdupdFlg(obj.id);
            } catch (Exception e) {logger.info("员工合同信息: {}", obj.toString());
                logger.error("员工合同信息同步主数据谬误:" + e.getMessage(), e);
            }
        }

        // 员工薪资我的项目
        List<EmpSalarypro> empSalarypros = empSalaryproService.getNoUpdMDList();
        for (EmpSalarypro obj : empSalarypros) {
            try {
                empInfoService.updMain(PubConstants.C_SYSUSERID, null, null, null, null, null, null, null, null, null,
                        null, obj, null, null);
                empSalaryproService.updMdupdFlg(obj.id);
            } catch (Exception e) {logger.info("员工薪资我的项目信息: {}", obj.toString());
                logger.error("员工薪资我的项目信息同步主数据谬误:" + e.getMessage(), e);
            }
        }

        // 员工档案信息
        List<EmpRecord> empRecords = empRecordService.getNoUpdMDList();
        for (EmpRecord obj : empRecords) {
            try {
                empInfoService.updMain(PubConstants.C_SYSUSERID, null, null, null, null, null, null, null, null, null,
                        obj, null, null, null);
                empSalaryproService.updMdupdFlg(obj.id);
            } catch (Exception e) {logger.info("员工图像信息: {}", obj.toString());
                logger.error("员工图像信息同步主数据谬误:" + e.getMessage(), e);
            }
        }

        // 员工地址信息
        List<EmpAddress> EmpAddresss = empAddressService.getNoUpdMDList();
        for (EmpAddress obj : EmpAddresss) {
            try {
                empInfoService.updMain(PubConstants.C_SYSUSERID, null, null, null, null, null, null, null, null, null,
                        null, null, obj, null);
                empAddressService.updMdupdFlg(obj.id);
            } catch (Exception e) {logger.info("员工地址信息: {}", obj.toString());
                logger.error("员工地址信息同步主数据谬误:" + e.getMessage(), e);
            }
        }
        // 员工分割信息
        List<EmpContact> empContacts = empContactService.getNoUpdMDList();
        for (EmpContact obj : empContacts) {
            try {
                empInfoService.updMain(PubConstants.C_SYSUSERID, null, null, null, null, null, null, obj, null, null,
                        null, null, null, null);
                empContactService.updMdupdFlg(obj.id);
            } catch (Exception e) {logger.info("员工分割信息: {}", obj.toString());
                logger.error("员工分割信息同步主数据谬误:" + e.getMessage(), e);
            }
        }
        // 员工福利信息
        List<EmpWealinfo> empWealinfos = empWealinfoService.getNoUpdMDList();
        for (EmpWealinfo obj : empWealinfos) {
            try {
                empInfoService.updMain(PubConstants.C_SYSUSERID, null, null, null, null, null, null, null, null, obj,
                        null, null, null, null);
                empWealinfoService.updMdupdFlg(obj.id);
            } catch (Exception e) {logger.info("员工福利信息: {}", obj.toString());
                logger.error("员工福利信息同步主数据谬误:" + e.getMessage(), e);
            }
        }
        // 员工薪酬信息
        List<EmpPayinfo> empPayinfos = empPayinfoService.getNoUpdMDList();
        for (EmpPayinfo obj : empPayinfos) {
            try {
                empInfoService.updMain(PubConstants.C_SYSUSERID, null, null, null, null, null, null, null, obj, null,
                        null, null, null, null);
                empPayinfoService.updMdupdFlg(obj.id);
            } catch (Exception e) {logger.info("员工薪酬信息: {}", obj.toString());
                logger.error("员工薪酬信息同步主数据谬误:" + e.getMessage(), e);
            }
        }
        
        // 2021-1-19 获取生效的兼岗信息,推送主数据更新,次要是 OA 和钉钉
        List<String> syncEmpids = new ArrayList<String>();
        List<EmpAppinfo> appPartTimeList = empAppinfoService.getInvalidPartPostList();
        if (CollectionUtils.isNotEmpty(appPartTimeList)) {for (EmpAppinfo obj : appPartTimeList) {if (!empIds.contains(obj.empId)) {// 排除主岗更新时曾经同步的员工
                    syncEmpids.add(obj.empId);
                    empIds.add(obj.empId);
                }
            }
        } else {logger.info("!----------Not emp part-time post change.");
        }
        if (CollectionUtils.isNotEmpty(syncEmpids)) {logger.info("!----------syncEmpids: {}", syncEmpids.toString());
            empInfoService.pushSpecialEmpMdSynchMsgByIds(syncEmpids, PubConstants.CS_DEFAULTCOMP, "upd",
                    PubConstants.C_LANGCN);
        }
        // 2021-1-19 获取生效的兼岗信息,推送主数据更新,次要是 OA 和钉钉
        
    }
}

4. 更新主数据主动工作的配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:reg="http://www.dangdang.com/schema/ddframe/reg"
    xmlns:job="http://www.dangdang.com/schema/ddframe/job"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans.xsd
                        http://www.dangdang.com/schema/ddframe/reg
                        http://www.dangdang.com/schema/ddframe/reg/reg.xsd
                        http://www.dangdang.com/schema/ddframe/job
                        http://www.dangdang.com/schema/ddframe/job/job.xsd">
    <!-- 配置作业注册核心 -->
    <reg:zookeeper id="regCenter" server-lists="${dubbo.registry.address}"
        namespace="${elasticJobNameSpace}" base-sleep-time-milliseconds="1000"
        max-sleep-time-milliseconds="3000" max-retries="5" />
    <bean id="elasticJobLog" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName" value="${elasticJobLog.jdbc.driver}" />
        <property name="url" value="${elasticJobLog.jdbc.url}" />
        <property name="username" value="${elasticJobLog.jdbc.username}" />
        <property name="password" value="${elasticJobLog.jdbc.password}" />
    </bean>

    <!-- 配置作业 <job:simple id="baseNoticeJob" class="com.hrocloud.znjs.baseauth.autotask.BaseNoticeJob" 
        registry-center-ref="regCenter" cron="00 00 01 * * ? *" sharding-total-count="1" 
        sharding-item-parameters="0=A" overwrite="true" event-trace-rdb-data-source="elasticJobLog"/> -->

    <job:simple id="empBaseInfoAutoTaskJob"
        class="com.hrocloud.znjs.orgemp.autotask.EmpBaseInfoAutoTaskJob"
        registry-center-ref="regCenter" cron="0 0 1 * * ? *"
        sharding-total-count="1" sharding-item-parameters="0=A" overwrite="true"
        event-trace-rdb-data-source="elasticJobLog" />
    <!--// 每天的凌晨一点去执行计算工龄的动作 -->
    <job:simple id="EmpSendMsgAutoTaskJob"
        class="com.hrocloud.znjs.orgemp.autotask.EmpSendMsgAutoTaskJob"
        registry-center-ref="regCenter" cron="0 0 7 * * ? *"
        sharding-total-count="1" sharding-item-parameters="0=A" overwrite="true"
        event-trace-rdb-data-source="elasticJobLog" />
    <!--// 每天的早上七点去执行发送短信的动作 -->




    <job:simple id="empKeyInfoAutoTaskJob"
        class="com.hrocloud.znjs.orgemp.autotask.EmpKeyInfoAutoTaskJob"
        registry-center-ref="regCenter" cron="0 0 2 * * ? *"
        sharding-total-count="1" sharding-item-parameters="0=A" overwrite="true"
        event-trace-rdb-data-source="elasticJobLog" />
    <!-- 每天的凌晨 2 点去执行计算司龄的动作 -->

    <job:simple id="empFlowEntrAutoTaskJob"
        class="com.hrocloud.znjs.orgemp.autotask.EmpFlowEntrAutoTaskJob"
        registry-center-ref="regCenter" cron="0 59 23 * * ?"
        sharding-total-count="1" sharding-item-parameters="0=A" overwrite="true"
        event-trace-rdb-data-source="elasticJobLog" />
    <!-- 每天的 23:59 去执行用户生效的动作 -->

    <job:simple id="empFlowTeachAutoTaskJob"
        class="com.hrocloud.znjs.orgemp.autotask.EmpFlowTeachAutoTaskJob"
        registry-center-ref="regCenter" cron="0 30 1 25 * ? *"
        sharding-total-count="1" sharding-item-parameters="0=A" overwrite="true"
        event-trace-rdb-data-source="elasticJobLog" />
    <!-- 每月的 25 日零点 20 分去执行发动带教的动作 0 20 0 25 * ? *-->

    <job:simple id="empFlowTeachMailAutoTaskJob"
        class="com.hrocloud.znjs.orgemp.autotask.EmpFlowTeachMailAutoTaskJob"
        registry-center-ref="regCenter" cron="0 0 15 26/1 * ? *"
        sharding-total-count="1" sharding-item-parameters="0=A" overwrite="true"
        event-trace-rdb-data-source="elasticJobLog" />
    <!-- 每月的 25 日之后发送督促的 带教培训的邮件 -->

    <job:simple id="empMainUpdateAutoTaskJob"
        class="com.hrocloud.znjs.orgemp.autotask.EmpMainUpdateAutoTaskJob"
        registry-center-ref="regCenter" cron="0 40 0 * * ? *"
        sharding-total-count="1" sharding-item-parameters="0=A" overwrite="true"
        event-trace-rdb-data-source="elasticJobLog" />
    <!-- 每天 0 点 10 分更新员工主信息 -->



    <job:simple id="EmpFlowRegularhAutoTaskJob"
                class="com.hrocloud.znjs.orgemp.autotask.EmpFlowRegularhAutoTaskJob"
                registry-center-ref="regCenter" cron="0 5 0 * * ? *"
                sharding-total-count="1" sharding-item-parameters="0=A" overwrite="true"
                event-trace-rdb-data-source="elasticJobLog" />
    <!-- 每天 0 点 5 分发动转正 -->


    <!-- 每天 1 点开始扫要续签的员工 -->
    <job:simple id="EmpFlowConrenewAutoTaskJob"
                class="com.hrocloud.znjs.orgemp.autotask.EmpFlowConrenewAutoTaskJob"
                registry-center-ref="regCenter" cron="0 0 1 * * ? *"
                sharding-total-count="1" sharding-item-parameters="0=A" overwrite="true"
                event-trace-rdb-data-source="elasticJobLog" />

    <job:simple id="orgKbdataTaskJob"
        class="com.hrocloud.znjs.orgemp.autotask.OrgKbdataTaskJob"
        registry-center-ref="regCenter" cron="0 0 1 * * ? *"
        sharding-total-count="1" sharding-item-parameters="0=A" overwrite="true"
        event-trace-rdb-data-source="elasticJobLog" />
    <!-- 每天的凌晨一点去调用 ERP 组织看板接口 -->

    <!-- 每天 1 点 10 分开始统计组织看板数据:人效类、管理费、费效类 -->
    <job:simple id="orgKbRpt01TaskJob"
                class="com.hrocloud.znjs.orgemp.autotask.OrgKbRpt01TaskJob"
                registry-center-ref="regCenter" cron="0 10 1 * * ? *"
                sharding-total-count="1" sharding-item-parameters="0=A" overwrite="true"
                event-trace-rdb-data-source="elasticJobLog" />

    <!-- 每天 1 点 15 开始统计组织看板数据:平台、学历、员工分类、学校类型、年龄剖析 -->
    <job:simple id="OrgKbRpt02TaskJob"
                class="com.hrocloud.znjs.orgemp.autotask.OrgKbRpt02TaskJob"
                registry-center-ref="regCenter" cron="0 15 1 * * ? *"
                sharding-total-count="1" sharding-item-parameters="0=A" overwrite="true"
                event-trace-rdb-data-source="elasticJobLog" />

    <!-- 每天两点整开始更新组织负责人 -->
    <job:simple id="orgUnitsAutoTaskJob"
                class="com.hrocloud.znjs.orgemp.autotask.OrgUnitsAutoTaskJob"
                registry-center-ref="regCenter" cron="0 20 0 * * ?"
                sharding-total-count="1" sharding-item-parameters="0=A" overwrite="true"
                event-trace-rdb-data-source="elasticJobLog" />

</beans>
退出移动版