Rev 33939 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.dao.model;import javax.persistence.*;import java.util.Objects;@Entity@NamedNativeQueries({@NamedNativeQuery(name = "RbmTarget.getWarehouseWiseMonthlyTarget",query = "SELECT a.auth_id," +" a.first_name," +" a.warehouse_id," +" SUM(a.purchase) AS monthly_target" +" FROM (" +" SELECT au.id AS auth_id," +" CONCAT(au.first_name, ' ', au.last_name) AS first_name," +" fs.id AS fofo_id," +" mtgt.purchase," +" fs.warehouse_id" +" FROM auth.auth_user au" +" JOIN cs.position p ON p.auth_user_id = au.id" +" JOIN cs.partner_position pp ON pp.position_id = p.id" +" JOIN fofo.fofo_store fs ON fs.id = pp.partner_id" +" JOIN fofo.monthly_target mtgt on mtgt.fofo_id=pp.partner_id" +" WHERE pp.partner_id != 0" +" AND DATE_FORMAT(mtgt.on_date, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')" +" AND p.category_id = 18" +" AND p.escalation_type = 'L1'" +" UNION ALL" +" SELECT au.id AS auth_id," +" CONCAT(au.first_name, ' ', au.last_name) AS first_name," +" fs.id AS fofo_id," +" mtgt.purchase," +" fs.warehouse_id" +" FROM auth.auth_user au" +" JOIN cs.position p ON p.auth_user_id = au.id" +" JOIN cs.partner_position pp ON pp.position_id = p.id" +" JOIN cs.region r ON pp.region_id = r.id" +" JOIN cs.partner_region pr ON pr.region_id = pp.region_id" +" JOIN fofo.fofo_store fs ON fs.id = pr.fofo_id" +" JOIN fofo.monthly_target mtgt on mtgt.fofo_id=pp.partner_id" +" WHERE pp.partner_id = 0" +" AND DATE_FORMAT(mtgt.on_date, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')" +" AND p.category_id = 18" +" AND p.escalation_type = 'L1') a" +" GROUP BY a.auth_id, a.warehouse_id",resultSetMapping = "WarehouseWiseMonthlyTarget"),})@SqlResultSetMappings({@SqlResultSetMapping(name = "WarehouseWiseMonthlyTarget",classes = {@ConstructorResult(targetClass = WarehouseRbmTargetModel.class,columns = {@ColumnResult(name = "auth_id", type = Integer.class),@ColumnResult(name = "first_name ", type = String.class),@ColumnResult(name = "warehouse_id ", type = Integer.class),@ColumnResult(name = "monthly_target ", type = Float.class)})})})public class WarehouseRbmTargetModel {int authId;String rbmName;int warehouseId;float monthlyTarget;// Synthetic primary key to satisfy JPA's requirement@Id@GeneratedValue(strategy = GenerationType.IDENTITY)private Long id; // This will not be used in the query but satisfies JPA.public WarehouseRbmTargetModel(int authId, String rbmName, int warehouseId, float monthlyTarget) {this.authId = authId;this.rbmName = rbmName;this.warehouseId = warehouseId;this.monthlyTarget = monthlyTarget;}public int getAuthId() {return authId;}public void setAuthId(int authId) {this.authId = authId;}public String getRbmName() {return rbmName;}public void setRbmName(String rbmName) {this.rbmName = rbmName;}public int getWarehouseId() {return warehouseId;}public void setWarehouseId(int warehouseId) {this.warehouseId = warehouseId;}public float getMonthlyTarget() {return monthlyTarget;}public void setMonthlyTarget(float monthlyTarget) {this.monthlyTarget = monthlyTarget;}@Overridepublic boolean equals(Object o) {if (this == o) return true;if (o == null || getClass() != o.getClass()) return false;WarehouseRbmTargetModel that = (WarehouseRbmTargetModel) o;return authId == that.authId && warehouseId == that.warehouseId && Float.compare(monthlyTarget, that.monthlyTarget) == 0 && Objects.equals(rbmName, that.rbmName);}@Overridepublic int hashCode() {return Objects.hash(authId, rbmName, warehouseId, monthlyTarget);}@Overridepublic String toString() {return "WarehouseRbmTargetModel{" +"authId=" + authId +", rbmName='" + rbmName + '\'' +", warehouseId=" + warehouseId +", monthlyTarget=" + monthlyTarget +'}';}}