| 33917 |
ranu |
1 |
package com.spice.profitmandi.service;
|
|
|
2 |
|
| 35672 |
ranu |
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 37497 |
ranu |
4 |
import com.spice.profitmandi.dao.entity.inventory.SalesTargets;
|
| 33917 |
ranu |
5 |
import com.spice.profitmandi.dao.model.*;
|
|
|
6 |
import org.springframework.stereotype.Service;
|
|
|
7 |
|
|
|
8 |
import java.time.LocalDate;
|
|
|
9 |
import java.util.List;
|
|
|
10 |
|
|
|
11 |
@Service
|
|
|
12 |
public interface RbmTargetService {
|
|
|
13 |
|
|
|
14 |
List<WarehouseRbmTargetModel> getWarehouseWiseRbmMonthlyTarget();
|
|
|
15 |
|
| 37858 |
ranu |
16 |
List<WarehouseRbmTargetModel> getWarehouseWiseRbmMonthlyTarget(LocalDate monthStart);
|
|
|
17 |
|
| 33917 |
ranu |
18 |
List<MTDAchievedTargetModel> getDateWiseAchievedTargetOfRbm(LocalDate startDate, LocalDate endDate);
|
|
|
19 |
|
| 37858 |
ranu |
20 |
List<MTDAchievedTargetModel> getDateWiseAchievedTargetOfRbm(LocalDate startDate, LocalDate endDate, LocalDate targetMonthStart);
|
|
|
21 |
|
| 33917 |
ranu |
22 |
List<WarehouseMobileStockByMovementModel> getWarehouseMobileStockByMovement();
|
|
|
23 |
|
| 33991 |
ranu |
24 |
List<SoldCatalogsReportModel> getCatalogSoldReport(LocalDate startDate, LocalDate endDate);
|
|
|
25 |
|
| 33917 |
ranu |
26 |
int getWorkingDaysCount(LocalDate startDate);
|
|
|
27 |
|
| 34055 |
ranu |
28 |
List<TodayAchievedMovementModel> getMovementWiseAchievementByDate(LocalDate startDate, LocalDate endDate);
|
| 33917 |
ranu |
29 |
|
| 37442 |
ranu |
30 |
List<RbmBrandSoldModel> getBrandsSoldByRbm(int authId, int warehouseId, LocalDate startDate, LocalDate endDate);
|
|
|
31 |
|
| 37460 |
ranu |
32 |
List<RbmBrandPartnerCountModel> getBrandPartnerCountByRbm(int authId, int warehouseId, LocalDate startDate, LocalDate endDate);
|
|
|
33 |
|
| 37487 |
ranu |
34 |
List<WarehouseBuyingByMovementModel> getWarehouseBuyingByMovement(int warehouseId, LocalDate startDate, LocalDate endDate);
|
|
|
35 |
|
| 37497 |
ranu |
36 |
/**
|
| 37586 |
ranu |
37 |
* Opening stock value per movement class for a warehouse at the start of a period.
|
|
|
38 |
* Used by the RBM DRR drill-down "Warehouse Flow" table to contextualise the
|
|
|
39 |
* period's buying/selling ratio against stock that already existed before the
|
|
|
40 |
* period.
|
|
|
41 |
*
|
|
|
42 |
* @param warehouseId warehouse whose opening we want
|
|
|
43 |
* @param asOfDate the period start; everything received before this date
|
|
|
44 |
* and everything sold before this date contribute
|
|
|
45 |
*/
|
|
|
46 |
List<WarehouseOpeningByMovementModel> getWarehouseOpeningByMovement(int warehouseId, LocalDate asOfDate);
|
|
|
47 |
|
|
|
48 |
/**
|
| 37497 |
ranu |
49 |
* Daily writer for Sales-hierarchy targets (mirrors {@link #setMovementWiseRbmTargets}).
|
|
|
50 |
* Reads today's persisted RBM snapshots from inventory.rbm_targets, rolls them up per
|
|
|
51 |
* (sales_auth_id × warehouse_id) for every active Sales person whose downline contains
|
|
|
52 |
* at least one RBM, and inserts one row per (sales, warehouse) into inventory.sales_targets.
|
|
|
53 |
* Intended to run once daily via the cron flag {@code pushSalesTargets},
|
|
|
54 |
* chained after {@code pushRbmTargets}.
|
|
|
55 |
*/
|
|
|
56 |
void setSalesTargets();
|
|
|
57 |
|
|
|
58 |
/**
|
|
|
59 |
* Same as {@link #setSalesTargets()} but for a specific date — reads that
|
|
|
60 |
* day's persisted RBM snapshots and writes Sales snapshots stamped to that
|
|
|
61 |
* day. Useful for backfilling missed cron runs or seeding local/staging
|
|
|
62 |
* data without needing today's RBM snapshot.
|
|
|
63 |
*/
|
|
|
64 |
void setSalesTargetsForDate(LocalDate date);
|
|
|
65 |
|
|
|
66 |
List<SalesTargets> getSalesTargetsByDates(LocalDate startDate, LocalDate endDate);
|
|
|
67 |
|
|
|
68 |
/**
|
|
|
69 |
* Historical snapshot writer for Sales-hierarchy achievement (mirrors
|
|
|
70 |
* {@link #setMovementWiseRbmAchievement}). Rolls up today's live order
|
|
|
71 |
* ACH into one row per (Sales person × warehouse) and persists to
|
|
|
72 |
* {@code inventory.sales_achievements} for later reconciliation.
|
|
|
73 |
* The DRR dashboard reads ACH LIVE from orders — this table is audit only.
|
|
|
74 |
*/
|
|
|
75 |
void setSalesAchievements();
|
|
|
76 |
|
|
|
77 |
/**
|
|
|
78 |
* Dated variant of {@link #setSalesAchievements()} for backfill.
|
|
|
79 |
*/
|
|
|
80 |
void setSalesAchievementsForDate(LocalDate date);
|
|
|
81 |
|
| 37505 |
ranu |
82 |
/**
|
|
|
83 |
* Per-(auth × warehouse) live achievement for a specific Sales-hierarchy role
|
|
|
84 |
* (category 4, escalation L1..L6) in a date range. Direct query — no RBM roll-up.
|
|
|
85 |
*/
|
|
|
86 |
List<SalesHierarchyAchievedByMovementModel> getSalesAchievementByRole(
|
|
|
87 |
int categoryId, String escalationType, LocalDate startDate, LocalDate endDate);
|
|
|
88 |
|
|
|
89 |
/**
|
|
|
90 |
* Monthly target per (auth × warehouse) for a specific Sales-hierarchy role,
|
|
|
91 |
* looked up for the month of {@code refDate}. Sum of
|
|
|
92 |
* {@code fofo.monthly_target.purchase} across each Sales person's assigned partners.
|
|
|
93 |
*/
|
|
|
94 |
List<SalesHierarchyMonthlyTargetModel> getSalesMonthlyTargetByRole(
|
|
|
95 |
int categoryId, String escalationType, LocalDate refDate);
|
|
|
96 |
|
| 37519 |
ranu |
97 |
/**
|
|
|
98 |
* Distinct-partner rolled-up ACH per warehouse for a set of Sales-hierarchy
|
|
|
99 |
* auth_ids (RSM/NSM's downline). Dedupes partners across positions so overlapping
|
|
|
100 |
* assignments don't double-count.
|
|
|
101 |
*/
|
|
|
102 |
List<com.spice.profitmandi.dao.model.SalesDownlineAchievedByMovementModel>
|
|
|
103 |
getSalesDownlineAchievement(java.util.Collection<Integer> authIds, LocalDate startDate, LocalDate endDate);
|
|
|
104 |
|
|
|
105 |
/**
|
|
|
106 |
* Distinct-partner rolled-up monthly target per warehouse for a set of
|
|
|
107 |
* Sales-hierarchy auth_ids. Same dedup guarantee as
|
|
|
108 |
* {@link #getSalesDownlineAchievement}.
|
|
|
109 |
*/
|
|
|
110 |
List<com.spice.profitmandi.dao.model.SalesDownlineMonthlyTargetModel>
|
|
|
111 |
getSalesDownlineMonthlyTarget(java.util.Collection<Integer> authIds, LocalDate refDate);
|
|
|
112 |
|
| 37533 |
ranu |
113 |
/**
|
|
|
114 |
* Brand × movement-status sold by a set of Sales-hierarchy auth_ids in one
|
|
|
115 |
* warehouse × date range. Works for both single-person views (pass one
|
|
|
116 |
* authId) and RSM/NSM roll-ups (pass self + full downline). Dedupes
|
|
|
117 |
* partners via SELECT DISTINCT.
|
|
|
118 |
*/
|
|
|
119 |
List<com.spice.profitmandi.dao.model.SalesHierarchyBrandSoldModel>
|
|
|
120 |
getSalesBrandsSold(java.util.Collection<Integer> authIds, int warehouseId, LocalDate startDate, LocalDate endDate);
|
|
|
121 |
|
|
|
122 |
/**
|
|
|
123 |
* Distinct partner count per brand for the same Sales-hierarchy auth_ids
|
|
|
124 |
* set. Used for the "N partners" badge in the drill-down brand mix.
|
|
|
125 |
*/
|
|
|
126 |
List<com.spice.profitmandi.dao.model.SalesHierarchyBrandPartnerCountModel>
|
|
|
127 |
getSalesBrandPartnerCount(java.util.Collection<Integer> authIds, int warehouseId, LocalDate startDate, LocalDate endDate);
|
|
|
128 |
|
| 33997 |
ranu |
129 |
List<RbmTargetAndAchievementsModel> getRbmTargetsAndAchievemnts(LocalDate startDate, LocalDate endDate);
|
|
|
130 |
|
| 33917 |
ranu |
131 |
List<RbmArrViewModel> getRbmTodayArr(LocalDate todayDate) throws Exception;
|
|
|
132 |
|
|
|
133 |
List<RbmArrViewModel> getRbmTodayArr() throws Exception;
|
|
|
134 |
|
| 33926 |
ranu |
135 |
void setMovementWiseRbmTargets();
|
|
|
136 |
|
| 33985 |
ranu |
137 |
void setMovementWiseRbmAchievement();
|
|
|
138 |
|
| 34055 |
ranu |
139 |
List<Sold15daysOldAgingModel> getAgingSale(LocalDate startDate, LocalDate endDate);
|
|
|
140 |
|
|
|
141 |
List<Our15DaysOldAgingStock> our15DaysAgingStock();
|
|
|
142 |
|
| 36334 |
ranu |
143 |
List<WarehouseAgingStockModel> getWarehouseWiseAgingStock();
|
|
|
144 |
|
| 34103 |
ranu |
145 |
List<RbmBilledFofoIdsModel> getDateWiseBilledFofoIdByRbm(LocalDate startDate, LocalDate endDate);
|
|
|
146 |
|
| 35453 |
amit |
147 |
List<RbmWeeklyBillingModel> getWeeklyBillingDataForMonth(LocalDate monthStart, LocalDate monthEnd);
|
|
|
148 |
|
| 37858 |
ranu |
149 |
List<RbmWeeklyBillingModel> getWeeklyBillingDataForMonth(LocalDate monthStart, LocalDate monthEnd, LocalDate targetMonthStart);
|
|
|
150 |
|
| 34641 |
ranu |
151 |
double calculateFofoIdTodayTarget(int fofoId, double secondryMtd, LocalDate date);
|
| 34880 |
ranu |
152 |
|
|
|
153 |
long getRemainingDaysInMonth(LocalDate date);
|
| 35631 |
ranu |
154 |
|
|
|
155 |
List<RbmCallTargetModel> getRbmCallTargetModels() throws Exception;
|
|
|
156 |
|
| 36234 |
ranu |
157 |
List<RbmCallTargetModel> getRbmCallTargetModels(LocalDate queryDate) throws Exception;
|
|
|
158 |
|
| 35631 |
ranu |
159 |
List<OutOfSequenceDetailModel> getOutOfSequenceDetails(int authId);
|
| 35645 |
ranu |
160 |
|
| 35672 |
ranu |
161 |
List<CalledPartnerDetailModel> getCalledPartnerDetails(int authId) throws ProfitMandiBusinessException;
|
| 35670 |
ranu |
162 |
|
| 35730 |
ranu |
163 |
List<CalledPartnerDetailModel> getCalledPartnerDetails(int authId, LocalDate date) throws ProfitMandiBusinessException;
|
|
|
164 |
|
| 35645 |
ranu |
165 |
List<List<String>> getRbmCallTargetRawDataByAuthId(int authId) throws Exception;
|
| 35852 |
ranu |
166 |
|
|
|
167 |
List<List<String>> getAllCallDataByDate(LocalDate date) throws Exception;
|
| 36596 |
ranu |
168 |
|
|
|
169 |
List<List<String>> getAllRbmCallTargetRawData() throws Exception;
|
| 33917 |
ranu |
170 |
}
|