工作人员对应关系错乱----问题解决

最近参与到一个维护项目,客户反映,自己的Live环境,工作人员的ListPage界面看到张三,点击进去显示李四。

最初看到这个问题,想到的那肯定是工作人员对应的人员记录不合适,查找后台表,HcmWork 和Dirperson表中人员都有,就开始了debug,跟代码,然鹅,代码跟踪费劲了,没找到线索。

后来还是从详细界面入手,查看界面组织出来的Query,发现DirpersonName表中没有数据。恩,就是Dirperson关联的DirpersonName表中缺少部分人员的记录。在ListPage界面看到的人员名称,在Dieperson表中是全名,而详细的姓和名是分开存储在DirpersonName中。

跟客户了解后得知,有错的这一批工作人员数据是几年前上线时用代码导入的。这就对了,代码导入时未给DirperName赋值,导致每次打开详细界面,有问题的人员都会随机指到某一个工作人员信息中去。

好了,有趣的背景已介绍完毕,找到问题,解决就好办了。根据人员Dirperson表补缺失的人员名称(DiepersonName)数据。以下是我写了一个Job用来修复错误的数据,可供参考。

static void Sunny_updateHcmworkerName(Args _args)
{
    HcmWorker           hcmWork;
    DirPerson           dirPerson;
    DirPersonName       dirPersonName;
    container           con;

    while select hcmWork
        join dirPerson
          where hcmWork.Person == dirPerson.RecId
    {
        select  firstOnly  dirPersonName
        where dirPersonName.Person == dirPerson.RecId;

        if(!dirPersonName)
        {
            con = DirPerson::splitNameParts(dirPerson.Name);
            dirPersonName.clear();
            dirPersonName.initValue();
            dirPersonName.Person          = dirPerson.RecId;
            dirPersonName.FirstName       = conPeek(con, 1);
            dirPersonName.MiddleName      = conPeek(con, 2);
            dirPersonName.LastName        = conPeek(con, 3);
            dirPersonName.ValidFrom       = dirPerson.createdDateTime;
            dirPersonName.ValidTo         = DateTimeUtil::maxValue();
            dirPersonName.insert();

            info(hcmWork.PersonnelNumber);
        }
    }
}

  

原文地址:https://www.cnblogs.com/sunny-technology/p/11401406.html