388 lines
11 KiB
Plaintext
Executable File
388 lines
11 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.solicitud;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.faces.bean.ManagedBean;
|
|
import javax.faces.bean.ManagedProperty;
|
|
import javax.faces.bean.ViewScoped;
|
|
|
|
import com.fp.dto.Request;
|
|
import com.fp.dto.Response;
|
|
import com.fp.dto.query.DtoQuery;
|
|
import com.fp.dto.save.DtoSave;
|
|
import com.fp.frontend.controller.AbstractController;
|
|
import com.fp.frontend.controller.armas.parametros.RequisitoController;
|
|
import com.fp.frontend.controller.pcustomer.PersonAddressController;
|
|
import com.fp.frontend.controller.pgeneral.gene.CatalogDetailController;
|
|
import com.fp.frontend.helper.MessageHelper;
|
|
import com.fp.persistence.parmas.fun.TarmSolicitudImportacion;
|
|
import com.fp.persistence.parmas.param.TarmRequisito;
|
|
import com.fp.persistence.parmas.param.TarmTramite;
|
|
import com.fp.persistence.parmas.soli.TarmOrdenTrabajo;
|
|
import com.fp.persistence.parmas.soli.TarmSolicitud;
|
|
import com.fp.persistence.parmas.soli.TarmSolicitudTramite;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCatalogDetail;
|
|
|
|
@SuppressWarnings("serial")
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class OrdenTrabajoController extends AbstractController<TarmOrdenTrabajo> {
|
|
|
|
private Date fechaHoy;
|
|
private Date inicio;
|
|
private Date fin;
|
|
private java.sql.Date fechaInicio;
|
|
private java.sql.Date fechaFin;
|
|
|
|
private TarmSolicitud solicitud=new TarmSolicitud();
|
|
private TarmSolicitudTramite solicitudTramite=new TarmSolicitudTramite();
|
|
private TarmTramite tramite=new TarmTramite();
|
|
private String usoActividad;
|
|
private Long numeroOrden;
|
|
|
|
private String documentoReferencia;
|
|
private String empresa;
|
|
private String lugarDireccion;
|
|
private String ruta;
|
|
private String tiempoEstimado;
|
|
private String observaciones;
|
|
|
|
public OrdenTrabajoController() throws Exception {
|
|
super(TarmOrdenTrabajo.class);
|
|
}
|
|
|
|
@PostConstruct
|
|
private void postconstruct() {
|
|
this.init();
|
|
// Inicializa autoconsulta
|
|
super.startQuery();
|
|
|
|
}
|
|
|
|
/**
|
|
* Incializa el controlador, cuando se esta utilizando una pagina que utliza el controlador.
|
|
*/
|
|
private void init() {
|
|
try {
|
|
recperpage = 15; // Cambiar al # reg a mirar.
|
|
lrecord = new ArrayList<>();
|
|
beanalias = "ORDENTRABAJOCONTROLLER";
|
|
|
|
fechaHoy=Calendar.getInstance().getTime();
|
|
record=new TarmOrdenTrabajo();
|
|
record.setIsnew(true);
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Crea una instancia de TgeneTransactionProcess y marca el registro como nuevo.
|
|
*
|
|
* @throws Exception
|
|
*/
|
|
@Override
|
|
public void create() throws Exception {
|
|
super.create();
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
protected void querydatabase() {
|
|
try {
|
|
//Obteniendo la solicitud
|
|
solicitud= ValidacionTramiteLibreTransitoController.findPorSolicitudSimple("1");
|
|
if(solicitud!=null && solicitud.getPk()!=null){
|
|
solicitudTramite=TarmSolicitudTramiteController.findPorCSolicitud(solicitud.getPk());
|
|
|
|
if(solicitudTramite!=null && solicitudTramite.getPk().getCtramite()!=null){
|
|
tramite=TarmTramiteController.find(solicitudTramite.getPk().getCtramite().toString());
|
|
|
|
if(tramite!=null && tramite.getPk()!=null){
|
|
//Uso actividad
|
|
TgeneCatalogDetail catalogDetailTramite=CatalogDetailController.findxCodigoCodcatalogo(solicitudTramite.getEstadotramite(), solicitudTramite.getEstadotramitecodigo());
|
|
catalogDetailTramite=CatalogDetailController.findxCodigoCodcatalogo(tramite.getUsoactividad(), tramite.getUsoactividadcodigo());
|
|
if(catalogDetailTramite!=null && tramite.getUsoactividad()!=null && tramite.getUsoactividadcodigo()!=null){
|
|
usoActividad=catalogDetailTramite.getDescription();
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
//Obteniendo el numero de orden
|
|
List<TarmOrdenTrabajo> listaOrdenes=OrdenTrabajoController.findAll();
|
|
if(listaOrdenes==null || listaOrdenes.isEmpty()){
|
|
numeroOrden=1L;
|
|
}else{
|
|
numeroOrden=listaOrdenes.get(listaOrdenes.size()-1).getPk()+1;
|
|
}
|
|
|
|
|
|
DtoQuery dto = super.getDtoQuery(true);
|
|
|
|
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
|
|
mtables.put(beanalias, dto); // permite adicionar mas de una tabla.
|
|
|
|
Request request = callerhelper.getRequest();
|
|
request.setQueryTables(mtables);
|
|
|
|
Response resp = callerhelper.executeQuery(request);
|
|
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) {
|
|
lrecord = new ArrayList<TarmOrdenTrabajo>();
|
|
MessageHelper.setMessageError(resp);
|
|
} else {
|
|
lrecord = (List<TarmOrdenTrabajo>) resp.get(beanalias);
|
|
if(!lrecord.isEmpty()){
|
|
record=lrecord.get(0);
|
|
}
|
|
super.postQuery(lrecord);
|
|
}
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
protected void querydatabaseAll() {
|
|
try {
|
|
DtoQuery dto = super.getDtoQuery(true);
|
|
|
|
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
|
|
mtables.put(beanalias, dto); // permite adicionar mas de una tabla.
|
|
|
|
Request request = callerhelper.getRequest();
|
|
request.setQueryTables(mtables);
|
|
|
|
Response resp = callerhelper.executeQuery(request);
|
|
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) {
|
|
lrecord = new ArrayList<TarmOrdenTrabajo>();
|
|
MessageHelper.setMessageError(resp);
|
|
} else {
|
|
lrecord = (List<TarmOrdenTrabajo>) resp.get(beanalias);
|
|
if(!lrecord.isEmpty()){
|
|
record=lrecord.get(0);
|
|
}
|
|
super.postQuery(lrecord);
|
|
}
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void save() {
|
|
try {
|
|
update();
|
|
|
|
DtoSave dtosave = super.getDtoSave();
|
|
dtosave.setReturnpk(true); // Para que el core devuelva el pk de los registros nuevos.
|
|
HashMap<String, DtoSave> msave = new HashMap<String, DtoSave>();
|
|
|
|
Request request = callerhelper.getRequest();
|
|
msave.put(beanalias, dtosave); // adicionar metadata de mantenimiento para cada tabla.
|
|
|
|
request.setSaveTables(msave);
|
|
Response resp = callerhelper.executeSave(request);
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) == 0) {
|
|
this.postCommit(resp);
|
|
MessageHelper.setMessageInfo(resp);
|
|
} else {
|
|
MessageHelper.setMessageError(resp);
|
|
}
|
|
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
public void update(TarmOrdenTrabajo bean) throws Exception {
|
|
record=bean;
|
|
update();
|
|
}
|
|
|
|
|
|
@Override
|
|
public void postCommit(Response response) throws Exception {
|
|
super.postCommitGeneric(response, beanalias);
|
|
}
|
|
|
|
/**
|
|
* Obtiene una orden de trabajo por su codigo
|
|
* @param cordentrabajo
|
|
* @return
|
|
*/
|
|
public static TarmOrdenTrabajo find(String cordentrabajo) {
|
|
try {
|
|
OrdenTrabajoController cc = new OrdenTrabajoController();
|
|
cc.init();
|
|
cc.recperpage = 300;
|
|
cc.addFilter("pk", cordentrabajo);
|
|
cc.querydatabase();
|
|
if (cc.record != null) {
|
|
return cc.record;
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static List<TarmOrdenTrabajo> findAll() {
|
|
try {
|
|
OrdenTrabajoController cc = new OrdenTrabajoController();
|
|
cc.init();
|
|
//cc.recperpage = 300;
|
|
cc.querydatabaseAll();
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
return cc.lrecord;
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public Date getFechaHoy() {
|
|
return fechaHoy;
|
|
}
|
|
|
|
public void setFechaHoy(Date fechaHoy) {
|
|
this.fechaHoy = fechaHoy;
|
|
}
|
|
|
|
public Date getInicio() {
|
|
return inicio;
|
|
}
|
|
|
|
public void setInicio(Date inicio) {
|
|
this.inicio = inicio;
|
|
}
|
|
|
|
public Date getFin() {
|
|
return fin;
|
|
}
|
|
|
|
public void setFin(Date fin) {
|
|
this.fin = fin;
|
|
}
|
|
|
|
public java.sql.Date getFechaInicio() {
|
|
return fechaInicio;
|
|
}
|
|
|
|
public void setFechaInicio(java.sql.Date fechaInicio) {
|
|
this.fechaInicio = fechaInicio;
|
|
}
|
|
|
|
public java.sql.Date getFechaFin() {
|
|
return fechaFin;
|
|
}
|
|
|
|
public void setFechaFin(java.sql.Date fechaFin) {
|
|
this.fechaFin = fechaFin;
|
|
}
|
|
|
|
public TarmSolicitud getSolicitud() {
|
|
return solicitud;
|
|
}
|
|
|
|
public void setSolicitud(TarmSolicitud solicitud) {
|
|
this.solicitud = solicitud;
|
|
}
|
|
|
|
public TarmSolicitudTramite getSolicitudTramite() {
|
|
return solicitudTramite;
|
|
}
|
|
|
|
public void setSolicitudTramite(TarmSolicitudTramite solicitudTramite) {
|
|
this.solicitudTramite = solicitudTramite;
|
|
}
|
|
|
|
public TarmTramite getTramite() {
|
|
return tramite;
|
|
}
|
|
|
|
public void setTramite(TarmTramite tramite) {
|
|
this.tramite = tramite;
|
|
}
|
|
|
|
public String getUsoActividad() {
|
|
return usoActividad;
|
|
}
|
|
|
|
public void setUsoActividad(String usoActividad) {
|
|
this.usoActividad = usoActividad;
|
|
}
|
|
|
|
public Long getNumeroOrden() {
|
|
return numeroOrden;
|
|
}
|
|
|
|
public void setNumeroOrden(Long numeroOrden) {
|
|
this.numeroOrden = numeroOrden;
|
|
}
|
|
|
|
public String getDocumentoReferencia() {
|
|
return documentoReferencia;
|
|
}
|
|
|
|
public void setDocumentoReferencia(String documentoReferencia) {
|
|
this.documentoReferencia = documentoReferencia;
|
|
}
|
|
|
|
public String getEmpresa() {
|
|
return empresa;
|
|
}
|
|
|
|
public void setEmpresa(String empresa) {
|
|
this.empresa = empresa;
|
|
}
|
|
|
|
public String getLugarDireccion() {
|
|
return lugarDireccion;
|
|
}
|
|
|
|
public void setLugarDireccion(String lugarDireccion) {
|
|
this.lugarDireccion = lugarDireccion;
|
|
}
|
|
|
|
public String getRuta() {
|
|
return ruta;
|
|
}
|
|
|
|
public void setRuta(String ruta) {
|
|
this.ruta = ruta;
|
|
}
|
|
|
|
public String getTiempoEstimado() {
|
|
return tiempoEstimado;
|
|
}
|
|
|
|
public void setTiempoEstimado(String tiempoEstimado) {
|
|
this.tiempoEstimado = tiempoEstimado;
|
|
}
|
|
|
|
public String getObservaciones() {
|
|
return observaciones;
|
|
}
|
|
|
|
public void setObservaciones(String observaciones) {
|
|
this.observaciones = observaciones;
|
|
}
|
|
|
|
|
|
}
|