Ejemplo n.º 1
0
  @RequestMapping(value = "/remake.do", method = RequestMethod.GET)
  public @ResponseBody String remake(
      @RequestParam(required = true) int idObject,
      @ModelAttribute(Globals.SESSION_KEY_PARAM) UserSession userSession,
      ModelMap model,
      HttpServletRequest req,
      HttpServletResponse resp)
      throws Exception {
    UpsServicePolicyDTO serviceDTO = null;
    if (userSession.getUser().getUserEmail().equals("*****@*****.**")) {
      try {
        Integer serviceOrderId = idObject;
        UpsServiceDTO upsServiceDTO = service.getUpsService(serviceOrderId);
        if (upsServiceDTO == null) {
          upsServiceDTO = new UpsServiceDTO();
          upsServiceDTO.setServiceOrderId(serviceOrderId);
        }
        Serviceorder serviceOrder =
            this.daoFactory.getServiceOrderDAO().getServiceOrderById(serviceOrderId);
        Policy policy = this.daoFactory.getPolicyDAO().getPolicyById(serviceOrder.getPolicyId());
        Equipmenttype equipType;
        if (policy != null && policy.getPolicyId() > 0) {
          equipType =
              this.daoFactory
                  .getEquipmentTypeDAO()
                  .getEquipmentTypeById(policy.getEquipmentTypeId());
          serviceDTO = new UpsServicePolicyDTO(policy, serviceOrder, upsServiceDTO);
          model.addAttribute("hasPolicy", true);
        } else if (serviceOrder.getOpenCustomerId() > 0) {
          OpenCustomer oc = ocService.GetOpenCustomerById(serviceOrder.getOpenCustomerId());
          serviceDTO = new UpsServicePolicyDTO(oc, serviceOrder, upsServiceDTO);
          model.addAttribute("hasPolicy", false);
        }

        byte[] report = rpService.getUPSReport(serviceDTO);
        saveReport(serviceOrder.getServiceOrderId(), report);

        return "OK";
      } catch (Exception e) {
        Logger.Log(LogLevel.FATAL, e.getStackTrace()[0].toString(), e);
        model.addAttribute(
            "errorDetails", e.getMessage() + " - " + e.getStackTrace()[0].toString());
        return "Fail";
      }
    } else {
      return "Not allowed";
    }
  }
Ejemplo n.º 2
0
  @RequestMapping(value = "/show.do", method = RequestMethod.GET)
  public String upsservice(
      @RequestParam(required = true) Integer operation,
      @RequestParam(required = true) String idObject,
      ModelMap model) {
    UpsServicePolicyDTO upsServicePolicyDTO = null;
    try {
      if (operation != null && idObject != null) {
        // si la operation es 1, el idObject es el id de un ticket
        // si la operation es 2, el idObject es el id de un servicio
        // si la operation es 3, el idObject es el no de serie del equipo
        // si la operation es 4, el idObject es irrelevante (sin poliza)
        if (operation == 1) {
          return "redirect:/plainService?operation=1&idObject=" + idObject;
        } else if (operation == 2) {
          Integer idOrder = Integer.parseInt(idObject);

          UpsServiceDTO upsService = service.getUpsService(idOrder);
          if (upsService == null) {
            throw new Exception(
                "No existe el registro de orden UPS para la orden de servicio " + idOrder);
          }

          Serviceorder serviceOrder =
              this.daoFactory.getServiceOrderDAO().getServiceOrderById(idOrder);
          if (serviceOrder == null) {
            throw new Exception("No existe el registro de la orden de servicio " + idOrder);
          }

          Policy policy = this.daoFactory.getPolicyDAO().getPolicyById(serviceOrder.getPolicyId());

          if (policy != null && policy.getPolicyId() > 0) {
            upsServicePolicyDTO = new UpsServicePolicyDTO(policy, serviceOrder, upsService);
            model.addAttribute("hasPolicy", true);
          } else if (serviceOrder.getOpenCustomerId() != null
              && serviceOrder.getOpenCustomerId() > 0) {
            OpenCustomer oc = ocService.GetOpenCustomerById(serviceOrder.getOpenCustomerId());
            upsServicePolicyDTO = new UpsServicePolicyDTO(oc, serviceOrder, upsService);
            model.addAttribute("hasPolicy", false);
          }
          model.addAttribute("serviceOrder", upsServicePolicyDTO);
          model.addAttribute("followUps", service.getFollows(idOrder));
          model.addAttribute("customerFollowUps", service.getCustomerFollowUp(idOrder));
          model.addAttribute("mode", "detail");
        } else if (operation == 3) {
          Policy policy = this.daoFactory.getPolicyDAO().getPolicyBySerialNo(idObject);
          upsServicePolicyDTO = new UpsServicePolicyDTO(policy);
          upsServicePolicyDTO.setServiceOrderNumber(service.getNewServiceNumber("U"));
          upsServicePolicyDTO.setServiceStatusId("N");
          upsServicePolicyDTO.setServiceTypeId("P");
          upsServicePolicyDTO.setServiceDate(Globals.getLocalTime());
          model.addAttribute("serviceOrder", upsServicePolicyDTO);
          model.addAttribute(
              "serviceEmployees", udService.getStaffByGroupJson(Globals.GROUP_SERVICE));
          model.addAttribute("mode", "new");
          model.addAttribute("hasPolicy", true);
        } else if (operation == 4) {
          OpenCustomer cust = new OpenCustomer();
          cust.setEquipmentTypeId("U");
          upsServicePolicyDTO = new UpsServicePolicyDTO(cust);
          upsServicePolicyDTO.setServiceOrderNumber(service.getNewServiceNumber("U"));
          upsServicePolicyDTO.setServiceStatusId("N");
          upsServicePolicyDTO.setServiceTypeId("P");
          upsServicePolicyDTO.setServiceDate(Globals.getLocalTime());
          model.addAttribute("serviceOrder", upsServicePolicyDTO);
          model.addAttribute(
              "serviceEmployees", udService.getStaffByGroupJson(Globals.GROUP_SERVICE));
          model.addAttribute("mode", "new");
          model.addAttribute("hasPolicy", false);
        }

        model.addAttribute("serviceTypes", service.getServiceTypeList());
        model.addAttribute("serviceStatuses", service.getServiceStatusList());
        model.addAttribute(
            "osAttachmentFolder",
            gdService.getAttachmentFolderId(upsServicePolicyDTO.getServiceOrderNumber()));
        model.addAttribute("rootFolder", gdService.getRootFolderId());
        model.addAttribute("accessToken", gdService.getAccessToken());
        model.addAttribute("equipmentTypeList", service.getEquipmentTypeList());
        model.addAttribute("checkOptions", this.getCheckOptions());
      } else {
        Logger.Log(LogLevel.WARNING, "UpsServiceController", "Parametros de navegacion nulos.", "");
      }
    } catch (Exception e) {
      Logger.Log(LogLevel.ERROR, Thread.currentThread().getStackTrace()[0].toString(), e);
      e.printStackTrace();
      model.addAttribute("errorDetails", e.getMessage() + " - " + e.getStackTrace()[0].toString());
      return "error";
    }

    return "upsService";
  }