@Override public String processService() throws GenericFacadeException, InvalidOperationException, OperationNotAllowedException { ServiceValue serviceValue = treatHeader(); treatDetails(serviceValue); String client = getMetaForIntegrationValue(getEntity().getClientCode(), MetaNames.CLIENT); Long ref = serviceValue.getServicevalueCod(); returnMessage = getFacadeContainer().getI18nAPI().iValue(tranType.getSuccessMessage()); returnMessage = MessageFormat.format(returnMessage, client, ref); addRouteDetail(getUserphone(), getMessage().getCell()); return returnMessage; }
@Override protected ServiceValue treatHeader() { ServiceValue serviceValue = null; serviceValue = new ServiceValue(); serviceValue.setService(getService()); serviceValue.setUserphone(getUserphone()); serviceValue.setMessage(getMessage()); serviceValue.setRecorddateDat(validateDate()); serviceValue.setColumn1Chr(getEntity().getClientCode()); serviceValue.setColumn2Chr(getEntity().getObservation()); serviceValue = getFacadeContainer().getServiceValueAPI().create(serviceValue); return serviceValue; }
public List<ServiceResult> lastMarks(Id service, Userphone userphone, Integer cant) { List<ServiceResult> result = new ArrayList<ServiceResult>(); EntityManager em = null; String mark = null; List<ServiceValue> svList = null; List<ServiceValueDetail> svdList = null; try { switch (service) { /* * COLUMN1 = EVENTO (ENT, SAL, ENTSAL) * COLUMN2 = CLIENTE * */ case VISITA: case VISITA_PEDIDO: svdList = getServiceValueDetailList( " AND (o.column1Chr = 'ENT' OR o.column1Chr = 'ENTSAL') ", userphone.getUserphoneCod(), service.value(), cant); if (svdList != null) { mark = null; for (ServiceValueDetail svd : svdList) { MetaData md = getFacadeContainer() .getMetaDataAPI() .findByClientMetaMemberAndCode( userphone.getClient().getClientCod(), MetaNames.CLIENT.value(), 1L, svd.getColumn2Chr()); String retValue = ""; if (md != null) { retValue = md.getValueChr(); } mark = formatResult( svd.getColumn2Chr(), retValue, svd.getRecorddateDat(), "dd-MM-yy HH:mm"); ServiceResult sr = new ServiceResult(); sr.setResult(mark); sr.setServiceValueDetail(svd); result.add(sr); } } break; /* * COLUMN1 = COD CLIENTE * */ case PEDIDO: svList = getServiceValueList( " AND (o.column9Chr = '0' OR o.column9Chr IS NULL) ", userphone.getUserphoneCod(), service.value(), cant); if (svList != null) { mark = null; for (ServiceValue sv : svList) { MetaData md = getFacadeContainer() .getMetaDataAPI() .findByClientMetaMemberAndCode( userphone.getClient().getClientCod(), MetaNames.CLIENT.value(), 1L, sv.getColumn1Chr()); String retValue = ""; if (md != null) { retValue = md.getValueChr(); } mark = formatResult( sv.getColumn1Chr(), retValue, sv.getMessage().getDateinDat(), "dd-MM-yy HH:mm"); ServiceResult sr = new ServiceResult(); sr.setResult(mark); sr.setServiceValue(sv); result.add(sr); } } break; /* * COLUMN1 = COD CLIENTE */ case COBRANZA: svList = getServiceValueList("", userphone.getUserphoneCod(), service.value(), cant); if (svList != null) { mark = null; for (ServiceValue sv : svList) { MetaData md = getFacadeContainer() .getMetaDataAPI() .findByClientMetaMemberAndCode( userphone.getClient().getClientCod(), MetaNames.CLIENT.value(), 1L, sv.getColumn1Chr()); String retValue = ""; if (md != null) { retValue = md.getValueChr(); } mark = formatResult( sv.getColumn1Chr(), retValue, sv.getMessage().getDateinDat(), "dd-MM-yy HH:mm"); ServiceResult sr = new ServiceResult(); sr.setResult(mark); sr.setServiceValue(sv); result.add(sr); } } break; /* * COLUMN1 = DEPOSITO * COLUMN2 = COD CLIENTE * COLUMN3 = CANTIDAD */ case INVENTARIO_STANDARD: svdList = getServiceValueDetailList("", userphone.getUserphoneCod(), service.value(), cant); if (svdList != null) { mark = null; for (ServiceValueDetail svd : svdList) { MetaData md = getFacadeContainer() .getMetaDataAPI() .findByClientMetaMemberAndCode( userphone.getClient().getClientCod(), MetaNames.PRODUCT.value(), 1L, svd.getColumn2Chr()); String retValue = ""; if (md != null) { retValue = md.getValueChr(); } mark = formatResult( svd.getColumn2Chr(), retValue, svd.getRecorddateDat(), "dd-MM-yy HH:mm"); ServiceResult sr = new ServiceResult(); sr.setResult(mark); sr.setServiceValueDetail(svd); result.add(sr); } } break; /* * COLUMN1 = NOMBRE PERSONA QEU RECIBIO */ case COURRIER: svList = getServiceValueList("", userphone.getUserphoneCod(), service.value(), cant); if (svList != null) { mark = null; for (ServiceValue sv : svList) { if (sv.getColumn1Chr() != null) { mark = formatResult( sv.getColumn1Chr(), "", sv.getMessage().getDateinDat(), "dd-MM-yy HH:mm"); } else { MetaData md = getFacadeContainer() .getMetaDataAPI() .findByClientMetaMemberAndCode( userphone.getClient().getClientCod(), MetaNames.MOTIVE.value(), 1L, sv.getColumn3Chr()); String retValue = ""; if (md != null) { retValue = md.getValueChr(); } mark = formatResult( sv.getColumn3Chr(), retValue, sv.getMessage().getDateinDat(), "dd-MM-yy HH:mm"); } ServiceResult sr = new ServiceResult(); sr.setResult(mark); sr.setServiceValue(sv); result.add(sr); } } break; /* * COLUMN1 = CHOFER */ case FLOTA: svList = getServiceValueList("", userphone.getUserphoneCod(), service.value(), cant); if (svList != null) { mark = null; for (ServiceValue sv : svList) { MetaData md = getFacadeContainer() .getMetaDataAPI() .findByClientMetaMemberAndCode( userphone.getClient().getClientCod(), MetaNames.EMPLOYEE.value(), 1L, sv.getColumn1Chr()); String retValue = ""; if (md != null) { retValue = md.getValueChr(); } mark = formatResult( sv.getColumn1Chr(), retValue, sv.getMessage().getDateinDat(), "dd-MM-yy HH:mm"); ServiceResult sr = new ServiceResult(); sr.setResult(mark); sr.setServiceValue(sv); result.add(sr); } } break; /* COLUMN1 = COD SANATORIO * COLUMN2 = COD MEDICO */ case VISITA_MEDICA: svList = getServiceValueList( " AND o.column3Chr = 'ME' ", userphone.getUserphoneCod(), service.value(), cant); if (svList != null) { mark = null; for (ServiceValue sv : svList) { MetaData md = getFacadeContainer() .getMetaDataAPI() .findByClientMetaMemberAndCode( userphone.getClient().getClientCod(), MetaNames.MEDIC.value(), 1L, sv.getColumn2Chr()); String retValue = ""; if (md != null) { retValue = md.getValueChr(); } mark = formatResult( sv.getColumn2Chr(), retValue, sv.getMessage().getDateinDat(), "dd-MM-yy HH:mm"); ServiceResult sr = new ServiceResult(); sr.setResult(mark); sr.setServiceValue(sv); result.add(sr); } } break; /* * COLUMN1 = NOMBRE PERSONA QEU RECIBIO */ case DELIVERY: svList = getServiceValueList("", userphone.getUserphoneCod(), service.value(), cant); if (svList != null) { mark = null; for (ServiceValue sv : svList) { MetaData md = getFacadeContainer() .getMetaDataAPI() .findByClientMetaMemberAndCode( userphone.getClient().getClientCod(), MetaNames.CLIENT.value(), 1L, sv.getColumn1Chr()); String retValue = ""; if (md != null) { retValue = md.getValueChr(); } mark = formatResult( sv.getColumn1Chr(), retValue, sv.getMessage().getDateinDat(), "dd-MM-yy HH:mm"); ServiceResult sr = new ServiceResult(); sr.setResult(mark); sr.setServiceValue(sv); result.add(sr); } } break; default: break; } return result; } catch (Exception e) { return null; } finally { if (em != null && getFacadeContainer().isEntityManagerTransactional()) { em.close(); } } }