Sie sind auf Seite 1von 6

import

import
import
import

java.text.SimpleDateFormat;
groovy.sql.Sql;
java.sql.ResultSet;
java.sql.RowId;

def int resp=1;


/*Inicia el proceso de guardar Estatus del Proveedor */
def sqlp9 = BonitaSql.newInstance("jdbc:mysql://localhost:3306/bdbpms", "root",
"",new com.mysql.jdbc.Driver());
def String selectqueryp9 = "SELECT a.`Id_rfp`, COUNT(*) AS Cuentapro FROM `tab_d
etproverfp` AS a GROUP BY a.`Id_rfp` HAVING a.`Id_rfp`="+g_cabIdrfp+"";
def regpro = sqlp9.firstRow(selectqueryp9);
def int contproveedores=regpro.Cuentapro;
def int contador=0;
def sqlp1 = BonitaSql.newInstance("jdbc:mysql://localhost:3306/bdbpms", "root",
"",new com.mysql.jdbc.Driver());
def String selectqueryp1 = "SELECT a.`Id_rfp` , a.`id_proveedores`, COUNT(*) AS
Cuentap FROM `tab_detproverfp` AS a INNER JOIN `productos` b ON ( a.`id_producto
` = b.`id_producto`) GROUP BY a.`Id_rfp` , a.`id_proveedores` HAVING a.`Id_rfp`=
"+g_cabIdrfp+"";
sqlp1.eachRow(selectqueryp1) {
def varg1=it.Id_rfp;
def varg2=it.id_proveedores;
def int varg3=it.Cuentap;
contador=contador+1;
if((contador < (contproveedores+1))){
def sqlregp = BonitaSql.newInstance("jdbc:mysql://localh
ost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());
def String selectqueryrp = "SELECT a.`Id_rfp`, a.`id_pro
veedores`, a.`id_producto`, a.`cant_ofrecida`, a.`monto_ofrecido`, a.`Estatus' F
ROM `tab_detproverfp` AS a WHERE ((a.`Id_rfp`="+varg1+") AND (a.`id_proveedores
`="+varg2+"))";
sqlregp.eachRow(selectqueryrp) {
def varp1=it.Id_rfp;
def varp2=it.id_proveedores;
def varp3=it.id_producto;
def varp4=it.cant_ofrecida;
def varp5=it.monto_ofrecido;
if(contador==1){
if(v_selprov1==true){
def sqlc1 = BonitaSql.newInstance("jdbc:
mysql://localhost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());
def String selectsqlc1 = "UPDATE tab_det
proverfp SET Estatus=1 WHERE ((Id_rfp="+varp1+") AND (id_producto='"+varp3+"'))"
;
sqlc1.execute(selectsqlc1);
}else{
def sqlc1 = BonitaSql.newInstanc
e("jdbc:mysql://localhost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());
def String selectsqlc1 = "UPDATE
tab_detproverfp SET Estatus=0 WHERE ((Id_rfp="+varp1+") AND (id_producto='"+var
p3+"'))";
sqlc1.execute(selectsqlc1);
}
}
if(contador==2){
if(v_selprov2==true){

def sqlc1 = BonitaSql.newInstanc


e("jdbc:mysql://localhost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());
def String selectsqlc1 = "UPDATE
tab_detproverfp SET Estatus=1 WHERE ((Id_rfp="+varp1+") AND (id_producto='"+var
p3+"'))";
sqlc1.execute(selectsqlc1);
}else{
def sqlc1 = BonitaSql.newInstanc
e("jdbc:mysql://localhost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());
def String selectsqlc1 = "UPDATE
tab_detproverfp SET Estatus=0 WHERE ((Id_rfp="+varp1+") AND (id_producto='"+var
p3+"'))";
sqlc1.execute(selectsqlc1);
}
}
if(contador==3){
if(v_selprov3==true){
def sqlc1 = BonitaSql.newInstanc
e("jdbc:mysql://localhost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());
def String selectsqlc1 = "UPDATE
tab_detproverfp SET Estatus=1 WHERE ((Id_rfp="+varp1+") AND (id_producto='"+var
p3+"'))";
sqlc1.execute(selectsqlc1);
}else{
def sqlc1 = BonitaSql.newInstanc
e("jdbc:mysql://localhost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());
def String selectsqlc1 = "UPDATE
tab_detproverfp SET Estatus=0 WHERE ((Id_rfp="+varp1+") AND (id_producto='"+var
p3+"'))";
sqlc1.execute(selectsqlc1);
}
}
if(contador==4){
if(v_selprov4==true){
def sqlc1 = BonitaSql.newInstanc
e("jdbc:mysql://localhost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());
def String selectsqlc1 = "UPDATE
tab_detproverfp SET Estatus=1 WHERE ((Id_rfp="+varp1+") AND (id_producto='"+var
p3+"'))";
sqlc1.execute(selectsqlc1);
}else{
def sqlc1 = BonitaSql.newInstanc
e("jdbc:mysql://localhost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());
def String selectsqlc1 = "UPDATE
tab_detproverfp SET Estatus=0 WHERE ((Id_rfp="+varp1+") AND (id_producto='"+var
p3+"'))";
sqlc1.execute(selectsqlc1);
}
}
if(contador==5){
if(v_selprov5==true){
def sqlc1 = BonitaSql.newInstanc
e("jdbc:mysql://localhost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());
def String selectsqlc1 = "UPDATE
tab_detproverfp SET Estatus=1 WHERE ((Id_rfp="+varp1+") AND (id_producto='"+var
p3+"'))";
sqlc1.execute(selectsqlc1);
}else{
def sqlc1 = BonitaSql.newInstanc
e("jdbc:mysql://localhost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());

def String selectsqlc1 = "UPDATE


tab_detproverfp SET Estatus=0 WHERE ((Id_rfp="+varp1+") AND (id_producto='"+var
p3+"'))";
sqlc1.execute(selectsqlc1);
}
}
}
}
}
return resp;

-------def sqlp9 = BonitaSql.newInstance("jdbc:mysql://localhost:3306/bdbpms", "root",


"",new com.mysql.jdbc.Driver());
def String selectqueryp9 = "SELECT a.`Id_rfp`, COUNT(*) AS Cuentapro FROM `tab_d
etproverfp` AS a GROUP BY a.`Id_rfp` HAVING a.`Id_rfp`="+g_cabIdrfp+"";
def regpro = sqlp9.firstRow(selectqueryp9);
def int numreg=regpro.Cuentapro;

SELECT PROVEEDOR
import java.text.SimpleDateFormat;
import groovy.sql.Sql;
import java.sql.ResultSet;
def int resp=1;
//ELIMINA REGISTROS DEL RFP
def sql2 = BonitaSql.newInstance("jdbc:mysql://localhost:3306/bdbpms", "root", "
",new com.mysql.jdbc.Driver());
def String selectquery2 = "DELETE from tab_selproverfp WHERE Id_rfp="+g_cabIdrfp
+"";
sql2.execute(selectquery2);
//AGREGAR REGISTROS DE ANALISIS DEL RFP
def sql = BonitaSql.newInstance("jdbc:mysql://localhost:3306/bdbpms", "root", ""
,new com.mysql.jdbc.Driver());
def String selectquery = "SELECT a.`Id_rfp`, a.`id_producto`, b.`nom_producto`,
a.`cant_frp` FROM `tab_detproverfp` AS a INNER JOIN `productos` b ON (a.`id_pro
ducto`=b.`id_producto`) GROUP BY a.`Id_rfp`, a.`id_producto`, b.`nom_producto`,
a.`cant_frp` HAVING a.`Id_rfp`="+g_cabIdrfp+"";
def List list = new ArrayList();
sql.eachRow(selectquery) {
def var1=it.Id_rfp;
def var2=it.id_producto;
def var3=it.nom_producto;
def var4=it.cant_frp;
/*Valida si ya existe*/
def sql3 = BonitaSql.newInstance("jdbc:mysql://localhost:3306/bd
bpms", "root", "",new com.mysql.jdbc.Driver());

def String selectquery3 = "INSERT INTO `bdbpms`.`tab_selproverfp


` (`Id_rfp`, `id_producto`, `nom_producto`, `cant_frp`) VALUES ('" + var1 + "',
'" + var2 + "','" + var3 + "','"+ var4 +"')";
sql3.execute(selectquery3);
}
//Inicia el proceso de guardar resultados de cotizacion
def int contador=0;
def sqlp1 = BonitaSql.newInstance("jdbc:mysql://localhost:3306/bdbpms", "root",
"",new com.mysql.jdbc.Driver());
def String selectqueryp1 = "SELECT a.`Id_rfp` , a.`id_proveedores`, COUNT(*) AS
Cuentap FROM `tab_detproverfp` AS a INNER JOIN `productos` b ON ( a.`id_producto
` = b.`id_producto`) GROUP BY a.`Id_rfp` , a.`id_proveedores` HAVING a.`Id_rfp`=
"+g_cabIdrfp+"";
sqlp1.eachRow(selectqueryp1) {
def varg1=it.Id_rfp;
def varg2=it.id_proveedores;
def int varg3=it.Cuentap;
contador=contador+1;
if(contador >0){
def sqlregp = BonitaSql.newInstance("jdbc:mysql://localh
ost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());
def String selectqueryrp = "SELECT a.`Id_rfp`, a.`id_pro
veedores`, a.`id_producto`, a.`cant_ofrecida`, a.`monto_ofrecido` FROM `tab_detp
roverfp` AS a WHERE ((a.`Id_rfp`="+varg1+") AND (a.`id_proveedores`="+varg2+"))
";
sqlregp.eachRow(selectqueryrp) {
def varp1=it.Id_rfp;
def varp2=it.id_proveedores;
def varp3=it.id_producto;
def varp4=it.cant_ofrecida;
def varp5=it.monto_ofrecido;
if(contador==1){
def sqlc1 = BonitaSql.newInstance("jdbc:
mysql://localhost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());
def String selectsqlc1 = "UPDATE tab_sel
proverfp SET cant_ofrecida1="+ varp4 + ", monto_ofrecido1="+ varp5 +" WHERE ((Id
_rfp="+varp1+") AND (id_producto='"+varp3+"'))";
sqlc1.execute(selectsqlc1);
}
if(contador==2){
def sqlc1 = BonitaSql.newInstance("jdbc:
mysql://localhost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());
def String selectsqlc1 = "UPDATE tab_sel
proverfp SET cant_ofrecida2="+ varp4 + ", monto_ofrecido2="+ varp5 +" WHERE ((Id
_rfp="+varp1+") AND (id_producto='"+varp3+"'))";
sqlc1.execute(selectsqlc1);
}
if(contador==3){
def sqlc1 = BonitaSql.newInstance("jdbc:
mysql://localhost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());
def String selectsqlc1 = "UPDATE tab_sel
proverfp SET cant_ofrecida3="+ varp4 + ", monto_ofrecido3="+ varp5 +" WHERE ((Id
_rfp="+varp1+") AND (id_producto='"+varp3+"'))";
sqlc1.execute(selectsqlc1);
}
if(contador==4){
def sqlc1 = BonitaSql.newInstance("jdbc:

mysql://localhost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());


def String selectsqlc1 = "UPDATE tab_sel
proverfp SET cant_ofrecida4="+ varp4 + ", monto_ofrecido4="+ varp5 +" WHERE ((Id
_rfp="+varp1+") AND (id_producto='"+varp3+"'))";
sqlc1.execute(selectsqlc1);
}
if(contador==5){
def sqlc1 = BonitaSql.newInstance("jdbc:
mysql://localhost:3306/bdbpms", "root", "",new com.mysql.jdbc.Driver());
def String selectsqlc1 = "UPDATE tab_sel
proverfp SET cant_ofrecida5="+ varp4 + ", monto_ofrecido5="+ varp5 +" WHERE ((Id
_rfp="+varp1+") AND (id_producto='"+varp3+"'))";
sqlc1.execute(selectsqlc1);
}
}
}
}
return resp;
-------------def List list=new ArrayList();
list.add("Id RFP");
list.add("Id Producto");
list.add("Producto");
list.add("Cant. Solicitada");
def String cabprov1;
def String cabprov2;
if(vproveedor1.length()>0){
cabprov1="Cantidad -"+vproveedor1
cabprov2="Precio -"+vproveedor1
}else{
cabprov1="Cantidad - Proveedor 1"
cabprov2="Precio - Proveedor 1"
}
list.add(cabprov1);
list.add(cabprov2);
if(vproveedor2.length()>0){
cabprov1="Cantidad -"+vproveedor2
cabprov2="Precio -"+vproveedor2
}else{
cabprov1="Cantidad - Proveedor 2"
cabprov2="Precio - Proveedor 2"
}
list.add(cabprov1);
list.add(cabprov2);
if(vproveedor3.length()>0){
cabprov1="Cantidad -"+vproveedor3
cabprov2="Precio -"+vproveedor3
}else{
cabprov1="Cantidad - Proveedor 3"
cabprov2="Precio - Proveedor 3"
}
list.add(cabprov1);

list.add(cabprov2);
if(vproveedor4.length()>0){
cabprov1="Cantidad -"+vproveedor4
cabprov2="Precio -"+vproveedor4
}else{
cabprov1="Cantidad - Proveedor 4"
cabprov2="Precio - Proveedor 4"
}
list.add(cabprov1);
list.add(cabprov2);
if(vproveedor5.length()>0){
cabprov1="Cantidad -"+vproveedor5
cabprov2="Precio -"+vproveedor5
}else{
cabprov1="Cantidad - Proveedor 5"
cabprov2="Precio - Proveedor 5"
}
list.add(cabprov1);
list.add(cabprov2);
return list;