The process of a bug-oa the problem of duplicate files

Source: Internet
Author: User

1, some users can not add, yesterday has submitted the issue, needs to be dealt with as soon as possible, there are currently some recruits but can not use OA;

2, some users have been added, the following situation appears, the same user appears two records ( specific ), resulting in the user can not log on, but generated the employee's profile, but when viewing the details, But can not see the data, are empty files;

The emergence of these issues is related to the recently launched feature, which is the creation of a new system user directly creating an empty file function (including work number, user name, name, and auto-create identity).

for the problem 1 , we direct remote debugging to the production system, the code is as follows:

Userentity userentity = Userservice.queryuserbystaffid (Staffinfoentity.getstaffid ()); if (UserEntity! = null) {Boolean IsOk = Userservice.updateuserinfofordefine4 (Userentity.getusercode (), "updatenofiles"); if (isOk) {code = Staffinfodao.add (staffinfoentity);} try {moduleproxyservice.updateuserandldapadbystaffinfo (staffinfoentity);} catch (Exception e) {throw new Staffinfoexception ("New file Failed" + e.getmessage ());}} else {code = Staffinfodao.add (staffinfoentity);}

In the first row of queries, the user has only one. Then we go into the Updateuserandldapadbystaffinfo method, the first line of the method is to query the user according to the work number. At this point the system reported an error. We use MyBatis's selectone, but the result set is two. We started querying the user table to find that there are no corresponding new StaffID users, because the transaction is not committed here, there is no problem. But the transaction is not submitted, in the previous sentence is also a check, why here is turned into two article. In the middle of these two sentences, there is only one sentence, that is, inserting a file data. That is, both the file and the user data in the transaction should be one.

We open the corresponding Queryuserbystaffid method, as follows:

<!--  Search by employee number   --><select id= "Queryuserbystaffid" resultmap= "Userresultmap"    parametertype= "String" >select <include refid= "Userall_column"/>,  User.userstatusfrom <include refid= "User_staff_view"/> user  where  user.staffid = #{staffid}</select><sql id =  "User_Staff_View" > (select  tsu.id,tsu.sortno,tsu.usercode,tsu.deptcode,tsu.deptname,tsu.username,tsu.usernamepinying,tsu.sex, Tsu.usernameen,tsu.aliasname,tsu. ' Password ', Tsu.dn,tsu.managementscopetype,tsu.managementscope, Tsu.accesscontrol,tsu.createtime,tsu.createusercode,tsu.bindingip,tsu.modifytime,tsu.modifyusercode, Tsu.define1,tsu.define2,tsu.define3,tsu.active,tsu.staffid,tsu.deskmenusequence,tsu.userstatus,tsu.givenname, tsu.sn,tsu.displayname,tps.personalemail as email,tps.phone as mobile,tps.stationno  As physicaldeliveryofficename,tps.extensionphone as telePhonenumber,tps.officeaddress as l,tps.postname as title,tps.directleadername as  manager,tps.define4 as define4 from t_sys_user tsu inner join t_ PER_STAFFINFO&NBSP;TPS&NBSP;ON&NBSP;TSU.STAFFID&NBSP;=&NBSP;TPS.STAFFID) </sql>

This method of querying the user stems from our previous optimization process. Because some of the fields in the user and archive information are duplicated, we organize some of the fields in the users table that are duplicated in the file information, and unify them in the file table. Because some of the fields in the user table are deleted, and these fields may be needed in the business, we have added a query like User_staff_view.

The responsible engineer first considered the problem caused by the inner join, resulting in two occurrences. I immediately denied that if User\staffinfo had only one data, using the inner join would not produce two results. The same is true of the engineer's modification to the left join.

At the same time, other problems continue to burst, there is a problem 2, the cause of the error is also the landing after the successful query user information, due to selectone reported 500 errors. I query the system for the same work number or user name is really two identical user information. So I asked the OPS colleague what happens when two identical user information is inserted. Then in the background data I found that there is only one user record, why the query will appear two?

The problem is gradually focused on the query method. This association query problem can be sure that the user information has many, that is, the file information has multiple. But from a business perspective, users and files are globally unique relative to StaffID. I checked the file data, found that the file is really two--hr in the use of OA for new employees to create files using Excel import Append function (import has append and update two, if you choose to append, do not judge, insert new records directly), And the new on-line feature will create a user when the creation of an empty file, resulting in two records, but also affect the user's query.

To get back to the first question, we know that when adding a new user, the new file action has not been executed until the new user finishes. At this time not only the user, the file is only a non-committed transaction records, there can be no more than one. We further confirm that the work number of our new user has been found in the user table, the work number was assigned to a new employee who abandoned the job, it did not delete it after the entry, so after the new user, the record of uncommitted transactions + existing record is exactly two. The wrong direction of this problem directly affects our analysis and judgment of question 2.

Let's take a look at the difference between the inner join\left join\right join: The definition of the three we all know that the inner join only finds records that match the criteria, and the left join is based on the left table, and right joins is based on the table on the left. Let's take a look at our case, using the results of three join queries, all two tested. In fact, this is why I immediately denied the judgment of the engineer.


This article is from the "South Lake Miner Technology Space" blog, please be sure to keep this source http://jncumter.blog.51cto.com/812546/1638134

The process of a bug-oa the problem of duplicate files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.