コード例 #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";
    }
  }
コード例 #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";
  }