Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @GetMapping(value = "getListTask")
- public List<HashMap<String, Object>> getListTask(
- @AuthenticationPrincipal Worker w,
- @RequestParam(value = "date_start", required = false) String startDate,
- @RequestParam(value = "date_stop", required = false) String stopDate,
- @RequestParam(value = "status", required = false) List<String> status,
- @RequestParam(value = "group_exe", required = false) List<UUID> group,
- @RequestParam(value = "company", required = false) List<UUID> company,
- @RequestParam(value = "view_tax", required = false) List<String> viewTax,
- @RequestParam(value = "object", required = false) List<String> obj,
- @RequestParam(value = "watcher", required = false) List<UUID> watcher,
- @RequestParam(value = "controller", required = false) List<UUID> controller,
- @RequestParam(value = "view_task", required = false) List<String> viewTask,
- @RequestParam(value = "subsidiary",required = false) List<UUID> subs,
- @RequestParam(required = false) List<String> kpp,
- @RequestParam(required = false) boolean global) {
- LocalDate start = startDate.equals("") ? LocalDate.now().minusMonths(3) : global ? LocalDate.parse(startDate).withDayOfMonth(1) : LocalDate.parse(startDate);
- LocalDate end = stopDate.equals("") ? LocalDate.now().plusMonths(3) : global ? start.withDayOfMonth(start.lengthOfMonth()) : LocalDate.parse(stopDate);
- ArrayList<TaskCalendar> taskCalendar = serviceTaskCalendar.findAllByDate(start, end);
- Iterator<TaskCalendar> itr = taskCalendar.listIterator();
- while (itr.hasNext()) {
- TaskCalendar task = itr.next();
- if (!w.isUserHaveRole("ROLE_CALENDAR_HEAD") && !w.isUserHaveRole("ROLE_CALENDAR_FORM") &&
- !w.isUserHaveRole("ROLE_CALENDAR_WATCHER") && !w.isUserHaveRole("ROLE_CALENDAR_MANAGEMENT"))
- if (!task.getIdDepartment().equals(w.getId_department())) {
- itr.remove();
- continue;
- }
- if (subs != null && subs.size() > 0) {
- if (!subs.contains(task.getIdSubsidiary())){
- itr.remove();
- continue;
- }
- }
- if (status != null && status.size() > 0)
- if (!status.contains(task.getStatus())) {
- itr.remove();
- continue;
- }
- if (viewTask != null && viewTask.size() > 0)
- if (!viewTask.contains(task.getTypeNotification())) {
- itr.remove();
- continue;
- }
- if (!w.isUserHaveRole("ROLE_CALENDAR_CONTROLLER") && !w.isUserHaveRole("ROLE_CALENDAR_WATCHER") &&
- w.isUserHaveRole("ROLE_CALENDAR_EXECUTOR") && (group == null || group.size() == 0))
- group = serviceListExecutor.getGroupWorker(w.getId());
- if (group != null && group.size() > 0)
- if (!group.contains(task.getGroupExecutor())) {
- itr.remove();
- continue;
- }
- if (company != null && company.size() > 0)
- if (!company.contains(task.getIdSubsidiary())) {
- itr.remove();
- continue;
- }
- if (viewTax != null && viewTax.size() > 0)
- if (!viewTax.contains(task.getViewTax())) {
- itr.remove();
- continue;
- }
- if (obj != null && obj.size() > 0)
- if (!obj.contains(task.getNumObject())) {
- itr.remove();
- continue;
- }
- if (kpp != null && kpp.size() > 0)
- if (!kpp.contains(task.getKpp())) {
- itr.remove();
- continue;
- }
- }
- return serviceTaxCalendar.getListTask(taskCalendar);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement