2 Commits 10c73c5497 ... d21e54dd5d

Autor SHA1 Mensaje Fecha
  yuanzhi_kuang d21e54dd5d Merge branch 'master' of http://47.92.104.23:3000/SHR88/guangzhouyiselie hace 3 semanas
  yuanzhi_kuang 6316d1eab6 离职更新_邮件发送内容查询更新 hace 3 semanas

+ 29 - 6
GDYSL/src/com/kingdee/eas/hr/affair/app/ResignBizBillControllerBeanEx.java

@@ -126,12 +126,35 @@ public class ResignBizBillControllerBeanEx extends ResignBizBillControllerBean{
         	String personId = affairEntry.getPerson().getId().toString();
 //        	String personName = affairEntry.getPerson().getName();
 //        	String sql = "SELECT a.*,b.fid userid FROM T_HR_EmpOrgRelation a left join t_pm_user b on a.fpersonid = b.fpersonid where a.fpersonid = '"+personId+"' and a.fislatestinaday = '1' and a.cfhourlywage is not null and a.cfhourlywage <> 0 and year(a.fleffdt) = 2199";
-        	String sql="SELECT a.*,c.fid as userid,d.fname_l1 as personName FROM T_HR_EmpOrgRelation a right join (SELECT max(a.fleffdt)as fleffdt,a.cfhourlywage as cfhourlywage, a.fpersonid as fpersonid FROM T_HR_EmpOrgRelation a where a.fpersonid='"+personId+"'   and a.cfhourlywage is not null and a.cfhourlywage <> 0   and a.fislatestinaday = '1' group by a.fpersonid,a.cfhourlywage)b\r\n" + 
-        			"on a.fpersonid=b.fpersonid and a.fleffdt=b.fleffdt and a.cfhourlywage =b.cfhourlywage\r\n" + 
-        			" left join t_pm_user c on a.fpersonid = c.fpersonid left join t_bd_person d on d.fid =a.fpersonid\r\n" + 
-        			" where a.fpersonid='"+personId+"'  and a.cfhourlywage is not null and a.cfhourlywage <> 0  and a.fislatestinaday = '1' ";
-        	logger.error("查询变动记录SQL:"+sql);
-        	IRowSet row = DbUtil.executeQuery(ctx, sql);
+//        	String sql="SELECT a.*,c.fid as userid,d.fname_l1 as personName FROM T_HR_EmpOrgRelation a right join (SELECT max(a.fleffdt)as fleffdt,a.cfhourlywage as cfhourlywage, a.fpersonid as fpersonid FROM T_HR_EmpOrgRelation a where a.fpersonid='"+personId+"'   and a.cfhourlywage is not null and a.cfhourlywage <> 0   and a.fislatestinaday = '1' group by a.fpersonid,a.cfhourlywage)b\r\n" +
+//        			"on a.fpersonid=b.fpersonid and a.fleffdt=b.fleffdt and a.cfhourlywage =b.cfhourlywage\r\n" +
+//        			" left join t_pm_user c on a.fpersonid = c.fpersonid left join t_bd_person d on d.fid =a.fpersonid\r\n" +
+//        			" where a.fpersonid='"+personId+"'  and a.cfhourlywage is not null and a.cfhourlywage <> 0  and a.fislatestinaday = '1' ";
+			//202511改,使用最新的一条变动记录来进行判断, (处理再入职人员的场景)
+			String sql = "SELECT " +
+					"    a.*, " +
+					"    c.fid as userid, " +
+					"    d.fname_l1 as personName " +
+					"FROM T_HR_EmpOrgRelation a " +
+					"RIGHT JOIN ( " +
+					"    SELECT " +
+					"        a.fpersonid, " +
+					"        MAX(a.fleffdt) as max_fleffdt " +
+					"    FROM T_HR_EmpOrgRelation a " +
+					"    WHERE a.fpersonid = ? " +
+					"        AND a.fislatestinaday = '1' " +
+					"    GROUP BY a.fpersonid " +
+					") b ON a.fpersonid = b.fpersonid AND a.fleffdt = b.max_fleffdt " +
+					"LEFT JOIN t_pm_user c ON a.fpersonid = c.fpersonid " +
+					"LEFT JOIN t_bd_person d ON d.fid = a.fpersonid " +
+					"WHERE a.fpersonid = ? " +
+					"    AND a.fislatestinaday = '1' " +
+					"    AND a.cfhourlywage is not null " +
+					"    AND a.cfhourlywage <> 0";
+
+
+			logger.error("查询变动记录SQL:"+sql);
+        	IRowSet row = DbUtil.executeQuery(ctx, sql, new String[]{personId, personId});
         	String userId = "";
         	while(row.next()) {
         		userId = row.getString("userid");