String hour = request.getParameter("hour[]");
String minute = request.getParameter("minute[]");
String recievers = request.getParameter("recievers");
params = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + params;
TimerAction timerAction = null;
Timer timer = null;
if (statId == null || statId.equals("")) {
//新创建
timerAction = das.createTimerAction();
timerAction.setClassName("com.sogou.qadev.service.cynthia.service.StatisticerManager");
timerAction.setMethod("execute");
timerAction.setName(statName);
timerAction.setCreateUser(key.getUsername());
timerAction.setParam(params);
if (isSendMail != null && isSendMail.equals("true") && recievers != null && !recievers.equals("")) {
timer = das.createTimer(key.getUsername());
timer.setActionId(timerAction.getId());
timer.setActionParam(timerAction.getParam());
timer.setName(timerAction.getName());
timer.setRetry(true);
timer.setRetryAccount(5);
timer.setRetryDelay(50000);
timer.setSendNull(true);
timer.setStart(true);
timer.setMonth(CommonUtil.arrayToStr(month));
timer.setWeek(CommonUtil.arrayToStr(week));
timer.setDay(CommonUtil.arrayToStr(date));
timer.setHour(hour);
timer.setMinute(minute);
das.addTimer(timer);
}
return String.valueOf(das.addTimerAction(timerAction).equals(ErrorCode.success));
}else {
timerAction = das.queryTimerAction(DataAccessFactory.getInstance().createUUID(statId));
//更新统计
timerAction.setName(statName);
timerAction.setParam(params);
Timer[] timerArray = das.queryTimersByActionId(timerAction.getId());
if (timerArray.length > 0) {
//己存在定时器更新定时器
for(int i = 0; i < timerArray.length; i++){
if(timerArray[i].getActionId().toString().equals(timerAction.getId().toString())){
timer = timerArray[i];
timer.setActionParam(timerAction.getParam());
timer.setName(timerAction.getName());
if (isSendMail != null && isSendMail.equals("false")) {
//时间为空则直接删除timer
das.removeTimer(timer.getId());
}else {
//否则更新timer时间
timer.setMonth(CommonUtil.arrayToStr(month));
timer.setWeek(CommonUtil.arrayToStr(week));
timer.setDay(CommonUtil.arrayToStr(date));
timer.setHour(hour);
timer.setMinute(minute);
das.modifyTimer(timer);
}
break;
}
}
}else {
//不存在,创建定时器
if (isSendMail != null && isSendMail.equals("true") && recievers != null && !recievers.equals("")) {
timer = das.createTimer(key.getUsername());
timer.setActionId(timerAction.getId());
timer.setActionParam(timerAction.getParam());
timer.setName(timerAction.getName());
timer.setRetry(true);
timer.setRetryAccount(5);
timer.setRetryDelay(50000);
timer.setSendNull(true);
timer.setStart(true);