- MOSTRAR POR RUTA EN EL TELEFONO DE RUTA LOS CLIENTES SIN RENOVAR

This commit is contained in:
Brayan.Gonzalez 2025-06-13 11:57:52 -06:00
parent 25fde10e97
commit 6ec0f569e1
14 changed files with 517 additions and 220 deletions

View File

@ -7,10 +7,13 @@
*/ */
package com.arrebol.apc.controller.mobile.controller.customer; package com.arrebol.apc.controller.mobile.controller.customer;
import com.arrebol.apc.controller.mobile.repository.views.CustomerWithoutRenovationViewRepository;
import com.arrebol.apc.controller.mobile.repository.views.LoanByUserViewRepository; import com.arrebol.apc.controller.mobile.repository.views.LoanByUserViewRepository;
import com.arrebol.apc.model.ModelParameter; import com.arrebol.apc.model.ModelParameter;
import com.arrebol.apc.model.core.constance.CustomerWithoutRenovationViewCfg;
import com.arrebol.apc.model.core.constance.LoanByUserViewCfg; import com.arrebol.apc.model.core.constance.LoanByUserViewCfg;
import com.arrebol.apc.model.enums.PreferenceValue; import com.arrebol.apc.model.enums.PreferenceValue;
import com.arrebol.apc.model.views.CustomerWithoutRenovationView;
import com.arrebol.apc.model.views.LoanByUserView; import com.arrebol.apc.model.views.LoanByUserView;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
@ -24,40 +27,65 @@ import org.apache.logging.log4j.Logger;
*/ */
public class CustomerController implements Serializable { public class CustomerController implements Serializable {
/** /**
* *
* @param orderList * @param orderList
* @param userId * @param userId
* @return * @return
* @throws Exception * @throws Exception
*/ */
public List<LoanByUserView> findAllLoansByUserId(String orderList, String userId) throws Exception { public List<LoanByUserView> findAllLoansByUserId(String orderList, String userId) throws Exception {
try { try {
List<ModelParameter> parameters = new ArrayList<>(); List<ModelParameter> parameters = new ArrayList<>();
boolean isByOrderInList = PreferenceValue.ORDER_IN_LIST.toString().equals(orderList); boolean isByOrderInList = PreferenceValue.ORDER_IN_LIST.toString().equals(orderList);
parameters.add(new ModelParameter(LoanByUserViewCfg.FIELD_USER_ID, userId)); parameters.add(new ModelParameter(LoanByUserViewCfg.FIELD_USER_ID, userId));
return loanByUserViewRepository return loanByUserViewRepository
.findAllLoansByUserId( .findAllLoansByUserId(
isByOrderInList isByOrderInList
? LoanByUserViewCfg.QUERY_FIND_ALL_LOAN_BY_USER_ID_BY_ORDER_LIST ? LoanByUserViewCfg.QUERY_FIND_ALL_LOAN_BY_USER_ID_BY_ORDER_LIST
: LoanByUserViewCfg.QUERY_FIND_ALL_LOAN_BY_USER_ID_BY_CUSTOMER_NAME, : LoanByUserViewCfg.QUERY_FIND_ALL_LOAN_BY_USER_ID_BY_CUSTOMER_NAME,
parameters parameters
); );
} catch (Exception e) { } catch (Exception e) {
logger.error("findAllLoansByUserId", e); logger.error("findAllLoansByUserId", e);
throw e; throw e;
} }
} }
private static final long serialVersionUID = -6689182942800786108L; /**
final Logger logger = LogManager.getLogger(CustomerController.class); *
* @param idRoute
* @return
* @throws Exception
*/
public List<CustomerWithoutRenovationView> findAllNonRenewingCustomersByRuteId(String idRoute) throws Exception {
try {
List<ModelParameter> parameters = new ArrayList<>();
private final LoanByUserViewRepository loanByUserViewRepository; parameters.add(new ModelParameter(CustomerWithoutRenovationViewCfg.FIELD_RUTE_ID, idRoute));
public CustomerController() { return customerWithoutRenovationViewRepository
this.loanByUserViewRepository = new LoanByUserViewRepository(); .nonRenewingCustomersByRuteId(
} CustomerWithoutRenovationViewCfg.QUERY_FIND_ALL_UNRENEWED_CUSTOMERS_BY_ROUTE,
parameters
);
} catch (Exception e) {
logger.error("findAllLoansByUserId", e);
throw e;
}
}
private static final long serialVersionUID = -6689182942800786108L;
final Logger logger = LogManager.getLogger(CustomerController.class);
private final LoanByUserViewRepository loanByUserViewRepository;
private final CustomerWithoutRenovationViewRepository customerWithoutRenovationViewRepository;
public CustomerController() {
this.loanByUserViewRepository = new LoanByUserViewRepository();
this.customerWithoutRenovationViewRepository = new CustomerWithoutRenovationViewRepository();
}
} }

View File

@ -0,0 +1,54 @@
/*
* Arrebol Consultancy copyright.
*
* This code belongs to Arrebol Consultancy
* its use, redistribution or modification are prohibited
* without written authorization from Arrebol Consultancy.
*/
package com.arrebol.apc.controller.mobile.repository.views;
import com.arrebol.apc.controller.mobile.repository.GenericRepository;
import com.arrebol.apc.model.ModelParameter;
import com.arrebol.apc.model.views.CustomerWithoutRenovationView;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
*
* @author Carlos Janitzio Zavala Lopez <janitzio.zavala@arrebol.com.mx>
*/
public class CustomerWithoutRenovationViewRepository extends GenericRepository implements Serializable {
/**
*
* @param xmlQuery
* @param parameters
* @return
* @throws Exception
*/
public List<CustomerWithoutRenovationView> nonRenewingCustomersByRuteId(String xmlQuery, List<ModelParameter> parameters) throws Exception {
logger.debug("nonRenewingCustomersByRuteId");
List<CustomerWithoutRenovationView> results = new ArrayList<>();
try {
results = createNamedQueryResultList(
CustomerWithoutRenovationView.class,
xmlQuery,
parameters
);
} catch (Exception e) {
logger.error("nonRenewingCustomersByRuteId", e);
throw e;
}
return results;
}
private static final long serialVersionUID = 5669198954766725476L;
final Logger logger = LogManager.getLogger(CustomerWithoutRenovationViewRepository.class);
}

View File

@ -220,6 +220,7 @@
<mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/customer.without.renovation.view.queries.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" />

View File

@ -216,6 +216,7 @@
<mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/customer.without.renovation.view.queries.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" />

View File

@ -80,8 +80,8 @@
<id>Localhost</id> <id>Localhost</id>
<properties> <properties>
<hibernate.connection.url>jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=GMT-5</hibernate.connection.url> <hibernate.connection.url>jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=GMT-5</hibernate.connection.url>
<hibernate.connection.username>apoprocomlocalhost</hibernate.connection.username> <hibernate.connection.username>root</hibernate.connection.username>
<hibernate.connection.password>Yj$2Da0z!</hibernate.connection.password> <hibernate.connection.password>root</hibernate.connection.password>
<hibernate.connection.min_size>10</hibernate.connection.min_size> <hibernate.connection.min_size>10</hibernate.connection.min_size>
<hibernate.connection.max_size>40</hibernate.connection.max_size> <hibernate.connection.max_size>40</hibernate.connection.max_size>
<hibernate.connection.timeout>1800</hibernate.connection.timeout> <hibernate.connection.timeout>1800</hibernate.connection.timeout>

View File

@ -0,0 +1,19 @@
/*
* Arrebol Consultancy copyright.
*
* This code belongs to Arrebol Consultancy
* its use, redistribution or modification are prohibited
* without written authorization from Arrebol Consultancy.
*/
package com.arrebol.apc.model.core.constance;
/**
*
* @author Carlos Janitzio Zavala Lopez <janitzio.zavala@arrebol.com.mx>
*/
public interface CustomerWithoutRenovationViewCfg extends GenericCfg {
String QUERY_FIND_ALL_UNRENEWED_CUSTOMERS_BY_ROUTE = "findAllNonRenewingCustomersByRuteIdList";
String FIELD_RUTE_ID = "idRoute";
}

View File

@ -0,0 +1,137 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.arrebol.apc.model.views;
import java.io.Serializable;
import java.util.Date;
/**
*
* @author Oscar
*/
public class CustomerWithoutRenovationSimpleDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String personName;
private Date lastLoan;
private String amountPaid;
private String amountToPay;
private String saldoInsoluto;
private String actionNumber;
private String numFee;
private String addressHome;
private String addressBusiness;
private String companyName;
private String strPaymentDate;
// Constructor
public CustomerWithoutRenovationSimpleDTO() {
}
// Constructor desde entidad
public CustomerWithoutRenovationSimpleDTO(CustomerWithoutRenovationView entity) {
this.personName = entity.getPersonName();
this.lastLoan = entity.getLastLoan();
this.amountPaid = entity.getAmountPaid();
this.amountToPay = entity.getAmountToPay();
this.saldoInsoluto = entity.getSaldoInsoluto();
this.actionNumber = entity.getActionNumber();
this.numFee = entity.getNumFee();
this.addressHome = entity.getAddressHome();
this.addressBusiness = entity.getAddressBusiness();
this.companyName = entity.getCompanyName();
this.strPaymentDate = entity.getStrPaymentDate();
}
public String getPersonName() {
return personName;
}
public void setPersonName(String personName) {
this.personName = personName;
}
public Date getLastLoan() {
return lastLoan;
}
public void setLastLoan(Date lastLoan) {
this.lastLoan = lastLoan;
}
public String getAmountPaid() {
return amountPaid;
}
public void setAmountPaid(String amountPaid) {
this.amountPaid = amountPaid;
}
public String getAmountToPay() {
return amountToPay;
}
public void setAmountToPay(String amountToPay) {
this.amountToPay = amountToPay;
}
public String getSaldoInsoluto() {
return saldoInsoluto;
}
public void setSaldoInsoluto(String saldoInsoluto) {
this.saldoInsoluto = saldoInsoluto;
}
public String getActionNumber() {
return actionNumber;
}
public void setActionNumber(String actionNumber) {
this.actionNumber = actionNumber;
}
public String getNumFee() {
return numFee;
}
public void setNumFee(String numFee) {
this.numFee = numFee;
}
public String getAddressHome() {
return addressHome;
}
public void setAddressHome(String addressHome) {
this.addressHome = addressHome;
}
public String getAddressBusiness() {
return addressBusiness;
}
public void setAddressBusiness(String addressBusiness) {
this.addressBusiness = addressBusiness;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getStrPaymentDate() {
return strPaymentDate;
}
public void setStrPaymentDate(String strPaymentDate) {
this.strPaymentDate = strPaymentDate;
}
}

View File

@ -30,197 +30,203 @@ import org.hibernate.annotations.Immutable;
@Table(name = "APC_CUSTOMERS_WITHOUT_RENOVATION_VIEW") @Table(name = "APC_CUSTOMERS_WITHOUT_RENOVATION_VIEW")
public class CustomerWithoutRenovationView implements Serializable { public class CustomerWithoutRenovationView implements Serializable {
private static final long serialVersionUID = 3731003393000465083L; private static final long serialVersionUID = 3731003393000465083L;
@Id @Id
@Column(name = "id", length = 36) @Column(name = "id", length = 36)
private String id; private String id;
@Column(name = "available_person") @Column(name = "available_person")
private String personName; private String personName;
@Column(name = "route_name") @Column(name = "route_name")
private String routeName; private String routeName;
@Column(name = "last_loan") @Column(name = "id_route")
@Temporal(javax.persistence.TemporalType.DATE) private String idRoute;
private Date lastLoan;
@Column(name = "amount_paid") @Column(name = "last_loan")
private String amountPaid; @Temporal(javax.persistence.TemporalType.DATE)
private Date lastLoan;
@Column(name = "amount_to_pay") @Column(name = "amount_paid")
private String amountToPay; private String amountPaid;
@Column(name = "saldo_insoluto") @Column(name = "amount_to_pay")
private String saldoInsoluto; private String amountToPay;
@Column(name = "action_number") @Column(name = "saldo_insoluto")
private String actionNumber; private String saldoInsoluto;
@Column(name = "num_fee") @Column(name = "action_number")
private String numFee; private String actionNumber;
@Column(name = "address_home") @Column(name = "num_fee")
private String addressHome; private String numFee;
@Column(name = "address_business") @Column(name = "address_home")
private String addressBusiness; private String addressHome;
@Column(name = "company_name") @Column(name = "address_business")
private String companyName; private String addressBusiness;
@Column(name = "company_name")
private String companyName;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(
name = "id_office",
referencedColumnName = "id",
nullable = false
)
private Office office;
@Column(name = "str_payment_date", length = 22)
private String strPaymentDate;
@ManyToOne(fetch = FetchType.LAZY, optional = false) public String getId() {
@JoinColumn( return id;
name = "id_office", }
referencedColumnName = "id",
nullable = false
)
private Office office;
@Column(name = "str_payment_date", length = 22) public void setId(String id) {
private String strPaymentDate; this.id = id;
}
public String getId() { public String getPersonName() {
return id; return personName;
} }
public void setId(String id) { public void setPersonName(String personName) {
this.id = id; this.personName = personName;
} }
public String getPersonName() { public String getRouteName() {
return personName; return routeName;
} }
public void setPersonName(String personName) { public void setRouteName(String routeName) {
this.personName = personName; this.routeName = routeName;
} }
public String getRouteName() { public Date getLastLoan() {
return routeName; return lastLoan;
} }
public void setRouteName(String routeName) { public void setLastLoan(Date lastLoan) {
this.routeName = routeName; this.lastLoan = lastLoan;
} }
public Date getLastLoan() { public Office getOffice() {
return lastLoan; return office;
} }
public void setLastLoan(Date lastLoan) { public void setOffice(Office office) {
this.lastLoan = lastLoan; this.office = office;
} }
public Office getOffice() { public String getStrPaymentDate() {
return office; return strPaymentDate;
} }
public void setOffice(Office office) { public void setStrPaymentDate(String strPaymentDate) {
this.office = office; this.strPaymentDate = strPaymentDate;
} }
public String getStrPaymentDate() { public String getAmountPaid() {
return strPaymentDate; return amountPaid;
} }
public void setStrPaymentDate(String strPaymentDate) { public void setAmountPaid(String amountPaid) {
this.strPaymentDate = strPaymentDate; this.amountPaid = amountPaid;
} }
public String getAmountPaid() { public String getAmountToPay() {
return amountPaid; return amountToPay;
} }
public void setAmountPaid(String amountPaid) { public void setAmountToPay(String amountToPay) {
this.amountPaid = amountPaid; this.amountToPay = amountToPay;
} }
public String getAmountToPay() { public String getSaldoInsoluto() {
return amountToPay; return saldoInsoluto;
} }
public void setAmountToPay(String amountToPay) { public void setSaldoInsoluto(String saldoInsoluto) {
this.amountToPay = amountToPay; this.saldoInsoluto = saldoInsoluto;
} }
public String getSaldoInsoluto() { public String getActionNumber() {
return saldoInsoluto; return actionNumber;
} }
public void setSaldoInsoluto(String saldoInsoluto) { public void setActionNumber(String actionNumber) {
this.saldoInsoluto = saldoInsoluto; this.actionNumber = actionNumber;
} }
public String getActionNumber() { public String getNumFee() {
return actionNumber; return numFee;
} }
public void setActionNumber(String actionNumber) { public void setNumFee(String numFee) {
this.actionNumber = actionNumber; this.numFee = numFee;
} }
public String getNumFee() { public String getAddressHome() {
return numFee; return addressHome;
} }
public void setNumFee(String numFee) { public void setAddressHome(String addressHome) {
this.numFee = numFee; this.addressHome = addressHome;
} }
public String getAddressHome() { public String getAddressBusiness() {
return addressHome; return addressBusiness;
} }
public void setAddressHome(String addressHome) { public void setAddressBusiness(String addressBusiness) {
this.addressHome = addressHome; this.addressBusiness = addressBusiness;
} }
public String getAddressBusiness() { public String getCompanyName() {
return addressBusiness; return companyName;
} }
public void setAddressBusiness(String addressBusiness) { public void setCompanyName(String companyName) {
this.addressBusiness = addressBusiness; this.companyName = companyName;
} }
public String getCompanyName() { public String getIdRoute() {
return companyName; return idRoute;
} }
public void setCompanyName(String companyName) { public void setIdRoute(String idRoute) {
this.companyName = companyName; this.idRoute = idRoute;
} }
@Override
public int hashCode() {
int hash = 7;
hash = 61 * hash + Objects.hashCode(this.id);
return hash;
}
@Override
@Override public boolean equals(Object obj) {
public int hashCode() { if (this == obj) {
int hash = 7; return true;
hash = 61 * hash + Objects.hashCode(this.id); }
return hash; if (obj == null) {
} return false;
}
@Override if (getClass() != obj.getClass()) {
public boolean equals(Object obj) { return false;
if (this == obj) { }
return true; final CustomerWithoutRenovationView other = (CustomerWithoutRenovationView) obj;
} if (!Objects.equals(this.id, other.id)) {
if (obj == null) { return false;
return false; }
} return true;
if (getClass() != obj.getClass()) { }
return false;
}
final CustomerWithoutRenovationView other = (CustomerWithoutRenovationView) obj;
if (!Objects.equals(this.id, other.id)) {
return false;
}
return true;
}
} }

View File

@ -222,6 +222,7 @@
<mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/customer.without.renovation.view.queries.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" />

View File

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"https://hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<query name="findAllNonRenewingCustomersByRuteIdList">
<![CDATA[
SELECT
view
FROM CustomerWithoutRenovationView view
WHERE
idRoute = :idRoute
ORDER BY personName DESC
]]>
</query>
</hibernate-mapping>

View File

@ -140,8 +140,8 @@
<id>Localhost</id> <id>Localhost</id>
<properties> <properties>
<hibernate.connection.url>jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=GMT-5</hibernate.connection.url> <hibernate.connection.url>jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=GMT-5</hibernate.connection.url>
<hibernate.connection.username>apoprocomlocalhost</hibernate.connection.username> <hibernate.connection.username>root</hibernate.connection.username>
<hibernate.connection.password>Yj$2Da0z!</hibernate.connection.password> <hibernate.connection.password>root</hibernate.connection.password>
</properties> </properties>
</profile> </profile>
<profile> <profile>

View File

@ -206,11 +206,11 @@
</properties> </properties>
</profile> </profile>
<profile> <profile>
<id>Localhost-Mobile-APP</id> <id>Localhost</id>
<properties> <properties>
<hibernate.connection.url>jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=GMT-5</hibernate.connection.url> <hibernate.connection.url>jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=GMT-5</hibernate.connection.url>
<hibernate.connection.username>apoprocommobilelocalhost</hibernate.connection.username> <hibernate.connection.username>root</hibernate.connection.username>
<hibernate.connection.password>0Ps$6%q8</hibernate.connection.password> <hibernate.connection.password>root</hibernate.connection.password>
</properties> </properties>
</profile> </profile>
<profile> <profile>

View File

@ -8,13 +8,18 @@
package com.arrebol.apc.ws.customer; package com.arrebol.apc.ws.customer;
import com.arrebol.apc.controller.mobile.controller.customer.CustomerController; import com.arrebol.apc.controller.mobile.controller.customer.CustomerController;
import com.arrebol.apc.model.views.CustomerWithoutRenovationSimpleDTO;
import com.arrebol.apc.model.views.CustomerWithoutRenovationView;
import com.arrebol.apc.model.views.LoanByUserView; import com.arrebol.apc.model.views.LoanByUserView;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import javax.ws.rs.FormParam; import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.GenericEntity; import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@ -28,32 +33,59 @@ import org.apache.logging.log4j.Logger;
@Path("customer") @Path("customer")
public class CustomerWS implements Serializable { public class CustomerWS implements Serializable {
private static final long serialVersionUID = -5280895557294295716L; private static final long serialVersionUID = -5280895557294295716L;
@POST @POST
@Path("list") @Path("list")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public Response findAllLoansByUserId(@FormParam("orderList") String orderList, @FormParam("userId") String userId) { public Response findAllLoansByUserId(@FormParam("orderList") String orderList, @FormParam("userId") String userId) {
logger.debug("findAllLoansByUserId"); logger.debug("findAllLoansByUserId");
Response response; Response response;
try { try {
GenericEntity<List<LoanByUserView>> list = new GenericEntity<List<LoanByUserView>>(controller.findAllLoansByUserId(orderList, userId)) { GenericEntity<List<LoanByUserView>> list = new GenericEntity<List<LoanByUserView>>(controller.findAllLoansByUserId(orderList, userId)) {
}; };
response = Response.ok(list).build(); response = Response.ok(list).build();
} catch (Exception e) { } catch (Exception e) {
logger.error("findAllLoansByUserId", e); logger.error("findAllLoansByUserId", e);
response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); response = Response.status(Response.Status.NOT_ACCEPTABLE).build();
} }
return response; return response;
} }
final Logger logger = LogManager.getLogger(CustomerWS.class); @GET
private final CustomerController controller; @Path("nonRenewingCustomersByRuteId")
@Produces(MediaType.APPLICATION_JSON)
public Response findAllNonRenewingCustomersByRuteId(@QueryParam("idRoute") String idRoute) {
logger.debug("findAllNonRenewingCustomersByRuteId");
public CustomerWS() { Response response;
this.controller = new CustomerController(); try {
} List<CustomerWithoutRenovationView> originalList = controller.findAllNonRenewingCustomersByRuteId(idRoute);
// Convertir a DTOs
List<CustomerWithoutRenovationSimpleDTO> simplifiedList = originalList.stream()
.map(CustomerWithoutRenovationSimpleDTO::new)
.collect(Collectors.toList());
GenericEntity<List<CustomerWithoutRenovationSimpleDTO>> list
= new GenericEntity<List<CustomerWithoutRenovationSimpleDTO>>(simplifiedList) {
};
response = Response.ok(list).build();
} catch (Exception e) {
logger.error("findAllNonRenewingCustomersByRuteId", e);
response = Response.status(Response.Status.NOT_ACCEPTABLE).build();
}
return response;
}
final Logger logger = LogManager.getLogger(CustomerWS.class);
private final CustomerController controller;
public CustomerWS() {
this.controller = new CustomerController();
}
} }

View File

@ -216,6 +216,7 @@
<mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/customer.without.renovation.view.queries.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" />