最近在有一个专家给项目打分的需求,要求一个专家随机打9个项目,一个项目随机被9个专家打,业务规则如下(专家不能给本部门发起的项目和合作单位发起的项目打分),
如:
项目GGGG是A部门申请的,合作单位是B,C,D,那么A、B、C、D部门的专家不能给项目GGG打分。
1、项目和专家的个数一致的 。
2、部门申请的项目总数和部门的专家数是一样的。
下边是小弟写的代码,老是爆数组越界错误。
List businessDataList=(List)argMap.get("businessDataList");
Map expertMap=new HashMap();
Map userCodeMap=new HashMap();
try {
y:for (int i = 0; i <= businessDataList.size(); i++) {
TPairJudgeBusinessData businessData=businessDataList.get(i);
List<TPairJudgeExpeortRelation> relations=this.getPairJudgeDDao().queryAllExpeortRelation(businessData.getPairJudgeId());
// List expertList = this.getPairJudgeDDao().findExpertcodeByorgname("", "");//所有专家
List expertList = this.getPairJudgeDDao().findExpertcodeByorgname("", businessData.getDeclareDeptName());//所有专家
int count=0;//记录项目拥有的专家数[虞春明, 网运中心, 13901346687, ycm]
n:for (Object obj : expertList) {
Object[] tExpertInfo = (Object[])obj;
int sumexpert = this.getPairJudgeDDao().findPairJudgeScore(tExpertInfo[3].toString(),businessData.getProcessId());//查询专家拥有的项目数
System.out.println("专家有的项目的总数:"+sumexpert);
//判断专家是否拥有9个项目
if(sumexpert==9){
continue n;
}
// //判断专家和项目是否是同部门或者合作部门
if(businessData.getFinishDeptName().indexOf(tExpertInfo[1].toString())!=-1){
continue n;
}
//判断项目是否有9个专家
int countexpert = this.getPairJudgeDDao().findPairJudgeScoreByJudgeId(businessData.getPairJudgeId(),businessData.getProcessId());//查询专家拥有的项目数
System.out.println("项目有的专家数:"+countexpert);
if(countexpert==9 && sumexpert==9){
continue y;
}
// if(count==9){
// continue y;
// }
if (sumexpert<=9) {
TPairJudgeScore pairJudgeScore=new TPairJudgeScore();
pairJudgeScore.setProcessId(businessData.getProcessId());
pairJudgeScore.setPairFirstJudgeId(ObjectUtils.toString(businessData.getId(),""));
pairJudgeScore.setPairjudgeName(businessData.getPairJudgeName());
pairJudgeScore.setPrizeLevel("");
pairJudgeScore.setMarkerDate(new Date(System.currentTimeMillis()));
pairJudgeScore.setMarkerCode(tExpertInfo[3].toString());
pairJudgeScore.setMarker(tExpertInfo[0].toString());
pairJudgeScore.setPairJudgeId(ObjectUtils.toString(businessData.getPairJudgeId(),""));
if ("成果应用奖 ".equals(businessData.getDeclarePrize())) {
pairJudgeScore.setPairJudgeType("1");
}else if("科技进步奖".equals(businessData.getDeclarePrize())){
pairJudgeScore.setPairJudgeType("2");
}else{
pairJudgeScore.setPairJudgeType("3");
}
pairJudgeScore.setDeclarePrize(businessData.getDeclarePrize());
pairJudgeScore.setType("0");
this.getPairJudgeDDao().insertIntoJudgeScore(pairJudgeScore);
count++;
}
}
}
} catch (Exception e) {
System.out.println("1111111111111111111");
e.printStackTrace();
}