Browse Source

点检率校验更新

yuanzhi_kuang 5 days ago
parent
commit
017970cc1e

+ 74 - 6
websrc/com/kingdee/shr/compensation/web/handler/timepiece/bill/CheckIwclUtil.java

@@ -1,13 +1,21 @@
 package com.kingdee.shr.compensation.web.handler.timepiece.bill;
 
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
 import com.kingdee.bos.metadata.entity.FilterInfo;
 import com.kingdee.bos.metadata.entity.FilterItemInfo;
 import com.kingdee.bos.metadata.query.util.CompareType;
 import com.kingdee.eas.framework.CoreBaseInfo;
 import com.kingdee.eas.hr.base.HRBillStateEnum;
+import com.kingdee.shr.compensation.app.integrate.CalSubmitItemCollection;
+import com.kingdee.shr.compensation.app.integrate.CalSubmitItemFactory;
+import com.kingdee.shr.compensation.app.integrate.CalSubmitItemInfo;
+import com.kingdee.shr.compensation.app.utils.SubConstants;
 
 import java.math.BigDecimal;
 
+import org.apache.commons.lang3.StringUtils;
+
 /**
  * 点检率校验
  * description: CheckIwclUtil <br>
@@ -18,21 +26,81 @@ import java.math.BigDecimal;
 public class CheckIwclUtil {
 
     //点检率
-    private static String IWCL = "S68";
+    private static String IWCL = "";
 
-    public static boolean isNotBlank(CoreBaseInfo entry) {
-        //点检率是否为空
-        BigDecimal s68 = entry.getBigDecimal(IWCL);
+    /**
+     * 对应字段值是否不为空;
+     * @param entry
+     * @param feildSeq
+     * @return
+     */
+    public static boolean isNotBlank(CoreBaseInfo entry,String feildSeq) {
+        BigDecimal s68 = entry.getBigDecimal(feildSeq);
         if (null == s68 || BigDecimal.ZERO.compareTo(s68) == 0) {
             return false;
         } else {
             return true;
         }
     }
-    public static boolean isBlank(CoreBaseInfo cs) {
-        return !isNotBlank(cs);
+    
+    /**
+     * 对应字段值是否为空;
+     * @param cs
+     * @param feildSeq
+     * @return
+     */
+    public static boolean isBlank(CoreBaseInfo cs,String feildSeq) {
+        return !isNotBlank(cs,feildSeq);
     }
 
+    
+    /**
+     * 点检率是否为空
+     * @param ctx
+     * @param cs
+     * @return
+     * @throws BOSException
+     */
+    public static boolean checkDataIsNull(Context ctx,CoreBaseInfo cs ) throws BOSException {
+    	if(StringUtils.isEmpty(IWCL)) {
+    		IWCL = getCheckSeq(ctx);
+    	}
+        return !isNotBlank(cs,IWCL);
+    }
+    
+    
+    /**
+     * 获取点检率seq
+     * @param ctx
+     * @return
+     * @throws BOSException
+     */
+    public static String   getCheckSeq(Context ctx ) throws BOSException {
+    	  return  getFeildSeq(ctx,SubConstants.COMRATE);
+    }
+      
+    
+    /**
+     * 通过编码获取项目的顺序号;
+     * @param ctx
+     * @param feildNum
+     * @return
+     * @throws BOSException
+     */
+    public static String  getFeildSeq(Context ctx,String feildNum) throws BOSException {
+    	String feildSeq = "";
+		CalSubmitItemCollection subColl = CalSubmitItemFactory.getLocalInstance(ctx)
+				.getCalSubmitItemCollection("SELECT ID,FieldSn,number  where  number = '"+feildNum+"'");
+		if(subColl.size()>0) {
+			CalSubmitItemInfo calSubmitItemInfo = subColl.get(0);
+			int fieldSn = calSubmitItemInfo.getFieldSn();
+			feildSeq = "S"+fieldSn ;
+		}
+		return feildSeq;
+    }
+    
+    
+    
 
     public static void main(String[] args) {
         FilterInfo filter = new FilterInfo();

+ 4 - 2
websrc/com/kingdee/shr/compensation/web/handler/timepiece/bill/TimepieceSchemeBillEditHandlerEx.java

@@ -83,11 +83,11 @@ public class TimepieceSchemeBillEditHandlerEx extends TimepieceSchemeBillEditHan
 
 	protected void beforeSubmit(HttpServletRequest request, HttpServletResponse response, CoreBaseInfo model) throws SHRWebException {
 		super.beforeSubmit(request, response, model);
+		Context ctx = SHRContext.getInstance().getContext();
 		String operateStatus = (String)request.getAttribute("operateState");
 		if (StringUtils.isEmpty(operateStatus)) {
 			operateStatus = request.getParameter("operateState");
 		}
-
 		if ("VIEW".equalsIgnoreCase(operateStatus)) {
 			model = (CoreBaseInfo)request.getAttribute("dynamic_model");
 		}
@@ -98,12 +98,14 @@ public class TimepieceSchemeBillEditHandlerEx extends TimepieceSchemeBillEditHan
 			for(int i = 0; i < collection.size(); i++){
 				BatchSubmitShemeBillEntryInfo entry =collection.get(i);
 				//点检率是否为空
-				if(CheckIwclUtil.isBlank(entry)){
+				if(CheckIwclUtil.checkDataIsNull(ctx,entry)){
 					throw new IllegalArgumentException("分录中" + entry.getPerson().getName() + ",有点检率为空的数据,请检查");
 				}
 			}
 		} catch (IllegalArgumentException var10) {
 			throw new ShrWebBizException(var10.getMessage(), var10);
+		} catch (BOSException e) {
+			e.printStackTrace();
 		}
 	}
 

+ 7 - 2
websrc/com/kingdee/shr/compensation/web/handler/timepiece/bill/TimepieceSchemeBillListHandlerEx.java

@@ -48,8 +48,11 @@ public class TimepieceSchemeBillListHandlerEx extends TimepieceSchemeBillListHan
         String returnStr = super.deleteAction(request, response, modelMap);
         return  returnStr ;
     }
+    
+    
     protected void beforeSubmit(HttpServletRequest request, HttpServletResponse response, CoreBaseInfo model) throws SHRWebException {
         super.beforeSubmit(request, response, model);
+        Context ctx = SHRContext.getInstance().getContext();
         String operateStatus = (String)request.getAttribute("operateState");
         if (StringUtils.isEmpty(operateStatus)) {
             operateStatus = request.getParameter("operateState");
@@ -65,13 +68,15 @@ public class TimepieceSchemeBillListHandlerEx extends TimepieceSchemeBillListHan
             for(int i = 0; i < collection.size(); i++){
                 BatchSubmitShemeBillEntryInfo entry =collection.get(i);
                 //点检率是否为空
-                if(CheckIwclUtil.isBlank(entry)){
+                if(CheckIwclUtil.checkDataIsNull(ctx, entry)) {
                     throw new IllegalArgumentException("分录中" + entry.getPerson().getName() + ",有点检率为空的数据,请检查");
                 }
             }
         } catch (IllegalArgumentException var10) {
             throw new ShrWebBizException(var10.getMessage(), var10);
-        }
+        } catch (BOSException e) {
+			e.printStackTrace();
+		}
     }