| Line 35... |
Line 35... |
| 35 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
35 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
| 36 |
import org.apache.logging.log4j.LogManager;
|
36 |
import org.apache.logging.log4j.LogManager;
|
| 37 |
import org.apache.logging.log4j.Logger;
|
37 |
import org.apache.logging.log4j.Logger;
|
| 38 |
import org.apache.velocity.app.VelocityEngine;
|
38 |
import org.apache.velocity.app.VelocityEngine;
|
| 39 |
import org.springframework.beans.factory.annotation.Autowired;
|
39 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 40 |
import org.springframework.beans.factory.annotation.Qualifier;
|
- |
|
| 41 |
import org.springframework.cache.CacheManager;
|
40 |
import org.springframework.cache.CacheManager;
|
| 42 |
import org.springframework.core.io.InputStreamResource;
|
41 |
import org.springframework.core.io.InputStreamResource;
|
| 43 |
import org.springframework.http.HttpHeaders;
|
42 |
import org.springframework.http.HttpHeaders;
|
| 44 |
import org.springframework.http.HttpStatus;
|
43 |
import org.springframework.http.HttpStatus;
|
| 45 |
import org.springframework.http.ResponseEntity;
|
44 |
import org.springframework.http.ResponseEntity;
|
| - |
|
45 |
import org.springframework.mock.web.MockHttpServletRequest;
|
| - |
|
46 |
import org.springframework.mock.web.MockHttpServletResponse;
|
| 46 |
import org.springframework.stereotype.Controller;
|
47 |
import org.springframework.stereotype.Controller;
|
| 47 |
import org.springframework.ui.Model;
|
48 |
import org.springframework.ui.Model;
|
| 48 |
import org.springframework.ui.velocity.VelocityEngineUtils;
|
- |
|
| 49 |
import org.springframework.web.bind.annotation.*;
|
49 |
import org.springframework.web.bind.annotation.*;
|
| 50 |
import org.springframework.web.multipart.MultipartFile;
|
50 |
import org.springframework.web.multipart.MultipartFile;
|
| - |
|
51 |
import org.springframework.web.servlet.View;
|
| - |
|
52 |
import org.springframework.web.servlet.ViewResolver;
|
| 51 |
import org.xhtmlrenderer.swing.Java2DRenderer;
|
53 |
import org.xhtmlrenderer.swing.Java2DRenderer;
|
| 52 |
|
54 |
|
| 53 |
import javax.imageio.ImageIO;
|
55 |
import javax.imageio.ImageIO;
|
| 54 |
import javax.servlet.http.HttpServletRequest;
|
56 |
import javax.servlet.http.HttpServletRequest;
|
| 55 |
import javax.transaction.Transactional;
|
57 |
import javax.transaction.Transactional;
|
| Line 82... |
Line 84... |
| 82 |
|
84 |
|
| 83 |
@Autowired
|
85 |
@Autowired
|
| 84 |
private ResponseSender responseSender;
|
86 |
private ResponseSender responseSender;
|
| 85 |
|
87 |
|
| 86 |
@Autowired
|
88 |
@Autowired
|
| - |
|
89 |
private ViewResolver viewResolver;
|
| - |
|
90 |
|
| - |
|
91 |
@Autowired
|
| 87 |
private OfferPartnerRepository offerPartnerRepository;
|
92 |
private OfferPartnerRepository offerPartnerRepository;
|
| 88 |
|
93 |
|
| 89 |
private static final String IMAGE_REMOTE_DIR = "/var/www/dtrdashboard/uploads/campaigns/";
|
94 |
private static final String IMAGE_REMOTE_DIR = "/var/www/dtrdashboard/uploads/campaigns/";
|
| 90 |
private static final String IMAGE_STATIC_SERVER_URL = "https://images.smartdukaan.com/uploads/campaigns";
|
95 |
private static final String IMAGE_STATIC_SERVER_URL = "https://images.smartdukaan.com/uploads/campaigns";
|
| 91 |
|
96 |
|
| Line 205... |
Line 210... |
| 205 |
@RequestParam(defaultValue = "true") boolean active) throws ProfitMandiBusinessException, Exception {
|
210 |
@RequestParam(defaultValue = "true") boolean active) throws ProfitMandiBusinessException, Exception {
|
| 206 |
Offer offer = offerRepository.selectById(offerId);
|
211 |
Offer offer = offerRepository.selectById(offerId);
|
| 207 |
// model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
212 |
// model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 208 |
// return "response";
|
213 |
// return "response";
|
| 209 |
CreateOfferRequest createOfferRequest = offerService.getCreateOfferRequest(offer);
|
214 |
CreateOfferRequest createOfferRequest = offerService.getCreateOfferRequest(offer);
|
| - |
|
215 |
Map<String, Object> model1 = new HashMap<>();
|
| 210 |
model.addAttribute("offer", createOfferRequest);
|
216 |
model1.put("offer", createOfferRequest);
|
| - |
|
217 |
model1.put("lessThan", "<");
|
| - |
|
218 |
String htmlContent = this.getContentFromTemplate("offer_margin_detail_notify", model1);
|
| - |
|
219 |
model.addAttribute("response1", htmlContent);
|
| 211 |
return "offer_margin_detail_partner2";
|
220 |
return "response";
|
| 212 |
}
|
221 |
}
|
| 213 |
|
222 |
|
| 214 |
@Autowired
|
223 |
@Autowired
|
| 215 |
private com.spice.profitmandi.dao.repository.dtr.UserRepository dtrUserRepository;
|
224 |
private com.spice.profitmandi.dao.repository.dtr.UserRepository dtrUserRepository;
|
| 216 |
|
225 |
|
| Line 249... |
Line 258... |
| 249 |
Map<Integer, List<Offer>> offersMap = offerRepository.selectAllPublishedMapByPartner(YearMonth.now());
|
258 |
Map<Integer, List<Offer>> offersMap = offerRepository.selectAllPublishedMapByPartner(YearMonth.now());
|
| 250 |
|
259 |
|
| 251 |
Map<String, InputStream> fileStreamsMap = new HashMap<>();
|
260 |
Map<String, InputStream> fileStreamsMap = new HashMap<>();
|
| 252 |
Map<String, Object> model = new HashMap<>();
|
261 |
Map<String, Object> model = new HashMap<>();
|
| 253 |
model.put("offer", createOfferRequest);
|
262 |
model.put("offer", createOfferRequest);
|
| 254 |
String htmlContent = this.getContentFromTemplate("offer_margin_detail_partner.vm", model);
|
263 |
String htmlContent = this.getContentFromTemplate("offer_margin_detail_notify", model);
|
| 255 |
LOGGER.info("this.getContentFromTemplate {}", htmlContent);
|
264 |
LOGGER.info("this.getContentFromTemplate {}", htmlContent);
|
| 256 |
fileStreamsMap.put(fileName, this.getImageBuffer(htmlContent));
|
265 |
fileStreamsMap.put(fileName, this.getImageBuffer(htmlContent));
|
| 257 |
// fileStreamsMap.put(htmlFileName, new
|
266 |
// fileStreamsMap.put(htmlFileName, new
|
| 258 |
// ByteArrayInputStream(htmlContent.getBytes()));
|
267 |
// ByteArrayInputStream(htmlContent.getBytes()));
|
| 259 |
|
268 |
|
| Line 350... |
Line 359... |
| 350 |
|
359 |
|
| 351 |
@Autowired
|
360 |
@Autowired
|
| 352 |
private VelocityEngine velocityEngine;
|
361 |
private VelocityEngine velocityEngine;
|
| 353 |
|
362 |
|
| 354 |
|
363 |
|
| 355 |
@Autowired
|
- |
|
| 356 |
@Qualifier("velocityAttributesMap")
|
- |
|
| 357 |
private Map<String, Object> velocityAttributesMap;
|
- |
|
| 358 |
|
- |
|
| 359 |
private String getContentFromTemplate(String template, Map<String, Object> model) {
|
364 |
private String getContentFromTemplate(String template, Map<String, Object> model) throws Exception {
|
| 360 |
StringBuffer content = new StringBuffer();
|
365 |
View resolvedView = viewResolver.resolveViewName(template, Locale.US);
|
| 361 |
try {
|
- |
|
| 362 |
((HashMap<String, Object>) (velocityAttributesMap.entrySet().stream().findAny().get()).getValue()).entrySet().stream().forEach(x -> {
|
366 |
MockHttpServletResponse mockResp = new MockHttpServletResponse();
|
| 363 |
model.put(x.getKey(), x.getValue());
|
367 |
MockHttpServletRequest req = new MockHttpServletRequest();
|
| 364 |
});
|
- |
|
| 365 |
content.append(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, template, model));
|
368 |
LOGGER.info("Resolved view -> {}, {}, {}, {}", resolvedView, model, req, mockResp);
|
| 366 |
} catch (Exception e) {
|
- |
|
| 367 |
e.printStackTrace();
|
369 |
resolvedView.render(model, req, mockResp);
|
| 368 |
}
|
- |
|
| 369 |
return content.toString();
|
370 |
return mockResp.getContentAsString();
|
| 370 |
}
|
371 |
}
|
| 371 |
|
372 |
|
| 372 |
@RequestMapping(value = "/offerHistory", method = RequestMethod.GET)
|
373 |
@RequestMapping(value = "/offerHistory", method = RequestMethod.GET)
|
| 373 |
public String getPaginatedOffers(HttpServletRequest request, @RequestParam YearMonth yearMonth, Model model)
|
374 |
public String getPaginatedOffers(HttpServletRequest request, @RequestParam YearMonth yearMonth, Model model)
|
| 374 |
throws ProfitMandiBusinessException {
|
375 |
throws ProfitMandiBusinessException {
|