Demo entry 6640940

卢广航

   

Submitted by 111 on Sep 14, 2017 at 11:18
Language: Java. Code size: 2.0 kB.

public void doPrint(HttpServletRequest request, HttpServletResponse response, Long eqipClass, String eqipClassNameQuery, String eqipName, String reportKey)
    throws IOException
  {
    BufferedOutputStream bos = new BufferedOutputStream(
      response.getOutputStream());
    try {
      EquipInfo info = new EquipInfo();

      info.setEqipName(eqipName);
      info.setEqipClassNameQuery(eqipClassNameQuery);
      List datas = this.service.queryEquipInfoList(info);
      List printList = new ArrayList();
      for (EquipInfo data : datas)
      {
        Map map = new HashMap();
        map.put("EQUIP_CODE", data.getEqipCode());
        map.put("EQUIP_NAME", data.getEqipName());
        map.put("ORG_NAME", data.getOrgIdName());
        if (data.getOpTime() != null)
        {
          map.put("BUY_DATE", new SimpleDateFormat("yyyy-MM-dd").format(data.getOpTime()));
        }
        map.put("OLD_VALUE", data.getOldValue());
        map.put("USEYEAR", data.getInYear());

        IdentifierGenerator idgen = new UUIDHexGenerator();
        String keyId = String.valueOf(idgen.generate());
        String imgPath = "F:\\iems\\WebRoot\\WEB-INF\\report\\" + keyId + ".jpg";
        map.put("EWM_IMG", "F:\\iems\\WebRoot\\WEB-INF\\report\\iems1.jpg");
        map.put("TUBIAO_IMG", "F:\\iems\\WebRoot\\WEB-INF\\report\\iems.jpg");

        JasperPrint jasperPrint = this.report.getJasperPrint(reportKey, map, null, null, false);
        printList.add(jasperPrint);
      }
      byte[] osdata = this.report.LianXuPrint(printList);
      response.setContentType("application/pdf");
      response.setHeader("Content-disposition", "inline;filename=" + URLEncoder.encode(new StringBuilder(String.valueOf(reportKey)).append(".pdf").toString(), "UTF-8"));

      bos.write(osdata);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (bos != null) {
        bos.flush();
        bos.close();
      }
    }
  }

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).