Ejemplo n.º 1
0
 private void commit(UpsServicePolicyDTO serviceOrder, String userEmail) throws Exception {
   byte[] report = rpService.getUPSReport(serviceOrder);
   saveReport(serviceOrder.getServiceOrderId(), report);
   sendNotification(
       userEmail + "," + serviceOrder.getReceivedByEmail(),
       report,
       serviceOrder.getServiceOrderNumber());
 }
Ejemplo n.º 2
0
  @RequestMapping(value = "/save.do", method = RequestMethod.POST)
  public String save(
      @ModelAttribute("serviceOrder") UpsServicePolicyDTO serviceOrder,
      @ModelAttribute(Globals.SESSION_KEY_PARAM) UserSession userSession,
      ModelMap model,
      HttpServletRequest req,
      HttpServletResponse resp)
      throws Exception {

    int idServicio = 0;
    int custId = 0;
    boolean doCommit = userSession.getUser().getBelongsToGroup().get(Globals.GROUP_SERVICE) != null;

    try {
      if (serviceOrder.getServiceOrderId() != null && serviceOrder.getServiceOrderId() > 0) {
        // Actualizar orden de servicio
        Serviceorder servicioOrderSave = new Serviceorder();
        servicioOrderSave.setServiceOrderId(serviceOrder.getServiceOrderId());
        if (serviceOrder.getClosed() != null && serviceOrder.getServiceStatusId().equals("C")) {
          servicioOrderSave.setAsignee(null);
        }
        servicioOrderSave.setClosed(serviceOrder.getClosed());
        servicioOrderSave.setIsWrong(serviceOrder.getIsWrong() ? 1 : 0);
        servicioOrderSave.setStatusId(serviceOrder.getServiceStatusId());
        if (serviceOrder.getSignReceivedBy() != null
            && !serviceOrder.getSignReceivedBy().equals("")) {
          serviceOrder.setHasPdf(1);
        }
        servicioOrderSave.setHasPdf(serviceOrder.getHasPdf());
        servicioOrderSave.setSignReceivedBy(serviceOrder.getSignReceivedBy());

        service.updateServiceOrder(
            servicioOrderSave, "UpsServiceController", userSession.getUser().getUserEmail());
        idServicio = serviceOrder.getServiceOrderId();
      } else {
        if (serviceOrder.getPolicyId() == null || serviceOrder.getPolicyId() == 0) {
          // Guardando el cliente capturado
          OpenCustomer customer = new OpenCustomer();
          customer.setCustomerName(serviceOrder.getCustomer());
          customer.setContactEmail(serviceOrder.getFinalUser());
          customer.setEquipmentTypeId("U");
          customer.setBrand(serviceOrder.getBrand());
          customer.setModel(serviceOrder.getModel());
          customer.setSerialNumber(serviceOrder.getSerialNumber());
          customer.setCapacity(serviceOrder.getCapacity());
          customer.setAddress(serviceOrder.getEquipmentAddress());
          customer.setContactName(serviceOrder.getContactName());
          customer.setPhone(serviceOrder.getContactPhone());
          customer.setProject(serviceOrder.getProject());
          customer.setOfficeId(String.valueOf(serviceOrder.getOfficeId()));
          customer.setCreated(Globals.getLocalTime());
          customer.setCreatedBy("UpsServiceController");
          customer.setCreatedByUsr(userSession.getUser().getUserEmail());
          custId = ocService.SaveOpenCustomer(customer);
        }

        // Guardando la OS
        Serviceorder servicioOrderSave = new Serviceorder();
        if (custId > 0) {
          servicioOrderSave.setOpenCustomerId(custId);
        }
        servicioOrderSave.setReceivedBy(serviceOrder.getReceivedBy());
        servicioOrderSave.setReceivedByPosition(serviceOrder.getReceivedByPosition());
        servicioOrderSave.setEmployeeListString(serviceOrder.getResponsible());
        servicioOrderSave.setServiceDate(serviceOrder.getServiceDate());
        servicioOrderSave.setServiceEndDate(serviceOrder.getServiceEndDate());
        servicioOrderSave.setServiceOrderNumber(serviceOrder.getServiceOrderNumber());
        servicioOrderSave.setServiceTypeId(serviceOrder.getServiceTypeId().toCharArray()[0]);
        servicioOrderSave.setReceivedByEmail(serviceOrder.getReceivedByEmail());
        servicioOrderSave.setIsWrong(serviceOrder.getIsWrong() ? 1 : 0);
        servicioOrderSave.setSignCreated(serviceOrder.getSignCreated());
        servicioOrderSave.setSignReceivedBy(serviceOrder.getSignReceivedBy());
        if (userSession.getUser().getBelongsToGroup().get(Globals.GROUP_COORDINATOR) != null) {
          servicioOrderSave.setStatusId("E");
        } else {
          servicioOrderSave.setStatusId("N");
        }
        servicioOrderSave.setPolicyId(serviceOrder.getPolicyId());
        servicioOrderSave.setResponsible(serviceOrder.getResponsible());
        servicioOrderSave.setTicketId(serviceOrder.getTicketId());
        if (serviceOrder.getSignReceivedBy() != "") {
          servicioOrderSave.setHasPdf(1);
        } else {
          servicioOrderSave.setHasPdf(0);
        }

        idServicio =
            service.saveServiceOrder(
                servicioOrderSave, "UpsServiceController", userSession.getUser().getUserEmail());
        serviceOrder.setServiceOrderId(idServicio);
        // Crear orden de servicio de UpsService
        service.saveUpsService(
            new UpsServiceDTO(serviceOrder),
            "UpsServiceController",
            userSession.getUser().getUserName());
      }

      if (serviceOrder.getUpsServiceId() == null
          && doCommit
          && serviceOrder.getSignReceivedBy() != null
          && !serviceOrder.getSignReceivedBy().equals("")) {
        commit(serviceOrder, userSession.getUser().getUserEmail());
      }
    } catch (Exception e) {
      Logger.Log(LogLevel.ERROR, Thread.currentThread().getStackTrace()[0].toString(), e);
      e.printStackTrace();
      model.addAttribute("errorDetails", e.getMessage() + " - " + e.getStackTrace()[0].toString());
      throw e;
    }

    return "dashboard";
  }