//返回参数必须包含 错误的List,需要提交的List
public HashMap pass_hours(List<InstanceContentVO> applyList,
InstanceContentVO instancecontentvo) throws ApplicationException {
String message= "";
HashMap map = new HashMap();
List<InstanceContentVO> errorList = new ArrayList<InstanceContentVO>();
List<InstanceContentVO> newList =new ArrayList<InstanceContentVO>();
Comparator c = new ContentComparator();
// 为集合排序
Collections.sort(applyList, c);
Date cFlag = null;
List<ApplyVO> groupList = new ArrayList<ApplyVO>(); //存放不同的组
ApplyVO applyVO = null;
List<InstanceContentVO> contentList = new ArrayList<InstanceContentVO>(); //存放同组记录
for(int i=0;i<applyList.size();i++){
InstanceContentVO vo = applyList.get(i);
Date sdate = conversionDate(vo.getStartDate());
if(i==0 || sdate.before(cFlag) || sdate.after(cFlag) ){ //不同日期
applyVO = new ApplyVO();
contentList = new ArrayList<InstanceContentVO>();
contentList.add(vo);
applyVO.setInstanceContentList(contentList);
groupList.add(applyVO);
cFlag = sdate;
} else {
contentList.add(vo);
applyVO.setInstanceContentList(contentList);
}
}
//对每组的合计时间进行获取和判断
for(int i=0;i<groupList.size();i++){
ApplyVO avo = groupList.get(i);
long groupHour =getGroupHour(avo.getInstanceContentList());//获取各组的合计时间,判断是否满足4小时
if(groupHour<AllowanceConstants.HOLIDAY_ON_SITE_HOUR){//如果小于4小时,那么继续判断是否在系统中有同一天的申报,如果不存在,不可以申报
InstanceContentVO vo=(InstanceContentVO)avo.getInstanceContentList().get(0);
vo.setPayrollId(instancecontentvo.getPayrollId());
vo.setEmployee_id(instancecontentvo.getEmployee_id());
vo.setElement_id(instancecontentvo.getElement_id());
int countRecord=getRecordCount(vo);//判断该员工是否已经有了同一天的申报数据
if(countRecord==0){ // countRecord==0是第一次申报,所以不满足提交的条件,校验不通过,必须添加到错误List,同时从提交list中删除
Iterator it=avo.getInstanceContentList().iterator();
while(it.hasNext()){ //如果该组不符合提交条件,把他们的记录都迭代出放到错误列表中
errorList.add((InstanceContentVO)it.next());
}
message ="errors.oneday.no4Hour";
groupList.remove(i); //整个组从引用中删除
i--;
}
}
}
for(int k=0;k<groupList.size();k++){
ApplyVO applyvo = groupList.get(k);
for(int u=0;u<applyvo.getInstanceContentList().size();u++){
InstanceContentVO icvo = (InstanceContentVO)applyvo.getInstanceContentList().get(u); //获取组的数据
newList.add(icvo);//重新包装申报数据
}
}
map.put("errorList", errorList);
map.put("applyList", newList);
map.put("message", message);
return map;}
public HashMap pass_hours(List<InstanceContentVO> applyList,
InstanceContentVO instancecontentvo) throws ApplicationException {
String message= "";
HashMap map = new HashMap();
List<InstanceContentVO> errorList = new ArrayList<InstanceContentVO>();
List<InstanceContentVO> newList =new ArrayList<InstanceContentVO>();
Comparator c = new ContentComparator();
// 为集合排序
Collections.sort(applyList, c);
Date cFlag = null;
List<ApplyVO> groupList = new ArrayList<ApplyVO>(); //存放不同的组
ApplyVO applyVO = null;
List<InstanceContentVO> contentList = new ArrayList<InstanceContentVO>(); //存放同组记录
for(int i=0;i<applyList.size();i++){
InstanceContentVO vo = applyList.get(i);
Date sdate = conversionDate(vo.getStartDate());
if(i==0 || sdate.before(cFlag) || sdate.after(cFlag) ){ //不同日期
applyVO = new ApplyVO();
contentList = new ArrayList<InstanceContentVO>();
contentList.add(vo);
applyVO.setInstanceContentList(contentList);
groupList.add(applyVO);
cFlag = sdate;
} else {
contentList.add(vo);
applyVO.setInstanceContentList(contentList);
}
}
//对每组的合计时间进行获取和判断
for(int i=0;i<groupList.size();i++){
ApplyVO avo = groupList.get(i);
long groupHour =getGroupHour(avo.getInstanceContentList());//获取各组的合计时间,判断是否满足4小时
if(groupHour<AllowanceConstants.HOLIDAY_ON_SITE_HOUR){//如果小于4小时,那么继续判断是否在系统中有同一天的申报,如果不存在,不可以申报
InstanceContentVO vo=(InstanceContentVO)avo.getInstanceContentList().get(0);
vo.setPayrollId(instancecontentvo.getPayrollId());
vo.setEmployee_id(instancecontentvo.getEmployee_id());
vo.setElement_id(instancecontentvo.getElement_id());
int countRecord=getRecordCount(vo);//判断该员工是否已经有了同一天的申报数据
if(countRecord==0){ // countRecord==0是第一次申报,所以不满足提交的条件,校验不通过,必须添加到错误List,同时从提交list中删除
Iterator it=avo.getInstanceContentList().iterator();
while(it.hasNext()){ //如果该组不符合提交条件,把他们的记录都迭代出放到错误列表中
errorList.add((InstanceContentVO)it.next());
}
message ="errors.oneday.no4Hour";
groupList.remove(i); //整个组从引用中删除
i--;
}
}
}
for(int k=0;k<groupList.size();k++){
ApplyVO applyvo = groupList.get(k);
for(int u=0;u<applyvo.getInstanceContentList().size();u++){
InstanceContentVO icvo = (InstanceContentVO)applyvo.getInstanceContentList().get(u); //获取组的数据
newList.add(icvo);//重新包装申报数据
}
}
map.put("errorList", errorList);
map.put("applyList", newList);
map.put("message", message);
return map;}