| | |
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.io.PrintWriter;
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.math.BigDecimal;
|
| | | import java.net.URLEncoder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | |
| | | import javax.script.ScriptEngineManager;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import org.apache.commons.httpclient.HttpClient;
|
| | | import org.apache.commons.httpclient.HttpException;
|
| | | import org.apache.commons.httpclient.methods.GetMethod;
|
| | | import org.jsoup.Jsoup;
|
| | | import org.jsoup.nodes.Document;
|
| | | import org.jsoup.select.Elements;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserMoneyExtraService userMoneyExtraService;
|
| | |
|
| | | @RequestMapping(value = "testimg")
|
| | | public void testImg(HttpServletRequest request, PrintWriter out) {
|
| | | long startTime = System.currentTimeMillis();
|
| | |
|
| | | List<String> list = new ArrayList<>();
|
| | | for (int i = 0; i < 10; i++) {
|
| | | list.add("i" + i);
|
| | | }
|
| | |
|
| | | try {
|
| | | final TaoBaoGoodsBrief goods = redisManager.getTaoBaoGoodsBrief(569823237075L);
|
| | | } catch (TaobaoGoodsDownException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | String url = "http://www.baidu.com";
|
| | | list.parallelStream().forEach(ids -> {
|
| | | InputStream portrait = HttpUtil.getAsInputStream(
|
| | | "https://wwc.alicdn.com/avatar/getAvatar.do?userId=1889722423&width=160&height=160&type=sns");
|
| | | System.out.println(ids + "开始时间:" + System.currentTimeMillis());
|
| | | String uid = "123";
|
| | | String auctionId = "test-" + ids;
|
| | |
|
| | | String destPath = FileUtil.getCacheDir() + "/" + auctionId + ".jpg";
|
| | |
|
| | | String shareImgPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + auctionId + ".png";
|
| | |
|
| | | try {
|
| | | QRCodeUtil.getInstance(500).encode(url, destPath);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | long startDTime = System.currentTimeMillis();
|
| | |
|
| | | /*
|
| | | * try { //ImageUtil.drawGoodsShareImg(new FileInputStream(new
|
| | | * File(destPath)), portrait, goods, shareImgPath); } catch
|
| | | * (FileNotFoundException e) { e.printStackTrace(); }
|
| | | */
|
| | | System.out.println(System.currentTimeMillis() - startDTime);
|
| | |
|
| | | String shareImgUrl = COSManager.getInstance()
|
| | | .uploadFile(new File(shareImgPath), "share_" + uid + "_" + auctionId + ".png").getUrl();
|
| | | System.out.println(ids + "结束时间:" + System.currentTimeMillis());
|
| | | });
|
| | | System.out.println("整体耗时:" + (System.currentTimeMillis() - startTime));
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @RequestMapping(value = "kefu")
|
| | | public void kefu(HttpServletRequest request, PrintWriter out) {
|
| | |
| | | }
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping("getTaoBaoGoodsDetail")
|
| | | public void getTaoBaoGoodsDetail(Long id, String headers, PrintWriter out) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("itemNumId", id + "");
|
| | |
|
| | | String url = "";
|
| | | try {
|
| | | url = String.format("https://acs.m.taobao.com/h5/mtop.taobao.detail.getdetail/6.0/?data=%s",
|
| | | URLEncoder.encode(data.toString(), "UTF-8"));
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | HttpClient client = new HttpClient();
|
| | | GetMethod gm = new GetMethod(url);
|
| | | String result = null;
|
| | | try {
|
| | | JSONObject headerJson = JSONObject.fromObject(headers);
|
| | | for (Iterator<String> its = headerJson.keys(); its.hasNext();) {
|
| | | String key = its.next();
|
| | | gm.setRequestHeader(key, headerJson.optString(key));
|
| | | }
|
| | | client.executeMethod(gm);
|
| | | result = gm.getResponseBodyAsString();
|
| | | } catch (HttpException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | out.print(result);
|
| | | }
|
| | |
|
| | | } |
| | | }
|