package com.kingdee.shr.compensation.web.handler.integrate; import java.sql.SQLException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import com.kingdee.bos.BOSException; import com.kingdee.bos.Context; import com.kingdee.customer.util.handler.ConfigurationHandler; import com.kingdee.eas.basedata.person.PersonInfo; import com.kingdee.eas.util.app.ContextUtil; import com.kingdee.eas.util.app.DbUtil; import com.kingdee.jdbc.rowset.IRowSet; import com.kingdee.shr.base.syssetting.context.SHRContext; import com.kingdee.shr.base.syssetting.exception.ShrWebBizException; import com.kingdee.shr.compensation.app.integrate.BatchSubmitShemeBillEntryCollection; import com.kingdee.shr.compensation.app.integrate.BatchSubmitShemeBillEntryInfo; import com.kingdee.shr.compensation.app.integrate.BatchSubmitShemeBillInfo; import com.kingdee.shr.customer.gtiit.util.DateTimeUtils; public class BatchSubmitSchemeUtils { private static Logger logger = Logger.getLogger("com.kingdee.shr.compensation.web.handler.integrate.BatchSubmitSchemeUtils"); /** * 校验只能提交发生日期和提报日期在一个月内的单据 * @param info * @throws ShrWebBizException */ public static void checkSubmitDate(BatchSubmitShemeBillInfo info) throws ShrWebBizException{ Calendar calendar = Calendar.getInstance(); //提报日期 Date applyDate = info.getApplyDate(); calendar.setTime(applyDate); int thisYear = calendar.get(Calendar.YEAR); int thisMonth = calendar.get(Calendar.MONTH); BatchSubmitShemeBillEntryCollection entryColl = info.getEntry(); for(int i=0;i personIdList = new ArrayList(); List cmpEmpOrgIdList = new ArrayList(); for(int i=0;i= '"+adjustDate+"' " + "and a.fid in ("+strBuffer.toString()+")"; logger.error("获取员工发薪任职日期SQL:"+empOrgSql); IRowSet empRowSet = DbUtil.executeQuery(ctx, empOrgSql); List empPerIdList = new ArrayList(); while(empRowSet.next()) { empPerIdList.add(empRowSet.getString("fid")); } StringBuffer personIdBuffer = new StringBuffer(); for(String personId:personIdList) { if(!empPerIdList.contains(personId)) { personIdBuffer.append("'"+personId+"',"); } } if(personIdBuffer.length()>0) { personIdBuffer = personIdBuffer.deleteCharAt(personIdBuffer.length()-1); String personSql = "select fnumber from T_BD_Person where fid in ("+personIdBuffer+")"; IRowSet personRowSet = DbUtil.executeQuery(ctx, personSql); StringBuffer numberBuffer = new StringBuffer(); while(personRowSet.next()) { numberBuffer.append("'"+personRowSet.getString("fnumber")+"',"); } numberBuffer = numberBuffer.deleteCharAt(numberBuffer.length()-1); throw new ShrWebBizException("The following employees: ("+numberBuffer.toString()+") The adjusted occurrence date is not within the range of salary and employment dates"); } } catch (BOSException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } /** * 校验员工+方案+发生日期不能重复 * @param info * @throws ShrWebBizException */ public static void checkSubmitRepeat(BatchSubmitShemeBillInfo info) throws ShrWebBizException{ Context ctx = SHRContext.getInstance().getContext(); BatchSubmitShemeBillEntryCollection entryColl = info.getEntry(); String submitSchemeId = info.getSubmitScheme().getId().toString(); StringBuffer personBuffer = new StringBuffer(); for(int i=0;i0) { numberBuffer = numberBuffer.deleteCharAt(numberBuffer.length()-1); throw new ShrWebBizException("The following employees ("+numberBuffer+") have submitted data for this plan with an occurrence date of that month"); } } catch (BOSException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } /** * 校验员工+提报月+方案只能提交一次 * @throws ShrWebBizException */ public static void checkSubmitCount(BatchSubmitShemeBillInfo info) throws ShrWebBizException{ Context ctx = SHRContext.getInstance().getContext(); String personId = ContextUtil.getCurrentUserInfo(ctx).getPerson().getId().toString(); String proposerId = info.getProposer().getId().toString(); String submitSchemeId = info.getSubmitScheme().getId().toString(); if(!StringUtils.equals(personId, proposerId)) { throw new ShrWebBizException("Only self created documents can be submitted"); } //提报日期 Date applyDate = info.getApplyDate(); Calendar calendar = Calendar.getInstance(); calendar.setTime(applyDate); calendar.set(Calendar.DAY_OF_MONTH, 1); String startDate = DateTimeUtils.dateFormat(calendar.getTime(), "yyyy-MM-dd"); calendar.add(Calendar.MONTH, 1); String endDate = DateTimeUtils.dateFormat(calendar.getTime(), "yyyy-MM-dd"); int count = 0; String sql = "select count(1) count from T_HR_SBatchSubmitShemeBill where FPROPOSERID = '"+personId+"' and fbillstate in ('1','2','3') " + "and fdatasource = '2' and fapplydate >= '"+startDate+"' and fapplydate < '"+endDate+"' and FSUBMITSCHEMEID = '"+submitSchemeId+"'"; logger.error("查询员工当月提交次数SQL:"+sql); try { IRowSet iRowSet = DbUtil.executeQuery(ctx, sql); while(iRowSet.next()) { count = iRowSet.getInt("count"); } logger.error("员工该方案当月提交次数:"+count); if(count>0) { throw new ShrWebBizException("Your proposal has been submitted in the month of submission and cannot be resubmitted"); } } catch (BOSException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } /** * 校验分录人员是否重复 * @param info * @throws ShrWebBizException */ public static void checkPersonRepeat(BatchSubmitShemeBillInfo info) throws ShrWebBizException{ BatchSubmitShemeBillEntryCollection entryColl = info.getEntry(); Set personIdSet = new HashSet(); for(int i=0;i day) { throw new ShrWebBizException(" documents have passed the last submission date !"); } } catch (SQLException e) { e.printStackTrace(); } catch (BOSException e) { e.printStackTrace(); } } }