| Line 38... |
Line 38... |
| 38 |
import com.spice.profitmandi.dao.entity.user.*;
|
38 |
import com.spice.profitmandi.dao.entity.user.*;
|
| 39 |
import com.spice.profitmandi.dao.entity.warehouse.WarehouseInventoryItem;
|
39 |
import com.spice.profitmandi.dao.entity.warehouse.WarehouseInventoryItem;
|
| 40 |
import com.spice.profitmandi.dao.entity.warehouse.WarehouseScan;
|
40 |
import com.spice.profitmandi.dao.entity.warehouse.WarehouseScan;
|
| 41 |
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
|
41 |
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
|
| 42 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
42 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| - |
|
43 |
import com.spice.profitmandi.dao.enumuration.catalog.StockTransactionType;
|
| 43 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
44 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 44 |
import com.spice.profitmandi.dao.enumuration.dtr.RefferalStatus;
|
45 |
import com.spice.profitmandi.dao.enumuration.dtr.RefferalStatus;
|
| 45 |
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
|
46 |
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
|
| 46 |
import com.spice.profitmandi.dao.enumuration.fofo.PaymentStatus;
|
47 |
import com.spice.profitmandi.dao.enumuration.fofo.PaymentStatus;
|
| 47 |
import com.spice.profitmandi.dao.enumuration.fofo.ReturnType;
|
48 |
import com.spice.profitmandi.dao.enumuration.fofo.ReturnType;
|
| 48 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
49 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
| 49 |
import com.spice.profitmandi.dao.enumuration.inventory.CatalogMovingEnum;
|
50 |
import com.spice.profitmandi.dao.enumuration.inventory.CatalogMovingEnum;
|
| 50 |
import com.spice.profitmandi.dao.enumuration.inventory.VendorCatalogPricingStatus;
|
51 |
import com.spice.profitmandi.dao.enumuration.inventory.VendorCatalogPricingStatus;
|
| 51 |
import com.spice.profitmandi.dao.enumuration.transaction.*;
|
52 |
import com.spice.profitmandi.dao.enumuration.transaction.CreditRisk;
|
| - |
|
53 |
import com.spice.profitmandi.dao.enumuration.transaction.LoanReferenceType;
|
| - |
|
54 |
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
|
| - |
|
55 |
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
|
| 52 |
import com.spice.profitmandi.dao.model.*;
|
56 |
import com.spice.profitmandi.dao.model.*;
|
| 53 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
57 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
| 54 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
58 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 55 |
import com.spice.profitmandi.dao.repository.auth.NonSdBuyingRepository;
|
59 |
import com.spice.profitmandi.dao.repository.auth.NonSdBuyingRepository;
|
| 56 |
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionRemarkRepository;
|
60 |
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionRemarkRepository;
|
| Line 112... |
Line 116... |
| 112 |
import org.apache.http.entity.StringEntity;
|
116 |
import org.apache.http.entity.StringEntity;
|
| 113 |
import org.apache.http.impl.client.CloseableHttpClient;
|
117 |
import org.apache.http.impl.client.CloseableHttpClient;
|
| 114 |
import org.apache.http.impl.client.HttpClients;
|
118 |
import org.apache.http.impl.client.HttpClients;
|
| 115 |
import org.apache.logging.log4j.LogManager;
|
119 |
import org.apache.logging.log4j.LogManager;
|
| 116 |
import org.apache.logging.log4j.Logger;
|
120 |
import org.apache.logging.log4j.Logger;
|
| 117 |
import org.hibernate.Session;
|
- |
|
| 118 |
import org.hibernate.SessionFactory;
|
121 |
import org.hibernate.SessionFactory;
|
| 119 |
import org.hibernate.query.NativeQuery;
|
- |
|
| 120 |
import org.json.JSONObject;
|
122 |
import org.json.JSONObject;
|
| 121 |
import org.springframework.beans.factory.annotation.Autowired;
|
123 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 122 |
import org.springframework.beans.factory.annotation.Qualifier;
|
124 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 123 |
import org.springframework.beans.factory.annotation.Value;
|
125 |
import org.springframework.beans.factory.annotation.Value;
|
| 124 |
import org.springframework.core.io.ByteArrayResource;
|
126 |
import org.springframework.core.io.ByteArrayResource;
|
| Line 749... |
Line 751... |
| 749 |
|
751 |
|
| 750 |
@Autowired
|
752 |
@Autowired
|
| 751 |
private PartnerStatsService partnerStatsService;
|
753 |
private PartnerStatsService partnerStatsService;
|
| 752 |
|
754 |
|
| 753 |
// Temporary Method
|
755 |
// Temporary Method
|
| 754 |
public void evaluateExcessSchemeOut() throws Exception {
|
- |
|
| 755 |
Map<Integer, String> userNameMap = retailerService.getAllFofoRetailerIdNameMap();
|
- |
|
| 756 |
Map<Integer, Float> userAmountMap = new HashMap<>();
|
- |
|
| 757 |
|
- |
|
| 758 |
List<List<?>> rows = new ArrayList<>();
|
- |
|
| 759 |
List<String> headers = Arrays.asList("Scheme", "Item", "Partner", "Amount", "Credited On", "Invoice Number", "Sale On", "Scheme Start", "Scheme End", "Active On", "Expired On");
|
- |
|
| 760 |
for (Scheme scheme : schemeRepository.selectAll()) {
|
- |
|
| 761 |
if (scheme.getType().equals(SchemeType.OUT)) {
|
- |
|
| 762 |
List<SchemeInOut> sioList = schemeInOutRepository.selectBySchemeIds(new HashSet<>(Arrays.asList(scheme.getId())));
|
- |
|
| 763 |
if (scheme.getActiveTimestamp() != null) {
|
- |
|
| 764 |
LocalDateTime endDateTime = scheme.getEndDateTime();
|
- |
|
| 765 |
if (scheme.getExpireTimestamp() != null && scheme.getExpireTimestamp().isBefore(scheme.getEndDateTime())) {
|
- |
|
| 766 |
endDateTime = scheme.getExpireTimestamp();
|
- |
|
| 767 |
}
|
- |
|
| 768 |
for (SchemeInOut sio : sioList) {
|
- |
|
| 769 |
InventoryItem inventoryItem = null;
|
- |
|
| 770 |
inventoryItem = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
- |
|
| 771 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndSerialNumber(
|
- |
|
| 772 |
inventoryItem.getFofoId(), inventoryItem.getSerialNumber(), null, null, 0, 1).get(0);
|
- |
|
| 773 |
Optional<ScanRecord> record = scanRecordRepository.selectByInventoryItemId(sio.getInventoryItemId()).stream().filter(y -> y.getType().equals(ScanType.SALE)).findFirst();
|
- |
|
| 774 |
if (record.isPresent()) {
|
- |
|
| 775 |
int fofoId = record.get().getFofoId();
|
- |
|
| 776 |
if (record.get().getCreateTimestamp().isAfter(endDateTime) || record.get().getCreateTimestamp().isBefore(scheme.getStartDateTime())) {
|
- |
|
| 777 |
if (!userAmountMap.containsKey(fofoId)) {
|
- |
|
| 778 |
userAmountMap.put(fofoId, 0f);
|
- |
|
| 779 |
}
|
- |
|
| 780 |
userAmountMap.put(fofoId, sio.getAmount() + userAmountMap.get(fofoId));
|
- |
|
| 781 |
try {
|
- |
|
| 782 |
rows.add(Arrays.asList(scheme.getDescription(), itemRepository.selectById(inventoryItem.getItemId()).getItemDescription(), userNameMap.get(fofoId), sio.getAmount(), FormattingUtils.formatDate(sio.getCreateTimestamp()), fofoOrder.getInvoiceNumber(), FormattingUtils.formatDate(record.get().getCreateTimestamp()), FormattingUtils.formatDate(scheme.getStartDateTime()), FormattingUtils.formatDate(scheme.getEndDateTime()), FormattingUtils.formatDate(scheme.getActiveTimestamp()), FormattingUtils.formatDate(scheme.getExpireTimestamp())));
|
- |
|
| 783 |
} catch (Exception e) {
|
- |
|
| 784 |
e.printStackTrace();
|
- |
|
| 785 |
}
|
- |
|
| 786 |
}
|
- |
|
| 787 |
}
|
- |
|
| 788 |
}
|
- |
|
| 789 |
}
|
- |
|
| 790 |
}
|
- |
|
| 791 |
}
|
- |
|
| 792 |
userAmountMap.entrySet().stream().forEach(x -> LOGGER.info("{} to be deducted from {}({}) for wrongly disbursed due to technical error.", x.getValue(), userNameMap.get(x.getKey())));
|
- |
|
| 793 |
|
- |
|
| 794 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
- |
|
| 795 |
Utils.sendMailWithAttachment(googleMailSender, new String[]{"amit.gupta@shop2020.in"}, null, "Partner Excess Amount", "PFA", "ListofSchemes.csv", new ByteArrayResource(baos.toByteArray()));
|
- |
|
| 796 |
|
- |
|
| 797 |
}
|
- |
|
| 798 |
|
756 |
|
| 799 |
public void fetchParnterStats() throws Exception {
|
757 |
public void fetchParnterStats() throws Exception {
|
| 800 |
Map<Integer, PartnerDetailModel> partnerStats = partnerStatsService.getAllPartnerStats();
|
758 |
Map<Integer, PartnerDetailModel> partnerStats = partnerStatsService.getAllPartnerStats();
|
| 801 |
ObjectOutputStream oos = null;
|
759 |
ObjectOutputStream oos = null;
|
| 802 |
FileOutputStream fout = null;
|
760 |
FileOutputStream fout = null;
|
| Line 1068... |
Line 1026... |
| 1068 |
|
1026 |
|
| 1069 |
@Autowired
|
1027 |
@Autowired
|
| 1070 |
PurSaleService purSaleService;
|
1028 |
PurSaleService purSaleService;
|
| 1071 |
|
1029 |
|
| 1072 |
public void test() throws Exception {
|
1030 |
public void test() throws Exception {
|
| 1073 |
System.out.println("test start");
|
1031 |
//List<TotalLoanAmountDueModel> totalLoanAmountDueModels = loanRepository.getDueLoansByFofoId(175139438);
|
| 1074 |
// this.send10OrMoreOrderStockReport();
|
1032 |
//System.out.println(totalLoanAmountDueModels);
|
| 1075 |
System.out.println("test end");
|
1033 |
runOnceTasks.findCNDiff();
|
| 1076 |
|
- |
|
| 1077 |
}
|
1034 |
}
|
| 1078 |
|
1035 |
|
| 1079 |
public void test4() throws Exception {
|
1036 |
public void test4() throws Exception {
|
| 1080 |
List<Integer> offerIds = Arrays.asList(2882, 2881, 2880, 2879, 2878, 2877, 2876, 2875, 2874, 2873, 2872, 2871, 2870, 2869, 2868, 2867, 2866, 2865, 2864, 2863, 2862, 2861, 2860, 2859, 2858, 2857, 2856, 2855, 2854, 2853, 2852, 2851, 2850, 2849, 2847, 2846, 2845, 2844, 2843, 2842, 2841, 2840, 2839, 2838, 2837, 2836, 2835, 2834, 2833, 2832, 2831, 2830, 2829, 2828, 2827, 2826, 2825, 2824, 2823, 2822, 2821, 2820, 2819, 2818, 2817, 2816, 2815, 2814, 2813, 2812, 2811, 2810, 2809, 2808, 2807, 2806, 2805, 2804, 2803, 2802, 2801, 2800, 2799, 2798, 2797, 2796, 2795, 2794, 2793, 2792, 2791, 2790, 2789, 2788, 2787, 2786, 2785, 2784, 2783, 2782, 2781, 2780, 2777, 2776, 2775, 2774, 2773, 2772, 2771, 2770, 2769, 2768, 2767, 2766, 2765, 2764, 2763, 2762, 2761, 2760, 2759, 2758, 2757, 2756, 2755, 2754, 2753, 2752, 2751, 2750, 2749, 2748, 2747, 2746, 2745, 2744, 2723, 2722, 2721, 2720, 2719, 2718, 2717, 2716, 2715, 2714, 2713, 2712, 2711, 2710, 2709, 2708, 2707, 2706, 2705, 2704, 2703, 2702, 2701, 2700, 2699, 2698, 2697, 2696, 2695, 2694, 2693, 2692, 2691, 2690, 2494, 2493, 2492, 2491, 2490, 2489, 2488, 2487, 2486, 2485, 2484, 2483, 2482, 2481, 2480, 2479, 2478, 2477, 2476, 2475, 2474, 2473, 2472, 2471, 2470, 2469, 2466, 2465, 2464, 2463, 2462, 2461, 2460, 2459, 2458, 2457, 2456, 2455, 2454, 2453, 2452, 2451, 2450, 2449, 2448, 2447, 2446, 2445, 2444, 2443, 2442, 2441, 2440, 2439, 2407, 2406, 2405, 2404, 2403, 2402, 2401, 2400, 2399, 2398, 2397, 2396, 2395, 2394, 2393, 2392, 2391, 2390, 2389, 2388, 2387, 2386, 2385, 2384, 2383, 2382, 2381, 2117, 2116, 2115, 2114, 2113, 2112, 2111, 2110, 2109, 2108, 2107, 2106, 2105, 2104, 2103, 2102, 2101, 2100, 2099, 2098, 2077);
|
1037 |
List<Integer> offerIds = Arrays.asList(2882, 2881, 2880, 2879, 2878, 2877, 2876, 2875, 2874, 2873, 2872, 2871, 2870, 2869, 2868, 2867, 2866, 2865, 2864, 2863, 2862, 2861, 2860, 2859, 2858, 2857, 2856, 2855, 2854, 2853, 2852, 2851, 2850, 2849, 2847, 2846, 2845, 2844, 2843, 2842, 2841, 2840, 2839, 2838, 2837, 2836, 2835, 2834, 2833, 2832, 2831, 2830, 2829, 2828, 2827, 2826, 2825, 2824, 2823, 2822, 2821, 2820, 2819, 2818, 2817, 2816, 2815, 2814, 2813, 2812, 2811, 2810, 2809, 2808, 2807, 2806, 2805, 2804, 2803, 2802, 2801, 2800, 2799, 2798, 2797, 2796, 2795, 2794, 2793, 2792, 2791, 2790, 2789, 2788, 2787, 2786, 2785, 2784, 2783, 2782, 2781, 2780, 2777, 2776, 2775, 2774, 2773, 2772, 2771, 2770, 2769, 2768, 2767, 2766, 2765, 2764, 2763, 2762, 2761, 2760, 2759, 2758, 2757, 2756, 2755, 2754, 2753, 2752, 2751, 2750, 2749, 2748, 2747, 2746, 2745, 2744, 2723, 2722, 2721, 2720, 2719, 2718, 2717, 2716, 2715, 2714, 2713, 2712, 2711, 2710, 2709, 2708, 2707, 2706, 2705, 2704, 2703, 2702, 2701, 2700, 2699, 2698, 2697, 2696, 2695, 2694, 2693, 2692, 2691, 2690, 2494, 2493, 2492, 2491, 2490, 2489, 2488, 2487, 2486, 2485, 2484, 2483, 2482, 2481, 2480, 2479, 2478, 2477, 2476, 2475, 2474, 2473, 2472, 2471, 2470, 2469, 2466, 2465, 2464, 2463, 2462, 2461, 2460, 2459, 2458, 2457, 2456, 2455, 2454, 2453, 2452, 2451, 2450, 2449, 2448, 2447, 2446, 2445, 2444, 2443, 2442, 2441, 2440, 2439, 2407, 2406, 2405, 2404, 2403, 2402, 2401, 2400, 2399, 2398, 2397, 2396, 2395, 2394, 2393, 2392, 2391, 2390, 2389, 2388, 2387, 2386, 2385, 2384, 2383, 2382, 2381, 2117, 2116, 2115, 2114, 2113, 2112, 2111, 2110, 2109, 2108, 2107, 2106, 2105, 2104, 2103, 2102, 2101, 2100, 2099, 2098, 2077);
|
| 1081 |
for (Integer offerId : offerIds) {
|
1038 |
for (Integer offerId : offerIds) {
|
| Line 1391... |
Line 1348... |
| 1391 |
// }
|
1348 |
// }
|
| 1392 |
|
1349 |
|
| 1393 |
@Autowired
|
1350 |
@Autowired
|
| 1394 |
SessionFactory sessionFactory;
|
1351 |
SessionFactory sessionFactory;
|
| 1395 |
|
1352 |
|
| 1396 |
private void checkAllPayoutsDuplicate() throws Exception {
|
- |
|
| 1397 |
final Session session = sessionFactory.getCurrentSession();
|
- |
|
| 1398 |
final NativeQuery<Object[]> nativeQuery = session.createNativeQuery("select sio.inventory_item_id, sio.scheme_id, sio.status, count(*) c\n" + "from fofo.scheme_in_out sio\n" + " join catalog.scheme s on s.id = sio.scheme_id\n" + "where (sio.status = 'CREDITED'\n" + " or sio.status = 'PENDING')\n" + " and s.type != 'INVESTMENT'\n" + " and sio.create_timestamp >= '2023-01-01' " + "group by sio.inventory_item_id, sio.scheme_id, sio.status\n" + "having c > 1");
|
- |
|
| 1399 |
List<Object[]> resultList = nativeQuery.getResultList();
|
- |
|
| 1400 |
for (Object[] tuple : resultList) {
|
- |
|
| 1401 |
LOGGER.info("RESULT -- {}, {}, {}", tuple[0], tuple[1], tuple[2]);
|
- |
|
| 1402 |
int inventoryItemId = (Integer) tuple[0];
|
- |
|
| 1403 |
int schemeId = (Integer) tuple[1];
|
- |
|
| 1404 |
SchemePayoutStatus schemePayoutStatus = SchemePayoutStatus.valueOf((String) tuple[2]);
|
- |
|
| 1405 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectByScheme(schemeId, inventoryItemId);
|
- |
|
| 1406 |
List<SchemeInOut> statusSpecificSchemeInOuts = schemeInOuts.stream().filter(x -> x.getStatus().equals(schemePayoutStatus)).collect(Collectors.toList());
|
- |
|
| 1407 |
if (statusSpecificSchemeInOuts.size() > 0) {
|
- |
|
| 1408 |
InventoryItem inventoryItem = inventoryItemRepository.selectById(inventoryItemId);
|
- |
|
| 1409 |
Scheme scheme = schemeRepository.selectById(schemeId);
|
- |
|
| 1410 |
List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(inventoryItemId);
|
- |
|
| 1411 |
if (scheme.getType().equals(SchemeType.IN)) {
|
- |
|
| 1412 |
LOGGER.info("Skipping -- {}", inventoryItem.getSerialNumber());
|
- |
|
| 1413 |
} else {
|
- |
|
| 1414 |
int fofoOrderId = scanRecords.stream().filter(x -> x.getOrderId() != 0).max(Comparator.comparing(x -> x.getOrderId())).get().getOrderId();
|
- |
|
| 1415 |
WalletReferenceType walletReferenceType = SchemeType.ACTIVATION.equals(scheme.getType()) ? WalletReferenceType.ACTIVATION_SCHEME : SchemeType.SPECIAL_SUPPORT.equals(scheme.getType()) ? WalletReferenceType.SPECIAL_SUPPORT : WalletReferenceType.SCHEME_OUT;
|
- |
|
| 1416 |
List<UserWalletHistory> userWalletHistoryList = userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(fofoOrderId, walletReferenceType).stream().filter(x -> x.getAmount() == Math.round(statusSpecificSchemeInOuts.get(0).getAmount())).collect(Collectors.toList());
|
- |
|
| 1417 |
LOGGER.info("UserwalletHistory Entry --> {}, Sios --> {}", userWalletHistoryList.size(), statusSpecificSchemeInOuts.size());
|
- |
|
| 1418 |
if (userWalletHistoryList.size() != statusSpecificSchemeInOuts.size()) {
|
- |
|
| 1419 |
//Skipping them in first run as it is the special casw of upgrade where mismatch has happend.
|
- |
|
| 1420 |
LOGGER.info("problem with {}, sio status - {}, inventoryItem id {}, schemeID {} ", fofoOrderId, statusSpecificSchemeInOuts.stream().map(x -> x.getStatus()).collect(Collectors.toList()), inventoryItemId, schemeId);
|
- |
|
| 1421 |
//Primarily multiple pending cases
|
- |
|
| 1422 |
statusSpecificSchemeInOuts.stream().skip(1).forEach(schemeInOut -> {
|
- |
|
| 1423 |
schemeInOut.setStatus(SchemePayoutStatus.REJECTED);
|
- |
|
| 1424 |
schemeInOut.setStatusDescription("Rejected as entry is duplicate");
|
- |
|
| 1425 |
});
|
- |
|
| 1426 |
} else {
|
- |
|
| 1427 |
userWalletHistoryList.stream().skip(1).forEach(userWalletHistory -> {
|
- |
|
| 1428 |
try {
|
- |
|
| 1429 |
walletService.rollbackAmountFromWallet(inventoryItem.getFofoId(), userWalletHistory.getAmount(), userWalletHistory.getReference(), userWalletHistory.getReferenceType(), "Reversal as multiple entries created", userWalletHistory.getBusinessTimestamp());
|
- |
|
| 1430 |
} catch (ProfitMandiBusinessException e) {
|
- |
|
| 1431 |
throw new RuntimeException(e);
|
- |
|
| 1432 |
}
|
- |
|
| 1433 |
});
|
- |
|
| 1434 |
|
- |
|
| 1435 |
statusSpecificSchemeInOuts.stream().skip(1).forEach(schemeInOut -> {
|
- |
|
| 1436 |
schemeInOut.setStatus(SchemePayoutStatus.REJECTED);
|
- |
|
| 1437 |
if (schemePayoutStatus.equals(SchemePayoutStatus.CREDITED)) {
|
- |
|
| 1438 |
schemeInOut.setRolledBackTimestamp(LocalDateTime.now());
|
- |
|
| 1439 |
schemeInOut.setStatusDescription("Rolled back as entry is duplicate");
|
- |
|
| 1440 |
} else {
|
- |
|
| 1441 |
LOGGER.info("This seems higly unreachable should not come here");
|
- |
|
| 1442 |
schemeInOut.setStatusDescription("Rejected as entry is duplicate");
|
- |
|
| 1443 |
}
|
- |
|
| 1444 |
});
|
- |
|
| 1445 |
}
|
- |
|
| 1446 |
}
|
- |
|
| 1447 |
}
|
- |
|
| 1448 |
}
|
- |
|
| 1449 |
}
|
- |
|
| 1450 |
|
1353 |
|
| 1451 |
public void sendMailForSamsungRebilling() throws Exception {
|
1354 |
public void sendMailForSamsungRebilling() throws Exception {
|
| 1452 |
List<BilledImeiModel> samsungModels = warehouseInventoryItemRepository.findByBillingDateBrand(LocalDate.now(), "Samsung");
|
1355 |
List<BilledImeiModel> samsungModels = warehouseInventoryItemRepository.findByBillingDateBrand(LocalDate.now(), "Samsung");
|
| 1453 |
LOGGER.info("SamsungModels {}", samsungModels);
|
1356 |
LOGGER.info("SamsungModels {}", samsungModels);
|
| 1454 |
samsungModels = samsungModels.stream().sorted(Comparator.comparing(x -> x.getPcmDate() == null ? -1 : 1)).collect(Collectors.toList());
|
1357 |
samsungModels = samsungModels.stream().sorted(Comparator.comparing(x -> x.getPcmDate() == null ? -1 : 1)).collect(Collectors.toList());
|
| Line 1906... |
Line 1809... |
| 1906 |
}
|
1809 |
}
|
| 1907 |
}
|
1810 |
}
|
| 1908 |
|
1811 |
|
| 1909 |
}
|
1812 |
}
|
| 1910 |
|
1813 |
|
| 1911 |
public void dryRunSchemeReco() throws Exception {
|
- |
|
| 1912 |
Map<Integer, Integer> userWalletMap = userWalletRepository.selectAll().stream().collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
- |
|
| 1913 |
|
- |
|
| 1914 |
List<UserWalletHistory> userWalletHistory = new ArrayList<>();
|
- |
|
| 1915 |
List<SchemeInOut> rolledbackSios = new ArrayList<>();
|
- |
|
| 1916 |
Map<Integer, SchemeType> schemeTypeMap = schemeRepository.selectAll().stream().collect(Collectors.toMap(Scheme::getId, Scheme::getType));
|
- |
|
| 1917 |
Set<String> serialNumbersConsidered = new HashSet<>();
|
- |
|
| 1918 |
|
- |
|
| 1919 |
LocalDateTime startDate = LocalDate.of(2018, 3, 1).atStartOfDay();
|
- |
|
| 1920 |
LocalDateTime endDate = LocalDate.now().atStartOfDay();
|
- |
|
| 1921 |
List<Purchase> purchases = purchaseRepository.selectAllBetweenPurchaseDate(startDate, endDate);
|
- |
|
| 1922 |
|
- |
|
| 1923 |
Map<Integer, String> storeNameMap = fofoStoreRepository.getStoresMap();
|
- |
|
| 1924 |
for (Purchase purchase : purchases) {
|
- |
|
| 1925 |
float amountToRollback = 0;
|
- |
|
| 1926 |
String description = "Adjustment of Duplicate Scheme for Purchase Invoice " + purchase.getPurchaseReference();
|
- |
|
| 1927 |
Map<Integer, String> inventorySerialNumberMap = inventoryItemRepository.selectByPurchaseId(purchase.getId()).stream().filter(ii -> ii.getSerialNumber() != null).collect(Collectors.toMap(InventoryItem::getId, InventoryItem::getSerialNumber));
|
- |
|
| 1928 |
if (inventorySerialNumberMap.size() > 0) {
|
- |
|
| 1929 |
for (Entry<Integer, String> inventorySerialNumberEntry : inventorySerialNumberMap.entrySet()) {
|
- |
|
| 1930 |
String serialNumber = inventorySerialNumberEntry.getValue();
|
- |
|
| 1931 |
int inventoryItemId = inventorySerialNumberEntry.getKey();
|
- |
|
| 1932 |
if (serialNumbersConsidered.contains(serialNumber)) {
|
- |
|
| 1933 |
// This will rollback scheme for differenct orders for same serial
|
- |
|
| 1934 |
List<SchemeInOut> sios = schemeInOutRepository.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream().filter(x -> x.getRolledBackTimestamp() == null && schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.IN)).collect(Collectors.toList());
|
- |
|
| 1935 |
Collections.reverse(sios);
|
- |
|
| 1936 |
for (SchemeInOut sio : sios) {
|
- |
|
| 1937 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
- |
|
| 1938 |
amountToRollback += sio.getAmount();
|
- |
|
| 1939 |
// sio.setSchemeType(SchemeType.OUT);
|
- |
|
| 1940 |
sio.setSerialNumber(serialNumber);
|
- |
|
| 1941 |
rolledbackSios.add(sio);
|
- |
|
| 1942 |
}
|
- |
|
| 1943 |
description = description.concat(" " + serialNumber + " ");
|
- |
|
| 1944 |
} else {
|
- |
|
| 1945 |
serialNumbersConsidered.add(serialNumber);
|
- |
|
| 1946 |
List<Integer> schemesConsidered = new ArrayList<>();
|
- |
|
| 1947 |
List<SchemeInOut> sios = schemeInOutRepository.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream().filter(x -> x.getRolledBackTimestamp() == null && schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.IN)).collect(Collectors.toList());
|
- |
|
| 1948 |
Collections.reverse(sios);
|
- |
|
| 1949 |
for (SchemeInOut sio : sios) {
|
- |
|
| 1950 |
if (!schemesConsidered.contains(sio.getSchemeId())) {
|
- |
|
| 1951 |
schemesConsidered.add(sio.getSchemeId());
|
- |
|
| 1952 |
continue;
|
- |
|
| 1953 |
}
|
- |
|
| 1954 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
- |
|
| 1955 |
amountToRollback += sio.getAmount();
|
- |
|
| 1956 |
// sio.setSchemeType(SchemeType.OUT);
|
- |
|
| 1957 |
sio.setSerialNumber(serialNumber);
|
- |
|
| 1958 |
sio.setStoreCode(storeNameMap.get(purchase.getFofoId()));
|
- |
|
| 1959 |
sio.setReference(purchase.getId());
|
- |
|
| 1960 |
rolledbackSios.add(sio);
|
- |
|
| 1961 |
}
|
- |
|
| 1962 |
}
|
- |
|
| 1963 |
|
- |
|
| 1964 |
}
|
- |
|
| 1965 |
}
|
- |
|
| 1966 |
if (amountToRollback > 0) {
|
- |
|
| 1967 |
// Address address =
|
- |
|
| 1968 |
// addressRepository.selectAllByRetailerId(purchase.getFofoId(), 0, 10).get(0);
|
- |
|
| 1969 |
UserWalletHistory uwh = new UserWalletHistory();
|
- |
|
| 1970 |
uwh.setAmount(Math.round(amountToRollback));
|
- |
|
| 1971 |
uwh.setDescription(description);
|
- |
|
| 1972 |
uwh.setTimestamp(LocalDateTime.now());
|
- |
|
| 1973 |
uwh.setReferenceType(WalletReferenceType.SCHEME_IN);
|
- |
|
| 1974 |
uwh.setReference(purchase.getId());
|
- |
|
| 1975 |
uwh.setWalletId(userWalletMap.get(purchase.getFofoId()));
|
- |
|
| 1976 |
uwh.setFofoId(purchase.getFofoId());
|
- |
|
| 1977 |
uwh.setStoreCode(storeNameMap.get(purchase.getFofoId()));
|
- |
|
| 1978 |
userWalletHistory.add(uwh);
|
- |
|
| 1979 |
}
|
- |
|
| 1980 |
}
|
- |
|
| 1981 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
- |
|
| 1982 |
Arrays.asList("User Id", "Store Code", "Reference Type", "Reference", "Amount", "Description", "Timestamp"), userWalletHistory.stream().map(x -> Arrays.asList(x.getWalletId(), x.getStoreCode(), x.getReferenceType(), x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp())).collect(Collectors.toList()));
|
- |
|
| 1983 |
|
- |
|
| 1984 |
ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
|
- |
|
| 1985 |
Arrays.asList("Scheme ID", "SchemeType", "Reference", "Store Code", "Serial Number", "Amount", "Created", "Rolledback"), rolledbackSios.stream().map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getReference(), x.getStoreCode(), x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp())).collect(Collectors.toList()));
|
- |
|
| 1986 |
|
- |
|
| 1987 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@shop2020.in"}, null, "Partner Excess Amount Scheme In", "PFA", new Attachment[]{new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())), new Attachment("SchemeInRolledback.csv", new ByteArrayResource(baosOuts.toByteArray()))});
|
- |
|
| 1988 |
|
- |
|
| 1989 |
throw new Exception();
|
- |
|
| 1990 |
|
- |
|
| 1991 |
}
|
- |
|
| 1992 |
|
- |
|
| 1993 |
public void dryRunOutSchemeReco() throws Exception {
|
- |
|
| 1994 |
List<UserWalletHistory> userWalletHistory = new ArrayList<>();
|
- |
|
| 1995 |
List<SchemeInOut> rolledbackSios = new ArrayList<>();
|
- |
|
| 1996 |
Map<Integer, Integer> userWalletMap = userWalletRepository.selectAll().stream().collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
- |
|
| 1997 |
Map<Integer, SchemeType> schemeTypeMap = schemeRepository.selectAll().stream().collect(Collectors.toMap(Scheme::getId, Scheme::getType));
|
- |
|
| 1998 |
LocalDateTime startDate = LocalDate.of(2019, 5, 1).atStartOfDay();
|
- |
|
| 1999 |
LocalDateTime endDate = LocalDate.now().atStartOfDay();
|
- |
|
| 2000 |
List<FofoOrder> allOrders = fofoOrderRepository.selectBetweenSaleDate(startDate, endDate);
|
- |
|
| 2001 |
// Collections.reverse(allOrders);
|
- |
|
| 2002 |
// List<FofoOrder> allOrders =
|
- |
|
| 2003 |
// List<FofoOrder> allOrders =
|
- |
|
| 2004 |
// Arrays.asList(fofoOrderRepository.selectByInvoiceNumber("UPGZ019/25"));
|
- |
|
| 2005 |
Set<String> serialNumbersConsidered = new HashSet<>();
|
- |
|
| 2006 |
for (FofoOrder fofoOrder : allOrders) {
|
- |
|
| 2007 |
String description = "Adjustment of Duplicate Scheme for Sale Invoice " + fofoOrder.getInvoiceNumber();
|
- |
|
| 2008 |
Map<Integer, String> inventorySerialNumberMap = new HashMap<>();
|
- |
|
| 2009 |
float amountToRollback = 0;
|
- |
|
| 2010 |
List<FofoOrderItem> orderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
- |
|
| 2011 |
orderItems.forEach(x -> {
|
- |
|
| 2012 |
inventorySerialNumberMap.putAll(x.getFofoLineItems().stream().filter(li -> li.getSerialNumber() != null).collect(Collectors.toMap(FofoLineItem::getInventoryItemId, FofoLineItem::getSerialNumber)));
|
- |
|
| 2013 |
});
|
- |
|
| 2014 |
if (inventorySerialNumberMap.size() > 0) {
|
- |
|
| 2015 |
for (Entry<Integer, String> inventorySerialNumberEntry : inventorySerialNumberMap.entrySet()) {
|
- |
|
| 2016 |
String serialNumber = inventorySerialNumberEntry.getValue();
|
- |
|
| 2017 |
int inventoryItemId = inventorySerialNumberEntry.getKey();
|
- |
|
| 2018 |
if (serialNumbersConsidered.contains(serialNumber)) {
|
- |
|
| 2019 |
// This will rollback scheme for differenct orders for same serial
|
- |
|
| 2020 |
List<SchemeInOut> sios = new ArrayList<>();
|
- |
|
| 2021 |
for (SchemeInOut schemeInOut : schemeInOutRepository.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId)))) {
|
- |
|
| 2022 |
if (schemeInOut.getRolledBackTimestamp() == null && schemeTypeMap.get(schemeInOut.getSchemeId()).equals(SchemeType.OUT)) {
|
- |
|
| 2023 |
sios.add(schemeInOut);
|
- |
|
| 2024 |
}
|
- |
|
| 2025 |
}
|
- |
|
| 2026 |
Collections.reverse(sios);
|
- |
|
| 2027 |
for (SchemeInOut sio : sios) {
|
- |
|
| 2028 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
- |
|
| 2029 |
amountToRollback += sio.getAmount();
|
- |
|
| 2030 |
// sio.setSchemeType(SchemeType.OUT);
|
- |
|
| 2031 |
sio.setSerialNumber(serialNumber);
|
- |
|
| 2032 |
sio.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
|
- |
|
| 2033 |
sio.setReference(fofoOrder.getId());
|
- |
|
| 2034 |
rolledbackSios.add(sio);
|
- |
|
| 2035 |
}
|
- |
|
| 2036 |
description = description.concat(" " + serialNumber + " ");
|
- |
|
| 2037 |
} else {
|
- |
|
| 2038 |
serialNumbersConsidered.add(serialNumber);
|
- |
|
| 2039 |
List<Integer> schemesConsidered = new ArrayList<>();
|
- |
|
| 2040 |
List<SchemeInOut> sios = schemeInOutRepository.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream().filter(x -> x.getRolledBackTimestamp() == null && schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.OUT)).collect(Collectors.toList());
|
- |
|
| 2041 |
Collections.reverse(sios);
|
- |
|
| 2042 |
for (SchemeInOut sio : sios) {
|
- |
|
| 2043 |
if (!schemesConsidered.contains(sio.getSchemeId())) {
|
- |
|
| 2044 |
schemesConsidered.add(sio.getSchemeId());
|
- |
|
| 2045 |
continue;
|
- |
|
| 2046 |
}
|
- |
|
| 2047 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
- |
|
| 2048 |
amountToRollback += sio.getAmount();
|
- |
|
| 2049 |
// sio.setSchemeType(SchemeType.OUT);
|
- |
|
| 2050 |
sio.setReference(fofoOrder.getId());
|
- |
|
| 2051 |
sio.setSerialNumber(serialNumber);
|
- |
|
| 2052 |
sio.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
|
- |
|
| 2053 |
rolledbackSios.add(sio);
|
- |
|
| 2054 |
}
|
- |
|
| 2055 |
}
|
- |
|
| 2056 |
|
- |
|
| 2057 |
}
|
- |
|
| 2058 |
}
|
- |
|
| 2059 |
if (amountToRollback > 0) {
|
- |
|
| 2060 |
UserWalletHistory uwh = new UserWalletHistory();
|
- |
|
| 2061 |
uwh.setAmount(Math.round(amountToRollback));
|
- |
|
| 2062 |
uwh.setDescription(description);
|
- |
|
| 2063 |
uwh.setTimestamp(LocalDateTime.now());
|
- |
|
| 2064 |
uwh.setReferenceType(WalletReferenceType.SCHEME_OUT);
|
- |
|
| 2065 |
uwh.setReference(fofoOrder.getId());
|
- |
|
| 2066 |
uwh.setWalletId(userWalletMap.get(fofoOrder.getFofoId()));
|
- |
|
| 2067 |
uwh.setFofoId(fofoOrder.getFofoId());
|
- |
|
| 2068 |
uwh.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
|
- |
|
| 2069 |
userWalletHistory.add(uwh);
|
- |
|
| 2070 |
}
|
- |
|
| 2071 |
}
|
- |
|
| 2072 |
|
- |
|
| 2073 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
- |
|
| 2074 |
Arrays.asList("Wallet Id", "Store Code", "Reference Type", "Reference", "Amount", "Description", "Timestamp"), userWalletHistory.stream().map(x -> Arrays.asList(x.getWalletId(), x.getStoreCode(), x.getReferenceType(), x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp())).collect(Collectors.toList()));
|
- |
|
| 2075 |
|
- |
|
| 2076 |
ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
|
- |
|
| 2077 |
Arrays.asList("Scheme ID", "SchemeType", "Store Code", "Serial Number", "Amount", "Created", "Rolledback"), rolledbackSios.stream().map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getStoreCode(), x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp())).collect(Collectors.toList()));
|
- |
|
| 2078 |
|
- |
|
| 2079 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@shop2020.in"}, null, "Partner Excess Amount Scheme Out", "PFA", new Attachment[]{new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())), new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray()))});
|
- |
|
| 2080 |
|
- |
|
| 2081 |
throw new Exception();
|
- |
|
| 2082 |
}
|
- |
|
| 2083 |
|
- |
|
| 2084 |
public void dryRunSchemeOutReco1() throws Exception {
|
- |
|
| 2085 |
List<Integer> references = Arrays.asList(6744, 7347, 8320, 8891, 9124, 9217, 9263, 9379);
|
- |
|
| 2086 |
List<UserWalletHistory> userWalletHistory = new ArrayList<>();
|
- |
|
| 2087 |
List<SchemeInOut> rolledbackSios = new ArrayList<>();
|
- |
|
| 2088 |
Map<Integer, Integer> userWalletMap = userWalletRepository.selectAll().stream().collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
- |
|
| 2089 |
Map<Integer, SchemeType> schemeTypeMap = schemeRepository.selectAll().stream().collect(Collectors.toMap(Scheme::getId, Scheme::getType));
|
- |
|
| 2090 |
for (Integer reference : references) {
|
- |
|
| 2091 |
FofoOrder fofoOrder = null;
|
- |
|
| 2092 |
try {
|
- |
|
| 2093 |
fofoOrder = fofoOrderRepository.selectByOrderId(reference);
|
- |
|
| 2094 |
} catch (Exception e) {
|
- |
|
| 2095 |
|
- |
|
| 2096 |
}
|
- |
|
| 2097 |
String description = "Adjustment of Duplicate Scheme for Sale Invoice " + fofoOrder.getInvoiceNumber();
|
- |
|
| 2098 |
Map<Integer, String> inventorySerialNumberMap = new HashMap<>();
|
- |
|
| 2099 |
float amountToRollback = 0;
|
- |
|
| 2100 |
List<FofoOrderItem> orderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
- |
|
| 2101 |
orderItems.forEach(x -> {
|
- |
|
| 2102 |
inventorySerialNumberMap.putAll(x.getFofoLineItems().stream().filter(li -> li.getSerialNumber() != null).collect(Collectors.toMap(FofoLineItem::getInventoryItemId, FofoLineItem::getSerialNumber)));
|
- |
|
| 2103 |
});
|
- |
|
| 2104 |
if (inventorySerialNumberMap.size() > 0) {
|
- |
|
| 2105 |
List<SchemeInOut> sios = schemeInOutRepository.selectByInventoryItemIds(inventorySerialNumberMap.keySet()).stream().filter(x -> schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.OUT)).collect(Collectors.toList());
|
- |
|
| 2106 |
LOGGER.info("Found {} duplicate schemeouts for Orderid {}", sios.size(), fofoOrder.getId());
|
- |
|
| 2107 |
UserWalletHistory uwh = new UserWalletHistory();
|
- |
|
| 2108 |
Map<Integer, List<SchemeInOut>> inventoryIdSouts = sios.stream().collect(groupingBy(SchemeInOut::getInventoryItemId, Collectors.toList()));
|
- |
|
| 2109 |
for (Entry<Integer, List<SchemeInOut>> inventorySioEntry : inventoryIdSouts.entrySet()) {
|
- |
|
| 2110 |
List<SchemeInOut> outList = inventorySioEntry.getValue();
|
- |
|
| 2111 |
if (outList.size() > 1) {
|
- |
|
| 2112 |
|
- |
|
| 2113 |
}
|
- |
|
| 2114 |
}
|
- |
|
| 2115 |
uwh.setAmount(Math.round(amountToRollback));
|
- |
|
| 2116 |
uwh.setDescription(description);
|
- |
|
| 2117 |
uwh.setTimestamp(LocalDateTime.now());
|
- |
|
| 2118 |
uwh.setReferenceType(WalletReferenceType.SCHEME_OUT);
|
- |
|
| 2119 |
uwh.setReference(fofoOrder.getId());
|
- |
|
| 2120 |
uwh.setWalletId(userWalletMap.get(fofoOrder.getFofoId()));
|
- |
|
| 2121 |
uwh.setFofoId(fofoOrder.getFofoId());
|
- |
|
| 2122 |
uwh.setStoreCode(fofoOrder.getInvoiceNumber().split("/")[0]);
|
- |
|
| 2123 |
userWalletHistory.add(uwh);
|
- |
|
| 2124 |
}
|
- |
|
| 2125 |
}
|
- |
|
| 2126 |
|
- |
|
| 2127 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
- |
|
| 2128 |
Arrays.asList("User Id", "Reference Type", "Reference", "Amount", "Description", "Timestamp"), userWalletHistory.stream().map(x -> Arrays.asList(x.getWalletId(), x.getReferenceType(), x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp())).collect(Collectors.toList()));
|
- |
|
| 2129 |
|
- |
|
| 2130 |
ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
|
- |
|
| 2131 |
Arrays.asList("Scheme ID", "SchemeType", "Store Code", "Serial Number", "Amount", "Created", "Rolledback"), rolledbackSios.stream().map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getStoreCode(), x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp())).collect(Collectors.toList()));
|
- |
|
| 2132 |
|
- |
|
| 2133 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@shop2020.in", "neeraj.gupta@smartdukaan.com"}, null, "Partner Excess Amount", "PFA", new Attachment[]{new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())), new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray()))});
|
- |
|
| 2134 |
|
- |
|
| 2135 |
throw new Exception();
|
- |
|
| 2136 |
|
- |
|
| 2137 |
}
|
- |
|
| 2138 |
|
- |
|
| 2139 |
public void sendDailySalesNotificationToPartner(Integer fofoIdInt) throws Exception {
|
1814 |
public void sendDailySalesNotificationToPartner(Integer fofoIdInt) throws Exception {
|
| 2140 |
|
1815 |
|
| 2141 |
LocalDateTime now = LocalDateTime.now();
|
1816 |
LocalDateTime now = LocalDateTime.now();
|
| 2142 |
LocalDateTime from = now.with(LocalTime.MIN);
|
1817 |
LocalDateTime from = now.with(LocalTime.MIN);
|
| 2143 |
String timeString = "Today %s";
|
1818 |
String timeString = "Today %s";
|
| Line 2681... |
Line 2356... |
| 2681 |
List<Integer> schemeIdsInt = schemeIds.stream().map(x -> Integer.parseInt(x)).collect(Collectors.toList());
|
2356 |
List<Integer> schemeIdsInt = schemeIds.stream().map(x -> Integer.parseInt(x)).collect(Collectors.toList());
|
| 2682 |
Map<Integer, Scheme> schemesMap = schemeRepository.selectBySchemeIds(schemeIdsInt, 0, schemeIds.size()).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
2357 |
Map<Integer, Scheme> schemesMap = schemeRepository.selectBySchemeIds(schemeIdsInt, 0, schemeIds.size()).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 2683 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectBySchemeIds(new HashSet<>(schemeIdsInt));
|
2358 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectBySchemeIds(new HashSet<>(schemeIdsInt));
|
| 2684 |
for (SchemeInOut sio : schemeInOuts) {
|
2359 |
for (SchemeInOut sio : schemeInOuts) {
|
| 2685 |
Scheme scheme = schemesMap.get(sio.getSchemeId());
|
2360 |
Scheme scheme = schemesMap.get(sio.getSchemeId());
|
| 2686 |
if (scheme.getType().equals(SchemeType.IN)) {
|
2361 |
if (scheme.getType().getTransactionType().equals(StockTransactionType.IN)) {
|
| 2687 |
|
2362 |
|
| 2688 |
} else if (scheme.getType().equals(SchemeType.OUT)) {
|
2363 |
} else if (scheme.getType().getTransactionType().equals(StockTransactionType.OUT)) {
|
| 2689 |
InventoryItem inventoryItem = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
2364 |
InventoryItem inventoryItem = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
| 2690 |
List<ScanRecord> sr = scanRecordRepository.selectByInventoryItemId(sio.getInventoryItemId());
|
2365 |
List<ScanRecord> sr = scanRecordRepository.selectByInventoryItemId(sio.getInventoryItemId());
|
| 2691 |
ScanRecord scanRecord = sr.stream().filter(x -> x.getType().equals(ScanType.SALE)).max((x1, x2) -> x1.getCreateTimestamp().compareTo(x2.getCreateTimestamp())).get();
|
2366 |
ScanRecord scanRecord = sr.stream().filter(x -> x.getType().equals(ScanType.SALE)).max((x1, x2) -> x1.getCreateTimestamp().compareTo(x2.getCreateTimestamp())).get();
|
| 2692 |
if (scanRecord.getCreateTimestamp().isAfter(scheme.getEndDateTime()) || scanRecord.getCreateTimestamp().isBefore(scheme.getStartDateTime())) {
|
2367 |
if (scanRecord.getCreateTimestamp().isAfter(scheme.getEndDateTime()) || scanRecord.getCreateTimestamp().isBefore(scheme.getStartDateTime())) {
|
| 2693 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
2368 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|