-
-
玳玳我 小试身手Lv3
发表于2021-8-8 02:42
在填报任务设计中,会设置任务的报表期,比如周报是一周一报,月报是一月一报,那么在此基础上如何限制用户的填报时间呢? 比如周报限制报表户必须在周五、周六、周日时才能填报,月报限制在当月29号之前完成填报
在任务的属性-》报表期设置-》最佳报表期脚本里可以设置填报任务的最佳报表期

2个回答
本帖最后由 v笑向前走 于 2022-7-14 14:33 编辑
月报--> 每月只有指定时间段可以填(最佳报表期为前一个月)
import java.util.Calendar;
import com.esen.ei.bbq.BbqFuncs;
import com.esen.ei.rp.Task;
import com.esen.ei.server.IReportServer;
import com.esen.util.StrFunc;
boolean allowOnlineFill = StrFunc.str2boolean(task.getProperty("allowOnlineFill","true"));
Calendar cal = Calendar.getInstance();
int dd = cal.get(Calendar.DATE); // 获取天
int startDate = 5; // 允许填报日期区间,开始于每月第几天
int endDate = 15; // 允许填报日期区间,结束于每月第几天
try {
if (dd >= startDate && dd <= endDate) { // 在允许填报的日期范围内
if (!allowOnlineFill) { // 如果任务当前不允许填报,那么需要设置为可填报
task.setProperty("allowOnlineFill", "true");
task.getServerPpt().saveProperties(); // 保存任务允许填报服务器属性
System.out.println("更新任务" + task.getCaption() + "(" + task.getServerId() + ")允许填报");
}
System.out.println("今天(" + StrFunc.formatDateTime(cal.getTime()) + ")允许填报任务" + task.getCaption() + "(" + task.getServerId() + ")");
} else { // 不在允许填报的日期范围内,且允许填报,需要设置为不允许填报
if (allowOnlineFill) {
task.setProperty("allowOnlineFill", "false");
task.getServerPpt().saveProperties(); // 保存任务允许填报服务器属性
System.out.println("更新任务" + task.getCaption() + "(" + task.getServerId() + ")不允许填报");
}
System.out.println("今天(" + StrFunc.formatDateTime(cal.getTime()) + ")不允许填报任务" + task.getCaption() + "(" + task.getServerId() + ")");
}
} catch (Exception e) {
e.printStackTrace();
}
bestBbq = BbqFuncs.getBestBbq(task.getBbqType(), task);
本帖最后由 v笑向前走 于 2022-7-14 14:45 编辑
月报:填写当前月指定时间可填写(最佳报表期为当月)
import java.util.Calendar;
import com.esen.ei.bbq.BbqFuncs;
import com.esen.ei.rp.Task;
import com.esen.ei.server.IReportServer;
import com.esen.util.StrFunc;
boolean allowOnlineFill = StrFunc.str2boolean(task.getProperty("allowOnlineFill","true"));
Calendar cal = Calendar.getInstance();
int dd = cal.get(Calendar.DATE); // 获取天
int startDate = 1; // 允许填报日期区间,开始于每月第几天
int endDate = 5; // 允许填报日期区间,结束于每月第几天
try {
if (dd >= startDate && dd <= endDate) { // 在允许填报的日期范围内
if (!allowOnlineFill) { // 如果任务当前不允许填报,那么需要设置为可填报
task.setProperty("allowOnlineFill", "true");
task.getServerPpt().saveProperties(); // 保存任务允许填报服务器属性
System.out.println("更新任务" + task.getCaption() + "(" + task.getServerId() + ")允许填报");
}
System.out.println("今天(" + StrFunc.formatDateTime(cal.getTime()) + ")允许填报任务" + task.getCaption() + "(" + task.getServerId() + ")");
} else { // 不在允许填报的日期范围内,且允许填报,需要设置为不允许填报
if (allowOnlineFill) {
task.setProperty("allowOnlineFill", "false");
task.getServerPpt().saveProperties(); // 保存任务允许填报服务器属性
System.out.println("更新任务" + task.getCaption() + "(" + task.getServerId() + ")不允许填报");
}
System.out.println("今天(" + StrFunc.formatDateTime(cal.getTime()) + ")不允许填报任务" + task.getCaption() + "(" + task.getServerId() + ")");
}
} catch (Exception e) {
e.printStackTrace();
}
int day = cal.get(java.util.Calendar.DAY_OF_MONTH);
int year = cal.get(java.util.Calendar.YEAR);
int month = cal.get(java.util.Calendar.MONTH);
month = month +1;
bestBbq = year + "" + ((month < 10) ? ("0"+ month) : (""+month)) + "--";