Subversion Repositories SmartDukaan

Rev

Rev 25278 | Rev 27574 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.dao.entity.fofo;

import java.io.Serializable;
import java.time.LocalDate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.spice.profitmandi.common.enumuration.CounterSize;
import com.spice.profitmandi.dao.entity.user.Address;

/**
 * This class basically contains store code details
 * 
 * @author ashikali
 *
 */
@Entity
@Table(name = "fofo.fofo_store", schema = "fofo")

@NamedQueries({

                @NamedQuery(name = "FofoStore.selectGroupByWarehousePartnerSale", query = "select new com.spice.profitmandi.dao.model.WarehouseWisePartnerSaleModel(fs.warehouseId,"
                                + "sum(case when month(foi.createTimestamp) = month(now())-1 then CAST(foi.mop  AS int) else 0 end),"
                                + "sum(case when month(foi.createTimestamp) = month(now())-1 then foi.quantity  else 0 end),"
                                + "sum(case when month(foi.createTimestamp) = month(now()) then CAST(foi.mop  AS int) else 0 end),"
                                + "sum(case when month(foi.createTimestamp) = month(now()) then foi.quantity  else 0 end))"
                                + " from FofoStore fs join FofoOrder fo on fs.id = fo.fofoId join FofoOrderItem foi on foi.orderId = fo.id  join Item i on i.id = foi.itemId  where fo.cancelledTimestamp is null and fs.active = true"
                                + " group by fs.warehouseId"),

                @NamedQuery(name = "FofoStore.selectGroupByBrandWarehousePartnerSale", query = "select new com.spice.profitmandi.dao.model.WarehouseWiseBrandSaleModel(i.brand, "
                                + "sum(case when month(foi.createTimestamp) = month(now())-1 then CAST(foi.mop  AS int) else 0 end),"
                                + "sum(case when month(foi.createTimestamp) = month(now())-1 then foi.quantity  else 0 end),"
                                + "sum(case when month(foi.createTimestamp) = month(now()) then CAST(foi.mop  AS int) else 0 end),"
                                + "sum(case when month(foi.createTimestamp) = month(now()) then foi.quantity  else 0 end))"
                                + " from FofoStore fs join FofoOrder fo on fs.id = fo.fofoId join FofoOrderItem foi on foi.orderId = fo.id  join Item i on i.id = foi.itemId  where fo.cancelledTimestamp is null and fs.active = true and "
                                + " :warehouseId IS NULL OR fs.warehouseId = :warehouseId" + " group by i.brand"),

                @NamedQuery(name = "FofoStore.selectWarehouseBrandItemSale", query = "select new com.spice.profitmandi.dao.model.WarehouseBrandWiseItemSaleModel(fs.warehouseId, i.brand, i.modelName, i.modelNumber,i.color,"
                                + "case when month(foi.createTimestamp) = month(now())-1 then foi.mop else 0 end,"
                                + "case when month(foi.createTimestamp) = month(now())-1 then foi.quantity  else 0 end,"
                                + "case when month(foi.createTimestamp) = month(now()) then foi.mop   else 0 end,"
                                + "case when month(foi.createTimestamp) = month(now()) then foi.quantity  else 0 end)"
                                + " from FofoStore fs join FofoOrder fo on fs.id = fo.fofoId join FofoOrderItem foi on foi.orderId = fo.id  join Item i on i.id = foi.itemId  where fo.cancelledTimestamp is null and fs.active = true"
                                + " and fs.warehouseId in :warehouseId and i.brand = :brand"),

})
public class FofoStore implements Serializable {

        private static final long serialVersionUID = 1L;

        public FofoStore() {
        }

        @Id
        @Column(name = "id", unique = true, updatable = false)
        private int id;

        @Column(name = "code", unique = true)
        private String code;

        @Column(name = "latitude")
        private String latitude;

        @Column(name = "longitude")
        private String longitude;

        @Column(name = "counter_size")
        @Enumerated(EnumType.STRING)
        private CounterSize counterSize = CounterSize.TEN_LAC;

        @Column(name = "warehouse_id")
        private int warehouseId;

        public int getWarehouseId() {
                return warehouseId;
        }

        public void setWarehouseId(int warehouseId) {
                this.warehouseId = warehouseId;
        }

        @Column(name = "minimum_investment")
        private float minimumInvestment;

        @Column(name = "grace_date")
        private LocalDate graceDate;

        @Column(name = "investment_ok")
        private boolean investmentOk;

        public boolean isInvestmentOk() {
                return investmentOk;
        }

        public void setInvestmentOk(boolean investmentOk) {
                this.investmentOk = investmentOk;
        }

        @Column(name = "grace_count")
        private int graceCount;

        @Column
        private boolean active = true;

        public int getGraceCount() {
                return graceCount;
        }

        public boolean isActive() {
                return active;
        }

        public void setActive(boolean active) {
                this.active = active;
        }

        public void setGraceCount(int graceCount) {
                this.graceCount = graceCount;
        }

        public LocalDate getGraceDate() {
                return graceDate;
        }

        public void setGraceDate(LocalDate graceDate) {
                this.graceDate = graceDate;
        }

        public float getMinimumInvestment() {
                return minimumInvestment;
        }

        public void setMinimumInvestment(float minimumInvestment) {
                this.minimumInvestment = minimumInvestment;
        }

        @Transient
        private Address userAddress;

        /*
         * public int getCreditCycle() { return creditCycle; } public void
         * setCreditCycle(int creditCycle) { this.creditCycle = creditCycle; }
         */
        public CounterSize getCounterSize() {
                return counterSize;
        }

        public void setCounterSize(CounterSize counterSize) {
                this.counterSize = counterSize;
        }

        public int getId() {
                return id;
        }

        public void setId(int id) {
                this.id = id;
        }

        public String getCode() {
                return code;
        }

        public void setCode(String code) {
                this.code = code;
        }

        public String getLatitude() {
                return latitude;
        }

        public void setLatitude(String latitude) {
                this.latitude = latitude;
        }

        public String getLongitude() {
                return longitude;
        }

        public void setLongitude(String longitude) {
                this.longitude = longitude;
        }

        public Address getUserAddress() {
                return userAddress;
        }

        public void setUserAddress(Address userAddress) {
                this.userAddress = userAddress;
        }

        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + (active ? 1231 : 1237);
                result = prime * result + ((code == null) ? 0 : code.hashCode());
                result = prime * result + ((counterSize == null) ? 0 : counterSize.hashCode());
                result = prime * result + graceCount;
                result = prime * result + ((graceDate == null) ? 0 : graceDate.hashCode());
                result = prime * result + id;
                result = prime * result + (investmentOk ? 1231 : 1237);
                result = prime * result + ((latitude == null) ? 0 : latitude.hashCode());
                result = prime * result + ((longitude == null) ? 0 : longitude.hashCode());
                result = prime * result + Float.floatToIntBits(minimumInvestment);
                result = prime * result + ((userAddress == null) ? 0 : userAddress.hashCode());
                result = prime * result + warehouseId;
                return result;
        }

        @Override
        public boolean equals(Object obj) {
                if (this == obj)
                        return true;
                if (obj == null)
                        return false;
                if (getClass() != obj.getClass())
                        return false;
                FofoStore other = (FofoStore) obj;
                if (active != other.active)
                        return false;
                if (code == null) {
                        if (other.code != null)
                                return false;
                } else if (!code.equals(other.code))
                        return false;
                if (counterSize != other.counterSize)
                        return false;
                if (graceCount != other.graceCount)
                        return false;
                if (graceDate == null) {
                        if (other.graceDate != null)
                                return false;
                } else if (!graceDate.equals(other.graceDate))
                        return false;
                if (id != other.id)
                        return false;
                if (investmentOk != other.investmentOk)
                        return false;
                if (latitude == null) {
                        if (other.latitude != null)
                                return false;
                } else if (!latitude.equals(other.latitude))
                        return false;
                if (longitude == null) {
                        if (other.longitude != null)
                                return false;
                } else if (!longitude.equals(other.longitude))
                        return false;
                if (Float.floatToIntBits(minimumInvestment) != Float.floatToIntBits(other.minimumInvestment))
                        return false;
                if (userAddress == null) {
                        if (other.userAddress != null)
                                return false;
                } else if (!userAddress.equals(other.userAddress))
                        return false;
                if (warehouseId != other.warehouseId)
                        return false;
                return true;
        }

        @Override
        public String toString() {
                return "FofoStore [id=" + id + ", code=" + code + ", latitude=" + latitude + ", longitude=" + longitude
                                + ", counterSize=" + counterSize + ", warehouseId=" + warehouseId + ", minimumInvestment="
                                + minimumInvestment + ", graceDate=" + graceDate + ", investmentOk=" + investmentOk + ", graceCount="
                                + graceCount + ", active=" + active + ", userAddress=" + userAddress + "]";
        }

}