931 lines
38 KiB
Plaintext
Executable File
931 lines
38 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.solicitud;
|
|
|
|
import java.sql.Date;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.Calendar;
|
|
import java.util.Collections;
|
|
import java.util.Comparator;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.faces.bean.ManagedBean;
|
|
import javax.faces.bean.ManagedProperty;
|
|
import javax.faces.bean.ViewScoped;
|
|
import javax.faces.context.FacesContext;
|
|
|
|
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.CentroControlArmasController;
|
|
import com.fp.frontend.controller.armas.parametros.TarmCentroControlJurController;
|
|
import com.fp.frontend.controller.pcustomer.PersonAddressController;
|
|
import com.fp.frontend.controller.pcustomer.PersonDetailController;
|
|
import com.fp.frontend.controller.pgeneral.gene.CatalogDetailController;
|
|
import com.fp.frontend.controller.pgeneral.gene.ParametersController;
|
|
import com.fp.frontend.helper.MessageHelper;
|
|
import com.fp.frontend.utility.MsgControlArmas;
|
|
import com.fp.frontend.utility.MsgGeneral;
|
|
import com.fp.persistence.parmas.ins.TarmPlanificacionInspeccion;
|
|
import com.fp.persistence.parmas.ins.TarmPlanificacionTramite;
|
|
import com.fp.persistence.parmas.param.TarmCentroControl;
|
|
import com.fp.persistence.parmas.param.TarmCentroControlJur;
|
|
import com.fp.persistence.parmas.param.TarmTramite;
|
|
import com.fp.persistence.parmas.soli.TarmDocumentoHabilitante;
|
|
import com.fp.persistence.parmas.soli.TarmSolicitudDocumento;
|
|
import com.fp.persistence.pcustomer.gene.TcustPersonAddress;
|
|
import com.fp.persistence.pcustomer.gene.TcustPersonDetail;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCatalogDetail;
|
|
import com.fp.persistence.pgeneral.gene.TgeneParameters;
|
|
import com.fp.persistence.pgeneral.safe.TsafeUserDetail;
|
|
|
|
@SuppressWarnings("serial")
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class PlanificacionInspeccionController extends AbstractController<TarmPlanificacionInspeccion> {
|
|
|
|
private TarmCentroControl centroControl;
|
|
|
|
TgeneCatalogDetail actividad = null;
|
|
private String meses;
|
|
private String Periodo;
|
|
private List<TgeneCatalogDetail> tipoplanificacionList;
|
|
private String idPlanificacion;
|
|
|
|
private List<String> listaPeriodo = new ArrayList<String>();
|
|
private String nombreCentroControl;
|
|
|
|
private Boolean planificacionSalvada = false;
|
|
|
|
private Boolean planificacionGenerada = false;
|
|
|
|
private Boolean habilitarGeneracion = false;
|
|
|
|
private Boolean planificacionesPrevias = false;
|
|
|
|
private TarmCentroControlJur jurisdiccionCentroControl;
|
|
|
|
// Codigo de planificacion (Variable de flujo)
|
|
private Long cplanificacion;
|
|
|
|
private Float presupuesto1;
|
|
|
|
private List<String> listaMeses = new ArrayList<String>();
|
|
|
|
private List<Long> listaAnnos = new ArrayList<Long>();
|
|
|
|
List<TarmPlanificacionInspeccion> planificaciones;
|
|
|
|
@ManagedProperty(value = "#{planificacionTramiteController}")
|
|
private PlanificacionTramiteController planificacionTramiteController;
|
|
|
|
@ManagedProperty(value = "#{documentoHabilitanteController}")
|
|
private DocumentoHabilitanteController documentoHabilitanteController;
|
|
|
|
@ManagedProperty(value = "#{personAddressController}")
|
|
private PersonAddressController personAddressController;
|
|
|
|
private Boolean btnFlujo;
|
|
private String codigoPlanificacion;
|
|
/**
|
|
* codigo de la provincia del usuario logeado
|
|
*/
|
|
private String cprovincia;
|
|
public PlanificacionInspeccionController() throws Exception {
|
|
super(TarmPlanificacionInspeccion.class);
|
|
// TODO Auto-generated constructor stub
|
|
}
|
|
|
|
@PostConstruct
|
|
private void postconstruct() {
|
|
this.init();
|
|
super.startQuery();
|
|
}
|
|
|
|
private void init() {
|
|
try {
|
|
recperpage = 15; // Cambiar al # reg a mirar.
|
|
lrecord = new ArrayList<>();
|
|
record = new TarmPlanificacionInspeccion();
|
|
beanalias = "PLANIFICACIONINSPECCIONCONTROLLER";
|
|
btnFlujo=Boolean.FALSE;
|
|
// Obteniendo el centro de control
|
|
TsafeUserDetail tsafeUserDetail = (TsafeUserDetail) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
|
PersonAddressController direccion = new PersonAddressController();
|
|
TcustPersonAddress tcustPersonAddres = direccion.findPrincipal(tsafeUserDetail.getPk().getPersoncode().toString());
|
|
this.jurisdiccionCentroControl = TarmCentroControlJurController.findxProvincia(tcustPersonAddres.getProvincecode());
|
|
this.centroControl = CentroControlArmasController.findPorCodigo(this.jurisdiccionCentroControl.getCcentrocontrol());
|
|
this.nombreCentroControl = CatalogDetailController.findxCodigoCodcatalogo(centroControl.getNombreinstitucion(),centroControl.getNombreinstitucioncodigo()).getDescription();
|
|
//codigo de la provincia del centro de control logeado
|
|
cprovincia=centroControl.getProvincecode();
|
|
|
|
// cargar tipo de planificacion
|
|
tipoplanificacionList = CatalogDetailController.find("TIPOPLANIFICACION");
|
|
// Fecha de generacion
|
|
Calendar calendar = Calendar.getInstance();
|
|
this.record.setFechageneracion(new Date(calendar.getTimeInMillis()));
|
|
|
|
// Generando los annos posibles
|
|
planificaciones = PlanificacionInspeccionController.findAllByCentroControl(this.centroControl.getPk());
|
|
Integer canno = Calendar.getInstance().get(Calendar.YEAR);
|
|
if (planificaciones != null && !planificaciones.isEmpty()) {
|
|
this.planificacionesPrevias = true;
|
|
//this.record.setAnno(Long.parseLong(canno.toString()));
|
|
this.listaAnnos.add(Long.parseLong(canno.toString()));
|
|
|
|
} else {
|
|
this.planificacionesPrevias = false;
|
|
this.listaAnnos.add(Long.parseLong(canno.toString()));
|
|
canno++;
|
|
this.listaAnnos.add(Long.parseLong(canno.toString()));
|
|
}
|
|
|
|
this.planificacionTramiteController = new PlanificacionTramiteController();
|
|
this.planificacionTramiteController.setLrecord(new ArrayList<TarmPlanificacionTramite>());
|
|
|
|
this.documentoHabilitanteController = new DocumentoHabilitanteController();
|
|
this.documentoHabilitanteController.setLrecord(new ArrayList<TarmDocumentoHabilitante>());
|
|
|
|
//validamos si viene del flujo
|
|
if(cplanificacion!=null){
|
|
TarmPlanificacionInspeccion planificacion=PlanificacionInspeccionController.findPorCodigo(cplanificacion);
|
|
if(planificacion!=null){
|
|
if("N".equals(planificacion.getAprobada())){
|
|
//listamos la planificacion en estado Negado
|
|
this.planificacionTramiteController.setLrecord(new ArrayList<TarmPlanificacionTramite>());
|
|
this.planificacionTramiteController.setLrecord(PlanificacionTramiteController.findPorCodigoPlanificacion(cplanificacion));
|
|
Collections.sort(planificacionTramiteController.getLrecord(), new Comparator<TarmPlanificacionTramite>() {
|
|
public int compare(TarmPlanificacionTramite p1, TarmPlanificacionTramite p2) {
|
|
return new Integer(Integer.parseInt(p1.getModifiedData().get("ordena").toString())).compareTo(new Integer(p2.getModifiedData().get("ordena").toString()));
|
|
}
|
|
});
|
|
}
|
|
MessageHelper.setMessageInfo(MsgControlArmas.getProperty("msg_existePlanificacionAnno"));
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void query() throws Exception {
|
|
// TODO Auto-generated method stub
|
|
MessageHelper.setMessageError("msg_notQuery");
|
|
super.query();
|
|
}
|
|
|
|
@Override
|
|
public void create() throws Exception {
|
|
super.create();
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
protected void querydatabase() {
|
|
try {
|
|
DtoQuery dto = super.getDtoQuery(true);
|
|
dto.setOrderby("anno desc");
|
|
|
|
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<TarmPlanificacionInspeccion>();
|
|
MessageHelper.setMessageError(resp);
|
|
} else {
|
|
lrecord = (List<TarmPlanificacionInspeccion>) resp.get(beanalias);
|
|
if (!lrecord.isEmpty()) {
|
|
// record=lrecord.get(0);
|
|
}
|
|
super.postQuery(lrecord);
|
|
}
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void save() {
|
|
try {
|
|
|
|
if (this.planificacionGenerada) {
|
|
int i = 0;
|
|
float pre=0;
|
|
float tot = this.presupuesto1;
|
|
for (TarmPlanificacionTramite tramite : planificacionTramiteController.getLrecord()) {
|
|
i++;
|
|
if (tramite.getInspectores()==null || tramite.getPeriodo()==null || tramite.getVehiculos()==null || tramite.getPresupuesto()==null){
|
|
MessageHelper.setMessageError("ERROR deben estar todos los campos llenos");
|
|
return;
|
|
}
|
|
|
|
|
|
pre=pre+tramite.getPresupuesto();
|
|
|
|
|
|
|
|
}
|
|
|
|
// MessageHelper.setMessageError(""+pre);
|
|
|
|
|
|
if (pre > tot){
|
|
MessageHelper.setMessageError("ERROR Valor : "+tot+"es menor que : "+pre);
|
|
return;
|
|
}
|
|
//MessageHelper.setMessageError("ERROR "+i);
|
|
//break;
|
|
//Asignando el centro de control
|
|
this.record.setCcentrocontrol(this.centroControl.getPk());
|
|
|
|
// tipo de planificacion codigo
|
|
this.record.setIdPlanificacion(this.idPlanificacion);
|
|
|
|
// tipo de planificacion catalogo
|
|
this.record.setPlanificacion("TIPOPLANIFICACION");
|
|
|
|
// presupuesto
|
|
|
|
this.record.setPresupuesto(this.presupuesto1);
|
|
|
|
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);
|
|
|
|
request.getModifiedData().put("PLANIFICACION", this.record);
|
|
codigoPlanificacion=this.record.getCodigo();
|
|
request.getModifiedData().put("INSPECCIONES", this.planificacionTramiteController.getLrecord());
|
|
|
|
Response resp = callerhelper.executeSave(request);
|
|
|
|
this.cplanificacion = (Long) resp.get("CPLANIFICACION");
|
|
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) == 0) {
|
|
this.postCommit(resp);
|
|
this.planificacionTramiteController.postCommit(resp);
|
|
MessageHelper.setMessageInfo(resp);
|
|
this.planificacionSalvada = true;
|
|
btnFlujo=Boolean.TRUE;
|
|
} else {
|
|
// MessageHelper.setMessageError(resp);
|
|
// this.planificacionSalvada=false;
|
|
}
|
|
} else {
|
|
// MessageHelper.setMessageError(new Exception(MsgControlArmas.getProperty("msg_planificacionNoGenerada")));
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void postCommit(Response response) throws Exception {
|
|
super.postCommitGeneric(response, beanalias);
|
|
}
|
|
|
|
/**
|
|
* Metodo que inicia el flujo
|
|
*/
|
|
@Override
|
|
public void iniciarFlujo() {
|
|
try {
|
|
if(cplanificacion==null || cplanificacion==0){
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_error_generarlaplanificacion"));
|
|
return;
|
|
}
|
|
Request request = this.callerhelper.getRequest();
|
|
super.cleanRequest(request);
|
|
// Iniciando el flujo
|
|
request.modifiedData().put("cplanificacion", this.cplanificacion);
|
|
request.modifiedData().put("cprovincia", cprovincia);
|
|
request.modifiedData().put("isnew", "Y");
|
|
request.setLogsolicitude(codigoPlanificacion);//codigo de la planificaion PAB-2014-01
|
|
Response resp = this.callerhelper.executeSave(request);
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) == 0) {
|
|
this.setShowRow(true);
|
|
MessageHelper.setMessageInfo(resp, MsgGeneral.getProperty("msg_initFlow") +" "+ MsgControlArmas.getProperty("msg_noplanificacion")+ " : " +codigoPlanificacion);
|
|
cplanificacion=null;
|
|
btnFlujo=Boolean.FALSE;
|
|
} else {
|
|
MessageHelper.setMessageError(resp);
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Metodo que genera la planificacion
|
|
*/
|
|
public void generarPlanificacion() {
|
|
try {
|
|
|
|
//Verificando que no existan planificaciones previas para
|
|
//el centro de control y el anno seleccionado
|
|
List<TarmPlanificacionInspeccion> planificaciones=PlanificacionInspeccionController.findAllByCentroControlAnno(this.centroControl.getPk()
|
|
,this.record.getAnno().toString());
|
|
if(!planificaciones.isEmpty()){
|
|
MessageHelper.setMessageError(new Exception(MsgControlArmas.getProperty("msg_existePlanificacionAnno")));
|
|
}else{
|
|
this.planificacionGenerada = false;
|
|
this.planificacionTramiteController.getLrecord().clear();
|
|
|
|
// Cargando los documentos habilitantes
|
|
//this.documentoHabilitanteController.setFechaInicio(this.record.getFechainicio());
|
|
//this.documentoHabilitanteController.setFechaFin(this.record.getFechafin());
|
|
List<TarmDocumentoHabilitante> lstDocumentohabilitantes= DocumentoHabilitanteController.findInspeccionesGenerar(this.record.getFechainicio(), this.record.getFechafin(), this.centroControl);
|
|
|
|
if (lstDocumentohabilitantes != null && !lstDocumentohabilitantes.isEmpty()) {
|
|
int i=0;
|
|
for (TarmDocumentoHabilitante documento : lstDocumentohabilitantes) {
|
|
System.out.println("i.."+i);
|
|
i++;
|
|
// Persona
|
|
// TcustPersonDetail detallesPersona = PersonDetailController.find(documento.getPersoncode().toString());
|
|
// Tramite
|
|
if(documento.getCtramite()!=null){
|
|
//TarmTramite tramite = TarmTramiteController.find(documento.getCtramite().toString());
|
|
|
|
if(documento.getModifiedData().get("ctramite")!=null){
|
|
|
|
TarmPlanificacionTramite inspeccion = new TarmPlanificacionTramite();
|
|
inspeccion.setCsolicitud(documento.getCsolicitud());
|
|
|
|
inspeccion.setCtramite(Long.parseLong(documento.getModifiedData().get("ctramite").toString()));
|
|
inspeccion.setCdocumento(documento.getPk());
|
|
inspeccion.setIsnew(true);
|
|
|
|
inspeccion.getModifiedData().put("nombre", documento.getModifiedData().get("nombre"));
|
|
inspeccion.getModifiedData().put("nodocumento", documento.getModifiedData().get("nodocumento"));
|
|
inspeccion.getModifiedData().put("tipotramite", documento.getModifiedData().get("tipotramite"));
|
|
inspeccion.getModifiedData().put("usoactividad", documento.getModifiedData().get("usoactividad"));
|
|
inspeccion.getModifiedData().put("categoria", documento.getModifiedData().get("categoria"));
|
|
inspeccion.getModifiedData().put("fechacaducidad", documento.getFechaexpiracion());
|
|
|
|
Calendar calendario = Calendar.getInstance();
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
|
|
Integer dia = calendario.get(Calendar.DAY_OF_MONTH);
|
|
Integer mes = calendario.get(Calendar.MONTH);
|
|
Integer anno = calendario.get(Calendar.YEAR);
|
|
|
|
// Fecha actual
|
|
java.util.Date fechaActual = sdf.parse(dia.toString() + "-" + mes.toString() + "-" + anno.toString());
|
|
|
|
// Fecha expiracion
|
|
calendario.setTime(documento.getFechaexpiracion());
|
|
dia = calendario.get(Calendar.DAY_OF_MONTH);
|
|
mes = calendario.get(Calendar.MONTH);
|
|
anno = calendario.get(Calendar.YEAR);
|
|
java.util.Date fechaExpiracion = sdf.parse(dia.toString() + "-" + mes.toString() + "-" + anno.toString());
|
|
|
|
// Asignando el estado del tramite Caducada o Vigente
|
|
if (fechaExpiracion.compareTo(fechaActual) < 0) {
|
|
inspeccion.getModifiedData().put("estado", "Caducada");
|
|
} else {
|
|
inspeccion.getModifiedData().put("estado", "Vigente");
|
|
}
|
|
|
|
// Calendar calendar = Calendar.getInstance();
|
|
// this.record.setFechageneracion(new Date(calendar.getTimeInMillis()));
|
|
|
|
// Asignando el mes
|
|
calendario.setTime(documento.getFechaexpiracion());
|
|
Integer intmesnumero = calendario.get(Calendar.MONTH);
|
|
inspeccion.setMesnumero(Long.parseLong(intmesnumero.toString()));
|
|
switch (calendario.get(Calendar.MONTH)) {
|
|
case 0:
|
|
//inspeccion.setMes("Enero");
|
|
inspeccion.getModifiedData().put("ordena",0);
|
|
break;
|
|
case 1:
|
|
//inspeccion.setMes("Febrero");
|
|
inspeccion.getModifiedData().put("ordena",1);
|
|
break;
|
|
case 2:
|
|
//inspeccion.setMes("Marzo");
|
|
inspeccion.getModifiedData().put("ordena",2);
|
|
break;
|
|
case 3:
|
|
//inspeccion.setMes("Abril");
|
|
inspeccion.getModifiedData().put("ordena",3);
|
|
break;
|
|
case 4:
|
|
//inspeccion.setMes("Mayo");
|
|
inspeccion.getModifiedData().put("ordena",4);
|
|
break;
|
|
case 5:
|
|
//inspeccion.setMes("Junio");
|
|
inspeccion.getModifiedData().put("ordena",5);
|
|
break;
|
|
case 6:
|
|
//inspeccion.setMes("Julio");
|
|
inspeccion.getModifiedData().put("ordena",6);
|
|
break;
|
|
case 7:
|
|
//inspeccion.setMes("Agosto");
|
|
inspeccion.getModifiedData().put("ordena",7);
|
|
break;
|
|
case 8:
|
|
// inspeccion.setMes("Septiembre");
|
|
inspeccion.getModifiedData().put("ordena",8);
|
|
break;
|
|
case 9:
|
|
// inspeccion.setMes("Octubre");
|
|
inspeccion.getModifiedData().put("ordena",9);
|
|
break;
|
|
case 10:
|
|
// inspeccion.setMes("Noviembre");
|
|
inspeccion.getModifiedData().put("ordena",10);
|
|
break;
|
|
case 11:
|
|
// inspeccion.setMes("Diciembre");
|
|
inspeccion.getModifiedData().put("ordena",11);
|
|
break;
|
|
}
|
|
|
|
|
|
inspeccion.setMes("");
|
|
// Inspectores
|
|
|
|
inspeccion.getModifiedData().put("inspectores", "0");
|
|
|
|
// Vehiculos
|
|
|
|
inspeccion.getModifiedData().put("vehiculos", "0");
|
|
|
|
// periodo
|
|
// inspeccion.setPeriodo("1er Trimestre");
|
|
inspeccion.getModifiedData().put("periodo", "");
|
|
|
|
|
|
// presupuesto
|
|
|
|
inspeccion.getModifiedData().put("presupuesto", "");
|
|
|
|
// Asignando el record
|
|
this.planificacionTramiteController.create();
|
|
this.planificacionTramiteController.setRecord(inspeccion);
|
|
this.planificacionTramiteController.update();
|
|
}
|
|
}
|
|
}
|
|
|
|
// Ordenando las inspecciones por Mes y por Nombre
|
|
//ordena la lista lvigenciaMeses TarmDocumentoHabilitante documento : lstDocumentohabilitantes
|
|
Collections.sort(planificacionTramiteController.getLrecord(), new Comparator<TarmPlanificacionTramite>() {
|
|
public int compare(TarmPlanificacionTramite p1, TarmPlanificacionTramite p2) {
|
|
return new Integer(Integer.parseInt(p1.getModifiedData().get("ordena").toString())).compareTo(new Integer(p2.getModifiedData().get("ordena").toString()));
|
|
}
|
|
});
|
|
|
|
if (!this.planificacionTramiteController.getLrecord().isEmpty()) {
|
|
this.planificacionGenerada = true;
|
|
} else {
|
|
this.planificacionGenerada = false;
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_noExistenTramitesAnno") + " " + this.record.getAnno(),
|
|
new Object());
|
|
}
|
|
} else {
|
|
this.planificacionGenerada = false;
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_noExistenTramitesAnno") + " " + this.record.getAnno(), new Object());
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Metodo que carga los meses disponibles atendiendo a la fecha de expiracion del documento
|
|
*
|
|
* @param tramite
|
|
*/
|
|
public void cargarMeses() {
|
|
|
|
this.listaMeses.clear();
|
|
|
|
this.meses = this.planificacionTramiteController.getRecord().getPeriodo();
|
|
|
|
// this.planificacionTramiteController.getRecord().getPeriodo();
|
|
|
|
// MessageHelper.setMessageError(prueba.trim());
|
|
|
|
|
|
|
|
|
|
|
|
// 1er Cuatrimestre
|
|
if(this.meses!=null){
|
|
|
|
if (this.meses.equalsIgnoreCase("Mensual")){
|
|
listaMeses.add("Enero");
|
|
listaMeses.add("Febrero");
|
|
listaMeses.add("Marzo");
|
|
listaMeses.add("Abril");
|
|
listaMeses.add("Mayo");
|
|
listaMeses.add("Junio");
|
|
listaMeses.add("Julio");
|
|
listaMeses.add("Agosto");
|
|
listaMeses.add("Septiembre");
|
|
listaMeses.add("Octubre");
|
|
listaMeses.add("Noviembre");
|
|
listaMeses.add("Diciembre");
|
|
}
|
|
|
|
if (this.meses.equalsIgnoreCase("1er Cuatrimestre")){
|
|
listaMeses.add("Enero");
|
|
listaMeses.add("Febrero");
|
|
listaMeses.add("Marzo");
|
|
listaMeses.add("Abril");
|
|
}
|
|
if( this.meses.equalsIgnoreCase("2do Cuatrimestre")){
|
|
|
|
listaMeses.add("Mayo");
|
|
listaMeses.add("Junio");
|
|
listaMeses.add("Julio");
|
|
listaMeses.add("Agosto");
|
|
} if( this.meses.equalsIgnoreCase("3er Cuatrimestre")){
|
|
|
|
listaMeses.add("Septiembre");
|
|
listaMeses.add("Octubre");
|
|
listaMeses.add("Noviembre");
|
|
listaMeses.add("Diciembre");
|
|
}
|
|
|
|
if (this.meses.equalsIgnoreCase("1er Semestre")){
|
|
listaMeses.add("Enero");
|
|
listaMeses.add("Febrero");
|
|
listaMeses.add("Marzo");
|
|
listaMeses.add("Abril");
|
|
listaMeses.add("Mayo");
|
|
listaMeses.add("Junio");
|
|
|
|
}
|
|
|
|
if (this.meses.equalsIgnoreCase("2do Semestre")){
|
|
|
|
listaMeses.add("Julio");
|
|
listaMeses.add("Agosto");
|
|
listaMeses.add("Septiembre");
|
|
listaMeses.add("Octubre");
|
|
listaMeses.add("Noviembre");
|
|
listaMeses.add("Diciembre");
|
|
|
|
}
|
|
}else
|
|
this.listaMeses.clear();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
}
|
|
|
|
public void cargarPeriodo(TarmPlanificacionTramite inspeccion) {
|
|
|
|
|
|
|
|
this.listaMeses.clear();
|
|
this.listaPeriodo.clear();
|
|
|
|
switch (this.idPlanificacion) {
|
|
case "1":
|
|
|
|
listaPeriodo.add("Mensual");
|
|
|
|
|
|
break;
|
|
case "2":
|
|
listaPeriodo.add("1er Cuatrimestre");
|
|
listaPeriodo.add("2do Cuatrimestre");
|
|
listaPeriodo.add("3er Cuatrimestre");
|
|
|
|
|
|
break;
|
|
case "3":
|
|
listaPeriodo.add("1er Semestre");
|
|
listaPeriodo.add("2do Semestre");
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
cargarMeses();
|
|
|
|
}
|
|
|
|
/**
|
|
* Metodo que genera el codigo de la planificacion teniendo en cuenta el anio introducido por el usuario
|
|
*/
|
|
public void generarCodigoPlanificacion() {
|
|
try {
|
|
// Descripcion
|
|
this.record.setDescripcion(MsgControlArmas.getProperty("lbl_planificacionAnual") + " " + this.record.getAnno().toString());
|
|
|
|
// Codigo
|
|
Integer numeroPlanificacion = 1;
|
|
String textoNoPlanificacion = "";
|
|
List<TarmPlanificacionInspeccion> planificacionesTmp = PlanificacionInspeccionController.findPorAnno(this.record.getAnno());
|
|
if (planificacionesTmp != null && !planificacionesTmp.isEmpty()) {
|
|
numeroPlanificacion = planificacionesTmp.size() + 1;
|
|
}
|
|
if (numeroPlanificacion < 10) {
|
|
textoNoPlanificacion = "0" + numeroPlanificacion.toString();
|
|
} else {
|
|
textoNoPlanificacion = numeroPlanificacion.toString();
|
|
}
|
|
this.record.setCodigo("PAP-" + this.record.getAnno().toString() + "-" + textoNoPlanificacion);
|
|
|
|
// Fecha inicio
|
|
Calendar calendario = Calendar.getInstance();
|
|
calendario.set(Calendar.YEAR, Integer.parseInt(this.record.getAnno().toString()));
|
|
calendario.set(Calendar.DAY_OF_MONTH, 1);
|
|
calendario.set(Calendar.MONTH, 0);
|
|
this.record.setFechainicio(new Date(calendario.getTimeInMillis()));
|
|
|
|
calendario.set(Calendar.DAY_OF_MONTH, 31);
|
|
calendario.set(Calendar.MONTH, 11);
|
|
this.record.setFechafin(new Date(calendario.getTimeInMillis()));
|
|
|
|
this.habilitarGeneracion = true;
|
|
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Busca las planificaciones de un anio
|
|
*
|
|
* @param codigoSolicitud
|
|
* @return
|
|
*/
|
|
public static List<TarmPlanificacionInspeccion> findPorAnno(Long anno) {
|
|
try {
|
|
PlanificacionInspeccionController cc = new PlanificacionInspeccionController();
|
|
cc.init();
|
|
cc.recperpage = 300;
|
|
cc.addFilter("anno", anno.toString());
|
|
cc.querydatabase();
|
|
if (cc.lrecord != null) {
|
|
return cc.lrecord;
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Busca todas las planificaciones
|
|
*
|
|
* @param codigoSolicitud
|
|
* @return
|
|
*/
|
|
public static List<TarmPlanificacionInspeccion> findAllByCentroControl(String ccentrocontrol) {
|
|
try {
|
|
PlanificacionInspeccionController cc = new PlanificacionInspeccionController();
|
|
// cc.init();
|
|
cc.recperpage = 300;
|
|
cc.addFilter("ccentrocontrol", ccentrocontrol);
|
|
cc.querydatabase();
|
|
if (cc.lrecord != null) {
|
|
return cc.lrecord;
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Busca todas las planificaciones
|
|
*
|
|
* @param codigoSolicitud
|
|
* @return
|
|
*/
|
|
public static List<TarmPlanificacionInspeccion> findAllByCentroControlAnno(String ccentrocontrol,String anno) {
|
|
try {
|
|
PlanificacionInspeccionController cc = new PlanificacionInspeccionController();
|
|
// cc.init();
|
|
cc.recperpage = 300;
|
|
cc.addFilter("ccentrocontrol", ccentrocontrol);
|
|
cc.addFilter("anno", anno);
|
|
cc.querydatabase();
|
|
if (cc.lrecord != null) {
|
|
return cc.lrecord;
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Busca una planificacion por su codigo
|
|
*
|
|
* @param codigoSolicitud
|
|
* @return
|
|
*/
|
|
public static TarmPlanificacionInspeccion findPorCodigo(Long cplanificacion) {
|
|
try {
|
|
PlanificacionInspeccionController cc = new PlanificacionInspeccionController();
|
|
cc.init();
|
|
cc.recperpage = 300;
|
|
cc.addFilter("pk", cplanificacion.toString());
|
|
cc.querydatabase();
|
|
if (cc.lrecord != null && !cc.lrecord.isEmpty()) {
|
|
return cc.lrecord.get(0);
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public PlanificacionTramiteController getPlanificacionTramiteController() {
|
|
return planificacionTramiteController;
|
|
}
|
|
|
|
public void setPlanificacionTramiteController(PlanificacionTramiteController planificacionTramiteController) {
|
|
this.planificacionTramiteController = planificacionTramiteController;
|
|
}
|
|
|
|
public TarmCentroControl getCentroControl() {
|
|
return centroControl;
|
|
}
|
|
|
|
public void setCentroControl(TarmCentroControl centroControl) {
|
|
this.centroControl = centroControl;
|
|
}
|
|
|
|
public String getNombreCentroControl() {
|
|
return nombreCentroControl;
|
|
}
|
|
|
|
public void setNombreCentroControl(String nombreCentroControl) {
|
|
this.nombreCentroControl = nombreCentroControl;
|
|
}
|
|
|
|
public DocumentoHabilitanteController getDocumentoHabilitanteController() {
|
|
return documentoHabilitanteController;
|
|
}
|
|
|
|
public void setDocumentoHabilitanteController(DocumentoHabilitanteController documentoHabilitanteController) {
|
|
this.documentoHabilitanteController = documentoHabilitanteController;
|
|
}
|
|
|
|
public Boolean getPlanificacionSalvada() {
|
|
return planificacionSalvada;
|
|
}
|
|
|
|
public void setPlanificacionSalvada(Boolean planificacionSalvada) {
|
|
this.planificacionSalvada = planificacionSalvada;
|
|
}
|
|
|
|
public Boolean getPlanificacionGenerada() {
|
|
return planificacionGenerada;
|
|
}
|
|
|
|
public void setPlanificacionGenerada(Boolean planificacionGenerada) {
|
|
this.planificacionGenerada = planificacionGenerada;
|
|
}
|
|
|
|
public List<String> getListaMeses() {
|
|
return listaMeses;
|
|
}
|
|
|
|
public void setListaMeses(List<String> listaMeses) {
|
|
this.listaMeses = listaMeses;
|
|
}
|
|
|
|
public List<String> getListaPeriodo() {
|
|
return listaPeriodo;
|
|
}
|
|
|
|
public void setListaPeriodo(List<String> listaPeriodo) {
|
|
this.listaPeriodo = listaPeriodo;
|
|
}
|
|
|
|
public String getPeriodo() {
|
|
return Periodo;
|
|
}
|
|
|
|
public void setPeriodo(String Periodo) {
|
|
this.Periodo = Periodo;
|
|
}
|
|
|
|
public Boolean getHabilitarGeneracion() {
|
|
return habilitarGeneracion;
|
|
}
|
|
|
|
public void setHabilitarGeneracion(Boolean habilitarGeneracion) {
|
|
this.habilitarGeneracion = habilitarGeneracion;
|
|
}
|
|
|
|
public List<Long> getListaAnnos() {
|
|
return listaAnnos;
|
|
}
|
|
|
|
public void setListaAnnos(List<Long> listaAnnos) {
|
|
this.listaAnnos = listaAnnos;
|
|
}
|
|
|
|
public Boolean getPlanificacionesPrevias() {
|
|
return planificacionesPrevias;
|
|
}
|
|
|
|
public void setPlanificacionesPrevias(Boolean planificacionesPrevias) {
|
|
this.planificacionesPrevias = planificacionesPrevias;
|
|
}
|
|
|
|
public TarmCentroControlJur getJurisdiccionCentroControl() {
|
|
return jurisdiccionCentroControl;
|
|
}
|
|
|
|
public void setJurisdiccionCentroControl(TarmCentroControlJur jurisdiccionCentroControl) {
|
|
this.jurisdiccionCentroControl = jurisdiccionCentroControl;
|
|
}
|
|
|
|
public List<TarmPlanificacionInspeccion> getPlanificaciones() {
|
|
return planificaciones;
|
|
}
|
|
|
|
public void setPlanificaciones(List<TarmPlanificacionInspeccion> planificaciones) {
|
|
this.planificaciones = planificaciones;
|
|
}
|
|
|
|
public PersonAddressController getPersonAddressController() {
|
|
return personAddressController;
|
|
}
|
|
|
|
public void setPersonAddressController(PersonAddressController personAddressController) {
|
|
this.personAddressController = personAddressController;
|
|
}
|
|
|
|
public Long getCplanificacion() {
|
|
return cplanificacion;
|
|
}
|
|
|
|
public void setCplanificacion(Long cplanificacion) {
|
|
this.cplanificacion = cplanificacion;
|
|
}
|
|
|
|
public Boolean getBtnFlujo() {
|
|
return btnFlujo;
|
|
}
|
|
|
|
public void setBtnFlujo(Boolean btnFlujo) {
|
|
this.btnFlujo = btnFlujo;
|
|
}
|
|
/*CFLORES*/
|
|
public List<TgeneCatalogDetail> getTipoplanificacionList() {
|
|
return tipoplanificacionList;
|
|
}
|
|
|
|
public void setTipoplanificacionList(List<TgeneCatalogDetail> tipoplanificacionList) {
|
|
this.tipoplanificacionList = tipoplanificacionList;
|
|
}
|
|
|
|
public String getIdPlanificacion() {
|
|
return idPlanificacion;
|
|
}
|
|
|
|
public void setIdPlanificacion(String idPlanificacion) {
|
|
this.idPlanificacion = idPlanificacion;
|
|
}
|
|
|
|
public Float getPresupuesto1() {
|
|
return presupuesto1;
|
|
}
|
|
|
|
public void setPresupuesto1(Float presupuesto1) {
|
|
this.presupuesto1 = presupuesto1;
|
|
}
|
|
|
|
|
|
/**/
|
|
}
|