| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.awt.RenderingHints;
|
| 3 |
import java.awt.image.BufferedImage;
|
4 |
import java.awt.image.BufferedImage;
|
| 4 |
import java.io.ByteArrayInputStream;
|
5 |
import java.io.ByteArrayInputStream;
|
| 5 |
import java.io.File;
|
6 |
import java.io.File;
|
| 6 |
import java.io.FileNotFoundException;
|
7 |
import java.io.FileNotFoundException;
|
| 7 |
import java.io.InputStream;
|
8 |
import java.io.InputStream;
|
| Line 44... |
Line 45... |
| 44 |
import org.springframework.web.bind.annotation.RequestMethod;
|
45 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 45 |
import org.springframework.web.bind.annotation.RequestParam;
|
46 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 46 |
import org.springframework.web.bind.annotation.RequestPart;
|
47 |
import org.springframework.web.bind.annotation.RequestPart;
|
| 47 |
import org.springframework.web.multipart.MultipartFile;
|
48 |
import org.springframework.web.multipart.MultipartFile;
|
| 48 |
import org.xhtmlrenderer.simple.Graphics2DRenderer;
|
49 |
import org.xhtmlrenderer.simple.Graphics2DRenderer;
|
| - |
|
50 |
import org.xhtmlrenderer.swing.Java2DRenderer;
|
| 49 |
|
51 |
|
| 50 |
import com.google.gson.Gson;
|
52 |
import com.google.gson.Gson;
|
| 51 |
import com.jcraft.jsch.ChannelSftp;
|
53 |
import com.jcraft.jsch.ChannelSftp;
|
| 52 |
import com.jcraft.jsch.JSch;
|
54 |
import com.jcraft.jsch.JSch;
|
| 53 |
import com.jcraft.jsch.JSchException;
|
55 |
import com.jcraft.jsch.JSchException;
|
| Line 193... |
Line 195... |
| 193 |
return "response";
|
195 |
return "response";
|
| 194 |
//CreateOfferRequest createOfferRequest = offerService.getCreateOfferRequest(offer);
|
196 |
//CreateOfferRequest createOfferRequest = offerService.getCreateOfferRequest(offer);
|
| 195 |
//model.addAttribute("offer", createOfferRequest);
|
197 |
//model.addAttribute("offer", createOfferRequest);
|
| 196 |
//return "offer_margin_detail_partner2";
|
198 |
//return "offer_margin_detail_partner2";
|
| 197 |
}
|
199 |
}
|
| - |
|
200 |
|
| - |
|
201 |
@RequestMapping(value = "/offer/testimage/{offerId}", method = RequestMethod.GET)
|
| - |
|
202 |
public String testOffer(HttpServletRequest request, @PathVariable int offerId, Model model, @RequestParam(defaultValue = "true") boolean active)
|
| - |
|
203 |
throws ProfitMandiBusinessException, Exception {
|
| - |
|
204 |
Offer offer = offerRepository.selectById(offerId);
|
| - |
|
205 |
//model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
206 |
//return "response";
|
| - |
|
207 |
CreateOfferRequest createOfferRequest = offerService.getCreateOfferRequest(offer);
|
| - |
|
208 |
model.addAttribute("offer", createOfferRequest);
|
| - |
|
209 |
return "offer_margin_detail_partner2";
|
| - |
|
210 |
}
|
| 198 |
|
211 |
|
| 199 |
@Autowired
|
212 |
@Autowired
|
| 200 |
private com.spice.profitmandi.dao.repository.dtr.UserRepository dtrUserRepository;
|
213 |
private com.spice.profitmandi.dao.repository.dtr.UserRepository dtrUserRepository;
|
| 201 |
|
214 |
|
| 202 |
@RequestMapping(value = "/offer/active/fofo/{fofoId}", method = RequestMethod.GET)
|
215 |
@RequestMapping(value = "/offer/active/fofo/{fofoId}", method = RequestMethod.GET)
|
| Line 301... |
Line 314... |
| 301 |
this.fileUpload(channelSftp, fileStreamsMap, IMAGE_REMOTE_DIR + "");
|
314 |
this.fileUpload(channelSftp, fileStreamsMap, IMAGE_REMOTE_DIR + "");
|
| 302 |
channelSftp.exit();
|
315 |
channelSftp.exit();
|
| 303 |
}
|
316 |
}
|
| 304 |
|
317 |
|
| 305 |
private InputStream getImageBuffer (String html) throws Exception {
|
318 |
private InputStream getImageBuffer (String html) throws Exception {
|
| - |
|
319 |
|
| 306 |
String fileName = "/tmp/" + Instant.now().toEpochMilli();
|
320 |
String fileName = "/tmp/" + Instant.now().toEpochMilli();
|
| 307 |
FileUtils.writeStringToFile(new File(fileName), html, "UTF-8");
|
321 |
FileUtils.writeStringToFile(new File(fileName), html, "UTF-8");
|
| - |
|
322 |
String address = "file:" + fileName;
|
| 308 |
return this.asInputStream(Graphics2DRenderer.renderToImageAutoSize("file:" + fileName, 500));
|
323 |
Java2DRenderer renderer = new Java2DRenderer(address, 300);
|
| - |
|
324 |
RenderingHints hints = new RenderingHints(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
|
| - |
|
325 |
hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
|
| - |
|
326 |
hints.add(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
|
| - |
|
327 |
hints.add(new RenderingHints(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC));
|
| - |
|
328 |
renderer.setRenderingHints(hints);
|
| - |
|
329 |
BufferedImage img = renderer.getImage();
|
| - |
|
330 |
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
| - |
|
331 |
ImageIO.write(img, "png", os);
|
| - |
|
332 |
return new ByteArrayInputStream(os.toByteArray());
|
| 309 |
}
|
333 |
}
|
| 310 |
|
334 |
|
| 311 |
@Autowired
|
335 |
@Autowired
|
| 312 |
VelocityEngine velocityEngine;
|
336 |
VelocityEngine velocityEngine;
|
| 313 |
|
337 |
|