Subversion Repositories SmartDukaan

Rev

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

Rev 33183 Rev 33465
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
3
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
3
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
4
import com.spice.profitmandi.common.model.ItemDescriptionModel;
4
import com.spice.profitmandi.common.model.ItemDescriptionModel;
5
import com.spice.profitmandi.common.model.ProfitMandiConstants;
-
 
6
import com.spice.profitmandi.common.util.FileUtil;
5
import com.spice.profitmandi.common.util.FileUtil;
7
import com.spice.profitmandi.common.util.FormattingUtils;
6
import com.spice.profitmandi.common.util.FormattingUtils;
8
import com.spice.profitmandi.dao.entity.auth.AuthUser;
7
import com.spice.profitmandi.dao.entity.auth.AuthUser;
9
import com.spice.profitmandi.dao.entity.catalog.Item;
8
import com.spice.profitmandi.dao.entity.catalog.Item;
10
import com.spice.profitmandi.dao.entity.inventory.Vendor;
9
import com.spice.profitmandi.dao.entity.inventory.Vendor;
11
import com.spice.profitmandi.dao.entity.inventory.VendorCatalogPricing;
10
import com.spice.profitmandi.dao.entity.inventory.VendorCatalogPricing;
12
import com.spice.profitmandi.dao.entity.inventory.VendorCatalogPricingLog;
11
import com.spice.profitmandi.dao.entity.inventory.VendorCatalogPricingLog;
13
import com.spice.profitmandi.dao.entity.warehouse.Supplier;
12
import com.spice.profitmandi.dao.entity.warehouse.Supplier;
14
import com.spice.profitmandi.dao.enumuration.inventory.VendorCatalogPricingStatus;
13
import com.spice.profitmandi.dao.enumuration.inventory.VendorCatalogPricingStatus;
15
import com.spice.profitmandi.dao.model.PriceDropReportModel;
-
 
16
import com.spice.profitmandi.dao.model.VendorCatalogPricingModel;
14
import com.spice.profitmandi.dao.model.VendorCatalogPricingModel;
17
import com.spice.profitmandi.dao.model.VendorPriceCircularModel;
15
import com.spice.profitmandi.dao.model.VendorPriceCircularModel;
18
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
16
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
19
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
17
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
20
import com.spice.profitmandi.dao.repository.inventory.VendorCatalogPricingLogRepository;
18
import com.spice.profitmandi.dao.repository.inventory.VendorCatalogPricingLogRepository;
Line 30... Line 28...
30
import com.spice.profitmandi.web.util.CookiesProcessor;
28
import com.spice.profitmandi.web.util.CookiesProcessor;
31
import com.spice.profitmandi.web.util.MVCResponseSender;
29
import com.spice.profitmandi.web.util.MVCResponseSender;
32
import org.apache.logging.log4j.LogManager;
30
import org.apache.logging.log4j.LogManager;
33
import org.apache.logging.log4j.Logger;
31
import org.apache.logging.log4j.Logger;
34
import org.springframework.beans.factory.annotation.Autowired;
32
import org.springframework.beans.factory.annotation.Autowired;
-
 
33
import org.springframework.core.io.ClassPathResource;
-
 
34
import org.springframework.core.io.InputStreamResource;
-
 
35
import org.springframework.http.HttpHeaders;
-
 
36
import org.springframework.http.MediaType;
35
import org.springframework.http.ResponseEntity;
37
import org.springframework.http.ResponseEntity;
36
import org.springframework.stereotype.Controller;
38
import org.springframework.stereotype.Controller;
37
import org.springframework.transaction.annotation.Transactional;
39
import org.springframework.transaction.annotation.Transactional;
38
import org.springframework.ui.Model;
40
import org.springframework.ui.Model;
39
import org.springframework.web.bind.annotation.RequestBody;
41
import org.springframework.web.bind.annotation.*;
40
import org.springframework.web.bind.annotation.RequestMapping;
42
import org.springframework.web.multipart.MultipartFile;
41
import org.springframework.web.bind.annotation.RequestMethod;
-
 
42
import org.springframework.web.bind.annotation.RequestParam;
-
 
43
 
43
 
-
 
44
import javax.mail.MessagingException;
44
import javax.servlet.http.HttpServletRequest;
45
import javax.servlet.http.HttpServletRequest;
-
 
46
import java.io.IOException;
45
import java.time.LocalDate;
47
import java.time.LocalDate;
46
import java.time.LocalDateTime;
48
import java.time.LocalDateTime;
47
import java.time.LocalTime;
-
 
48
import java.util.*;
49
import java.util.*;
49
import java.util.stream.Collectors;
50
import java.util.stream.Collectors;
50
 
51
 
51
@Controller
52
@Controller
52
@Transactional(rollbackFor = Throwable.class)
53
@Transactional(rollbackFor = Throwable.class)
Line 160... Line 161...
160
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
161
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
161
        return "response";
162
        return "response";
162
 
163
 
163
    }
164
    }
164
 
165
 
-
 
166
    @RequestMapping(value = "/createBulkPricing")
-
 
167
    public String createBulkPricing(HttpServletRequest request, Model model) throws ProfitMandiBusinessException, MessagingException, IOException {
-
 
168
        return "bulk-vendor-pricing";
-
 
169
    }
-
 
170
 
-
 
171
    @PostMapping(value = "/bulkVendorCatalogPricing/upload")
-
 
172
    public String uploadCatalog(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
-
 
173
            throws Exception {
-
 
174
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
-
 
175
        int authId = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId()).getId();
-
 
176
        LOGGER.info("authId - {}", authId);
-
 
177
        vendorCatalogPricingService.parseBulkVendorCatalogPricing(file, authId);
-
 
178
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
-
 
179
        return "response";
-
 
180
    }
-
 
181
 
-
 
182
    @GetMapping("/bulkVendorCatalogPricing/downloadReferenceFile")
-
 
183
    public ResponseEntity<?> downloadDummyFile() throws IOException {
-
 
184
        ClassPathResource dummyFile = new ClassPathResource("vendor-catalog-pricing-file.xlsx"); // Make sure the file is in the resources folder
-
 
185
        return ResponseEntity.ok()
-
 
186
                .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=dummy-file.xlsx")
-
 
187
                .contentType(MediaType.APPLICATION_OCTET_STREAM)
-
 
188
                .body(new InputStreamResource(dummyFile.getInputStream()));
-
 
189
    }
-
 
190
 
165
 
191
 
166
    @RequestMapping(value = "/vendorCatalogPricingRequests", method = RequestMethod.GET)
192
    @RequestMapping(value = "/vendorCatalogPricingRequests", method = RequestMethod.GET)
167
    public String vendorCatalogPricingRequests(HttpServletRequest request, Model model) throws Exception {
193
    public String vendorCatalogPricingRequests(HttpServletRequest request, Model model) throws Exception {
168
        List<VendorCatalogPricingLog> vendorCatalogPricingRequests = vendorCatalogPricingLogRepository.selectByStatus(VendorCatalogPricingStatus.PENDING);
194
        List<VendorCatalogPricingLog> vendorCatalogPricingRequests = vendorCatalogPricingLogRepository.selectByStatus(VendorCatalogPricingStatus.PENDING);
169
        Map<Integer, AuthUser> authUserMap = authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
195
        Map<Integer, AuthUser> authUserMap = authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));