Subversion Repositories SmartDukaan

Rev

Rev 33843 | Rev 33917 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33843 Rev 33844
Line 5... Line 5...
5
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
5
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
6
import com.spice.profitmandi.common.model.*;
6
import com.spice.profitmandi.common.model.*;
7
import com.spice.profitmandi.common.util.FileUtil;
7
import com.spice.profitmandi.common.util.FileUtil;
8
import com.spice.profitmandi.common.web.util.ResponseSender;
8
import com.spice.profitmandi.common.web.util.ResponseSender;
9
import com.spice.profitmandi.dao.entity.auth.AuthUser;
9
import com.spice.profitmandi.dao.entity.auth.AuthUser;
10
import com.spice.profitmandi.dao.entity.auth.PartnerCollectionRemark;
-
 
11
import com.spice.profitmandi.dao.entity.catalog.BrandCatalog;
10
import com.spice.profitmandi.dao.entity.catalog.BrandCatalog;
12
import com.spice.profitmandi.dao.entity.cs.Position;
-
 
13
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
11
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
14
import com.spice.profitmandi.dao.entity.user.*;
12
import com.spice.profitmandi.dao.entity.user.*;
15
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
-
 
16
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
13
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
17
import com.spice.profitmandi.dao.enumuration.dtr.CommunicationType;
14
import com.spice.profitmandi.dao.enumuration.dtr.CommunicationType;
18
import com.spice.profitmandi.dao.enumuration.dtr.LeadSource;
15
import com.spice.profitmandi.dao.enumuration.dtr.LeadSource;
19
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
16
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
20
import com.spice.profitmandi.dao.model.*;
17
import com.spice.profitmandi.dao.model.*;
Line 1244... Line 1241...
1244
        for (int rbmAuthId : rbmPositionsAuthIds) {
1241
        for (int rbmAuthId : rbmPositionsAuthIds) {
1245
            RBMPerformanceSummaryModel rbmPerformanceSummaryModel = new RBMPerformanceSummaryModel();
1242
            RBMPerformanceSummaryModel rbmPerformanceSummaryModel = new RBMPerformanceSummaryModel();
1246
            rbmPerformanceSummaryModel.setAuthId(rbmAuthId);
1243
            rbmPerformanceSummaryModel.setAuthId(rbmAuthId);
1247
            AuthUser authUser = authRepository.selectById(rbmAuthId);
1244
            AuthUser authUser = authRepository.selectById(rbmAuthId);
1248
            rbmPerformanceSummaryModel.setAuthName(authUser.getFullName());
1245
            rbmPerformanceSummaryModel.setAuthName(authUser.getFullName());
1249
            List<Integer> fofoIdList = new ArrayList<>(storeGuyMap.get(authUser.getEmailId()));
1246
            List<Integer> fofoIds = new ArrayList<>(storeGuyMap.get(authUser.getEmailId()));
1250
 
-
 
1251
            List<Integer> remarkIds = partnerCollectionRemarkRepository.selectMaxRemarkId(fofoIdList);
-
 
1252
 
-
 
1253
            Map<Integer, PartnerCollectionRemark> partnerCollectionRemarks = new HashMap<>();
-
 
1254
 
-
 
1255
            if (!remarkIds.isEmpty()) {
-
 
1256
                partnerCollectionRemarks = partnerCollectionRemarkRepository.selectByIds(remarkIds).stream()
-
 
1257
                        .collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
-
 
1258
            }
-
 
1259
            List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId()).stream().collect(Collectors.toList());
-
 
1260
            boolean isRBMAndL1 = positions.stream()
-
 
1261
                    .anyMatch(position ->
-
 
1262
                            ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId()
-
 
1263
                                    && EscalationType.L1.equals(position.getEscalationType()));
-
 
1264
 
-
 
1265
//            this is creating for escalation filtered fofo id in case of if rbm is l1
-
 
1266
 
-
 
1267
            List<Integer> fofoIds = fofoIdList;
-
 
1268
 
-
 
1269
            if (isRBMAndL1) {
-
 
1270
                fofoIds = partnerCollectionRemarks.entrySet().stream()
-
 
1271
                        // Filter for fofoIds where the escalation type is neither RBM nor Sale
-
 
1272
                        .filter(entry -> {
-
 
1273
                            PartnerCollectionRemark pcrMap = entry.getValue();
-
 
1274
                            return !(CollectionRemark.RBM_L2_ESCALATION.equals(pcrMap.getRemark())
-
 
1275
                                    || CollectionRemark.SALES_ESCALATION.equals(pcrMap.getRemark()));
-
 
1276
                        })
-
 
1277
                        .map(Map.Entry::getKey) // Map to the fofoId
-
 
1278
                        .collect(Collectors.toList()); // Collect the result as a List
-
 
1279
            }
-
 
1280
 
1247
 
1281
            if (fofoIds.size() > 0) {
1248
            if (fofoIds.size() > 0) {
1282
                fofoIds = fofoStoreRepository.selectByRetailerIds(fofoIds).stream().filter(x -> !x.isInternal()).map(x -> x.getId()).collect(Collectors.toList());
1249
                fofoIds = fofoStoreRepository.selectByRetailerIds(fofoIds).stream().filter(x -> !x.isInternal()).map(x -> x.getId()).collect(Collectors.toList());
1283
 
1250
 
1284
                /*
1251
                /*
1285
                 * Map<Integer, PartnerCollectionPlanModel> foundCollectionMap =
1252
                 * Map<Integer, PartnerCollectionPlanModel> foundCollectionMap =
1286
                 * partnerCollectionService .getCollectionMap(fofoIds, startDate);
1253
                 * partnerCollectionService .getCollectionMap(fofoIds, startDate);
1287
                 */
1254
                 */
1288
 
1255
 
-
 
1256
                List<Integer> remarkIds = partnerCollectionRemarkRepository.selectMaxRemarkId(fofoIds);
-
 
1257
 
1289
                LOGGER.info("remarkIds {}", remarkIds);
1258
                LOGGER.info("remarkIds {}", remarkIds);
1290
 
1259
 
1291
                long todayOverallCall = 0;
1260
                long todayOverallCall = 0;
1292
                if (!remarkIds.isEmpty()) {
1261
                if (!remarkIds.isEmpty()) {
1293
                    todayOverallCall = partnerCollectionRemarkRepository.selectByIds(remarkIds).stream().filter(x -> x.getCreateTimestamp().toLocalDate().equals(LocalDate.now())).collect(Collectors.counting());
1262
                    todayOverallCall = partnerCollectionRemarkRepository.selectByIds(remarkIds).stream().filter(x -> x.getCreateTimestamp().toLocalDate().equals(LocalDate.now())).collect(Collectors.counting());