فهرست منبع

兼职终止单后台

yuanzhi_kuang 1 هفته پیش
والد
کامیت
c7198dc746

+ 1 - 1
GDYSL/src/com/kingdee/eas/custom/facade/EarlyWarningFacadeControllerBean.java

@@ -30,7 +30,7 @@ import com.kingdee.eas.util.app.DbUtil;
 import com.kingdee.jdbc.rowset.IRowSet;
 
 /**
- * 后台任务发送预警消息
+ * 后台任务发送预警消息 个人加班邮件预警
  * @author xiaoxin
  *
  */

+ 45 - 31
GDYSL/src/com/kingdee/eas/custom/facade/plurality/PluralitySubFacadeControllerBean.java

@@ -22,10 +22,16 @@ import java.util.Date;
 import java.util.HashMap;
 import com.kingdee.bos.*;
 import com.kingdee.eas.common.EASBizException;
-import com.kingdee.eas.custom.hr.utils.DateUtil;
+ 
 
 import java.lang.String;
 
+
+/**
+ * 兼职终止
+ * @author kkuan
+ *
+ */
 public class PluralitySubFacadeControllerBean extends AbstractPluralitySubFacadeControllerBean
 {
     private static Logger logger =
@@ -40,37 +46,39 @@ public class PluralitySubFacadeControllerBean extends AbstractPluralitySubFacade
 		HashMap<String, Object> params = new HashMap  ();
 		params.put("reasonInfo", reasonInfo);
 		params.put("defineInfo", defineInfo);
-		Date bizDate = new Date();
+		
 		//查询所有当天日期的离职单
-		if (StringUtils.isNotBlank(curdate)) {
-			bizDate = DateUtil.stringToDate(curdate, "yyyy-MM-dd");
-		}
-		Date startDate = DateUtil.getDateStartTime(bizDate);
-		Date endDate = DateUtil.getDateEndTime(bizDate);
-		if( offset > 0 ){
-			endDate = DateUtil.add(endDate, offset) ;
-		}else if( offset < 0 ) {
-			startDate = DateUtil.add(startDate, offset) ;
-		}
+		try {
+			//转 00:00:00
+			Date bizDate = DateTimeUtils.parseDate(DateTimeUtils.format( new Date(), "yyyy-MM-dd"),  "yyyy-MM-dd")  ;  
+			if (StringUtils.isNotBlank(curdate)) {
+				bizDate = DateTimeUtils.parseDate(curdate, "yyyy-MM-dd");
+			} 
+			Date startDate = bizDate;
+			Date endDate = DateTimeUtils.addDay(bizDate, 1) ;
+			if( offset > 0 ){
+				endDate = DateTimeUtils.addDay(endDate, offset) ;
+			}else if( offset < 0 ) {
+				startDate = DateTimeUtils.addDay(startDate, offset) ;
+			}
 
-    	//查询兼职单
-		StringBuilder sbu = new StringBuilder();
-		sbu.append(" select  bill.fid billId   from T_HR_PluralityAddBizBill bill ");
-		sbu.append(" left join  T_HR_PluralityAddBizBillEntry entry on bill.FEntryId = entry.fbillid ");
-		sbu.append(" where  bill.fbillstate = '3'  "  );
-		sbu.append(" and  entry.fenddate >= '" + startDate+"' " );
-		sbu.append(" and  entry.fenddate <= '" + endDate+"' " );
-		if( StringUtils.isNotBlank(personId)){
-			sbu.append(" and  entry.fpersonid = " + personId );
-		}
-		IRowSet rowSet = DbUtil.executeQuery(ctx, sbu.toString());
+			//查询兼职单
+			StringBuilder sbu = new StringBuilder();
+			sbu.append(" select  bill.fid billId   from T_HR_PluralityAddBizBill bill ");
+			sbu.append(" left join  T_HR_PluralityAddBizBillEntry entry on bill.FEntryId = entry.fbillid ");
+			sbu.append(" where  bill.fbillstate = '3'  "  );
+			sbu.append(" and  entry.fenddate >= '" + startDate+"' " );
+			sbu.append(" and  entry.fenddate < '" + endDate+"' " );
+			if( StringUtils.isNotBlank(personId)){
+				sbu.append(" and  entry.fpersonid = " + personId );
+			}
+			IRowSet rowSet = DbUtil.executeQuery(ctx, sbu.toString());
 		 
-		try {
 			while(rowSet.next()) {
 				String billId = rowSet.getString("billId");
 				newDelBill(  ctx,   billId , params);
 			}
-		} catch (SQLException e) {
+		} catch (SQLException | ParseException e) {
 			e.printStackTrace();
 		}
 	 
@@ -179,7 +187,7 @@ public class PluralitySubFacadeControllerBean extends AbstractPluralitySubFacade
 	protected void _resignCreateEnd(Context ctx, String personId, String endDate) throws BOSException, EASBizException {
 		super._resignCreateEnd(ctx, personId, endDate);
 		if(StringUtils.isBlank(endDate)) {
-			endDate = DateUtil.dateToString(new Date(), "yyyy-MM-dd");
+			 endDate = DateTimeUtils.format (new Date(), "yyyy-MM-dd");
 		}
 		
 		//变动类型
@@ -196,11 +204,17 @@ public class PluralitySubFacadeControllerBean extends AbstractPluralitySubFacade
 		sbu.append(" left join  T_HR_PluralityAddBizBillEntry entry on bill.FId = entry.fbillid "); 
 		sbu.append(" left join T_HR_PluralityDelBizBillEntry  delen   ");
 		sbu.append(" on  entry.fpersonid = delen.fpersonid   ");
-		sbu.append(" and  entry.foldpositionid = delen.FMainPositionID  ");
-		sbu.append(" and   (   ");
-		sbu.append(" entry.cfpthwage = delen.cfpthwage   ");
-		sbu.append(" OR  ( entry.cfpthwage IS NULL AND delen.cfpthwage IS NULL  ) ");
-		sbu.append("  )   ");
+		
+		sbu.append(" and  entry.FBizDate = delen.FBeginDate  ");
+        sbu.append(" and  entry.fpositionid = delen.FOldPositionID  ");
+        sbu.append(" and   (   ");
+        sbu.append(" entry.cfpthwage = delen.cfpthwage   ");
+        sbu.append(" OR  ( entry.cfpthwage IS NULL AND delen.cfpthwage IS NULL  ) ");
+        sbu.append("  )   ");
+        sbu.append(" and   (   ");
+        sbu.append(" entry.cfptlmanagerid = delen.cfptlmanagerid   ");
+        sbu.append(" OR  ( entry.cfptlmanagerid IS NULL AND delen.cfptlmanagerid IS NULL  ) ");
+        sbu.append("  )   ");
 		sbu.append(" where  bill.fbillstate = '3'  ");
 		sbu.append(" and  entry.fpersonid = '" + personId+"'" );
 		sbu.append(" and  ( entry.fenddate >= {" + endDate+"}  or entry.fenddate is null ) ");

+ 134 - 15
GDYSL/src/com/kingdee/eas/hr/affair/app/PluralityDelBizBillControllerBeanEx.java

@@ -18,9 +18,14 @@ import com.kingdee.eas.hr.affair.PluralityDelBizBillEntryCollection;
 import com.kingdee.eas.hr.affair.PluralityDelBizBillEntryInfo;
 import com.kingdee.eas.hr.affair.PluralityDelBizBillFactory;
 import com.kingdee.eas.hr.affair.PluralityDelBizBillInfo;
-import com.kingdee.eas.hr.affair.app.PluralityDelBizBillControllerBean;
+import com.kingdee.eas.hr.base.EmpPosOrgRelationFactory;
+import com.kingdee.eas.hr.base.EmpPosOrgRelationInfo;
+import com.kingdee.eas.hr.base.IEmpPosOrgRelation;
 import com.kingdee.eas.util.app.DbUtil;
 import com.kingdee.jdbc.rowset.IRowSet;
+import com.kingdee.shr.compensation.CmpEmpORelationFactory;
+import com.kingdee.shr.compensation.CmpEmpORelationInfo;
+import com.kingdee.shr.compensation.ICmpEmpORelation;
 
 /**
  * 扩展了PluralityDelBizBillControllerBean类,增加了在提交单据后的endDate更新逻辑。
@@ -83,6 +88,9 @@ public class PluralityDelBizBillControllerBeanEx extends PluralityDelBizBillCont
                 PluralityDelBizBillEntryInfo entryInfo = entrys.get(i);
                 // 检查并更新添加单据的endDate
                 checkAddBill(ctx, entryInfo.getId().toString(),1);
+                //更新变更记录
+                checkRelation(ctx,entryInfo.getId().toString(),null,1);
+
             }
         }
     }
@@ -95,10 +103,9 @@ public class PluralityDelBizBillControllerBeanEx extends PluralityDelBizBillCont
      * @throws BOSException 业务基础服务异常
      * @throws EASBizException EAS业务异常
      */
-    private void checkAddBill(Context ctx, String entryId, int type) throws BOSException, EASBizException {
+    private Date checkAddBill(Context ctx, String entryId, int type) throws BOSException, EASBizException {
 //        // 创建删除单据条目集合
 //        CoreBaseCollection delEnCol = new CoreBaseCollection();
-
         // 构建SQL查询语句
         StringBuilder sbu = new StringBuilder();
         sbu.append(" select  bill.fid addId  , entry.fid  addEnId ,entry.fendDate addEndDate  ");
@@ -108,25 +115,132 @@ public class PluralityDelBizBillControllerBeanEx extends PluralityDelBizBillCont
         sbu.append(" left join  T_HR_PluralityAddBizBillEntry  entry on bill.FId = entry.fbillid ");
         sbu.append(" left join  T_HR_PluralityDelBizBillEntry  delen   ");
         sbu.append(" on  entry.fpersonid = delen.fpersonid   ");
-        sbu.append(" and  entry.foldpositionid = delen.FMainPositionID  ");
+        
+        sbu.append(" and  entry.FBizDate = delen.FBeginDate  ");
+        sbu.append(" and  entry.fpositionid = delen.FOldPositionID  ");
         sbu.append(" and   (   ");
         sbu.append(" entry.cfpthwage = delen.cfpthwage   ");
         sbu.append(" OR  ( entry.cfpthwage IS NULL AND delen.cfpthwage IS NULL  ) ");
         sbu.append("  )   ");
+        sbu.append(" and   (   ");
+        sbu.append(" entry.cfptlmanagerid = delen.cfptlmanagerid   ");
+        sbu.append(" OR  ( entry.cfptlmanagerid IS NULL AND delen.cfptlmanagerid IS NULL  ) ");
+        sbu.append("  )   ");
         sbu.append(" where  bill.fbillstate = '3'  ");
         sbu.append(" and  delen.fid = '" + entryId + "'");
-        
+        //反审核
         if( type == 0 ) {
-        	restoreAddBillEndDate(ctx, sbu.toString());
+        	return restoreAddBillEndDate(ctx, sbu.toString());
         }else if( type == 1 ) {
-        	updateAddBillEndDate(ctx, sbu.toString());
+            //审核
+        	return updateAddBillEndDate(ctx, sbu.toString());
         }
+        return null;
+    }
+
+
+
+    /**
+     * 检查并更新变动记录的endDate。
+     * @param ctx 上下文对象
+     * @param entryId 单据条目ID
+     * @param type  1:审核 ; 0:反审核
+     * @throws BOSException 业务基础服务异常
+     * @throws EASBizException EAS业务异常
+     */
+    private Date checkRelation(Context ctx, String entryId, Date newDate , int type) throws BOSException, EASBizException {
+        // 构建SQL查询语句
+        StringBuilder sbu = new StringBuilder();
+        sbu.append(" select   bill.fid  billId   ");
+        sbu.append(" , cmpBill.FID  cmpBillId  ");
+        sbu.append(" , delen.fbizDate  newEDate  ");
+        sbu.append(" from T_HR_EmpOrgRelation  bill ");
+        sbu.append(" left join T_HR_SCmpEmpORelation  cmpBill ");
+        sbu.append(" on  bill.FID = cmpBill.femporgrelationid   ");
+        sbu.append(" left join  T_HR_PluralityDelBizBillEntry  delen   ");
+        sbu.append(" on  bill.fpersonid = delen.fpersonid   ");
         
+        sbu.append(" and  bill.feffdt = delen.FBeginDate  ");
+        sbu.append(" and  bill.fpositionid = delen.FOldPositionID  ");
+        sbu.append(" and   (   ");
+        sbu.append(" bill.CFLineManagerNameI = delen.cfptlmanagerid   ");
+        sbu.append(" OR  ( bill.CFLineManagerNameI IS NULL AND delen.cfptlmanagerid IS NULL  ) ");
+        sbu.append("  )   ");
+        sbu.append(" where    ");
+        sbu.append(" delen.fid = '" + entryId + "'");
+        //反审核
+        if( type == 0 ) {
+            return updateRelationEndDate(ctx, sbu.toString(),newDate,type);
+        }else if( type == 1 ) {
+            //审核
+            return updateRelationEndDate(ctx, sbu.toString(),null,type);
+        }
+        return  null;
     }
+
+
+
+
+
+
+
+
+    /**
+     * 更新变动记录结束日期
+     * @param ctx
+     * @param sqlStr
+     * @param newEDate
+     * @param opType 0,反审核;  1,审核
+     * @return
+     */
+    private  Date  updateRelationEndDate(Context ctx, String sqlStr,Date newEDate,int opType ) {
+        // 创建添加单据条目集合
+        CoreBaseCollection addEnCol = new CoreBaseCollection();
+        try {
+            // 获取添加单据条目实例
+            IEmpPosOrgRelation  billIns = EmpPosOrgRelationFactory.getLocalInstance(ctx);
+            ICmpEmpORelation cmpBillIns = CmpEmpORelationFactory.getLocalInstance(ctx);
+            // 执行SQL查询
+            IRowSet rowSet = DbUtil.executeQuery(ctx, sqlStr);
+            // 遍历查询结果
+            while (rowSet.next()) {
+                // 获取添加单据条目ID
+                String billId = rowSet.getString("billId");
+                // 获取薪酬档案记录ID
+                String cmpBillId = rowSet.getString("cmpBillId");
+                // 获取新的endDate 审核的时候;
+                if(opType ==  1){
+                    newEDate = rowSet.getDate("newEDate");
+                }
+                // 变动记录
+                EmpPosOrgRelationInfo billInfo = billIns.getEmpPosOrgRelationInfo(new ObjectUuidPK(billId));
+                //薪酬 记录
+                CmpEmpORelationInfo cmpInfo = cmpBillIns.getCmpEmpORelationInfo(new ObjectUuidPK(cmpBillId));
+                if ( null != newEDate) {
+                    //结束日期 = 单据创建时的结束日期
+                    billInfo.setLEFFDT(newEDate);
+                    billInfo.setEndDateTime(newEDate);
+                    cmpInfo.setLeffectDate(newEDate);
+                }
+//                addEnCol.add(billInfo);
+                billIns.update(new ObjectUuidPK(billId),billInfo);
+                cmpBillIns.update(new ObjectUuidPK(cmpBillId),cmpInfo);
+            }
+            // 更新 集合
+//            billIns.update(addEnCol);
+        } catch (BOSException | SQLException | EASBizException e) {
+            e.printStackTrace();
+        }
+        return newEDate;
+    }
+
+
+
+
+
     
-    
-    
-    private  void  updateAddBillEndDate(Context ctx, String sqlStr) {
+    private  Date  updateAddBillEndDate(Context ctx, String sqlStr) {
+        Date newEDate = null;
         // 创建添加单据条目集合
         CoreBaseCollection addEnCol = new CoreBaseCollection();
     	try {
@@ -143,7 +257,7 @@ public class PluralityDelBizBillControllerBeanEx extends PluralityDelBizBillCont
             	// 获取oldEDate
             	Date addEndDate = rowSet.getDate("addEndDate");
             	// 获取新的endDate
-            	Date newEDate = rowSet.getDate("newEDate");
+                newEDate = rowSet.getDate("newEDate");
             	// 如果添加单据条目ID为空,则进行更新操作
             	
             	// 获取兼职单据条目信息
@@ -161,6 +275,7 @@ public class PluralityDelBizBillControllerBeanEx extends PluralityDelBizBillCont
         } catch (BOSException | SQLException | EASBizException e) {
             e.printStackTrace();
         }
+        return newEDate;
         
     	
     }
@@ -185,7 +300,10 @@ public class PluralityDelBizBillControllerBeanEx extends PluralityDelBizBillCont
     	PluralityDelBizBillEntryCollection entrys = delInfo.getEntrys();
     	for(int i = 0; i < entrys.size(); i++ ) {
     		PluralityDelBizBillEntryInfo entryInfo = entrys.get(i);
-    		checkAddBill(ctx, entryInfo.getId().toString(), 0);
+            //恢复兼职但上的结束日期
+            Date newDate = checkAddBill(ctx, entryInfo.getId().toString(), 0);
+            //更新变更记录
+            checkRelation(ctx,entryInfo.getId().toString(),newDate,0);
     	}
     }
     
@@ -197,7 +315,8 @@ public class PluralityDelBizBillControllerBeanEx extends PluralityDelBizBillCont
      * @param ctx
      * @param sqlStr
      */
-    private  void  restoreAddBillEndDate(Context ctx, String sqlStr) {
+    private  Date  restoreAddBillEndDate(Context ctx, String sqlStr) {
+        Date oldAddEDate = null;
         // 创建添加单据条目集合
         CoreBaseCollection addEnCol = new CoreBaseCollection();
     	try {
@@ -210,7 +329,7 @@ public class PluralityDelBizBillControllerBeanEx extends PluralityDelBizBillCont
             	// 获取添加单据条目ID
             	String addEnId = rowSet.getString("addEnId");
             	// 获取 原兼职单上创建时的日期,第一次写兼职结束时是空的;
-            	Date oldAddEDate = rowSet.getDate("oldAddEDate");
+                oldAddEDate = rowSet.getDate("oldAddEDate");
             	// 获取兼职单据条目信息
             	PluralityAddBizBillEntryInfo addInfo = addEnIns.getPluralityAddBizBillEntryInfo(new ObjectUuidPK(addEnId));
             	if ( null != oldAddEDate) {
@@ -224,7 +343,7 @@ public class PluralityDelBizBillControllerBeanEx extends PluralityDelBizBillCont
         } catch (BOSException | SQLException | EASBizException e) {
             e.printStackTrace();
         }
-        
+        return oldAddEDate;
     	
     }