/* */ public InputStream getContentAsStream() throws IOException /* */ { /* 272 */ if (this.source != null) { /* 273 */ InputStream is = null; /* */ /* 276 */ if (((this.source instanceof StreamSource)) && (!isFastInfoset())) { /* 277 */ is = ((StreamSource) this.source).getInputStream(); /* */ } /* 279 */ else if ((FastInfosetReflection.isFastInfosetSource(this.source)) && (isFastInfoset())) /* */ { /* */ try /* */ { /* 284 */ is = FastInfosetReflection.FastInfosetSource_getInputStream(this.source); /* */ } /* */ catch (Exception e) { /* 287 */ throw new IOException(e.toString()); /* */ } /* */ } /* */ /* 291 */ if (is != null) { /* 292 */ if (lazyContentLength) { /* 293 */ return is; /* */ } /* 295 */ if (!(is instanceof ByteInputStream)) { /* 296 */ log.severe("SAAJ0546.soap.stream.incorrect.type"); /* 297 */ throw new IOException("Internal error: stream not of the right type"); /* */ } /* 299 */ return (ByteInputStream) is; /* */ } /* */ /* */ } /* */ /* 305 */ ByteOutputStream b = new ByteOutputStream(); /* */ /* 307 */ Envelope env = null; /* */ try /* */ { /* 310 */ env = (Envelope) getEnvelope(); /* 311 */ env.output(b, isFastInfoset()); /* */ } /* */ catch (SOAPException soapException) { /* 314 */ log.severe("SAAJ0547.soap.cannot.externalize"); /* 315 */ throw new SOAPIOException( "SOAP exception while trying to externalize: ", soapException); /* */ } /* */ /* 320 */ return b.newInputStream(); /* */ }
/* */ public void setContent(Source source) throws SOAPException { /* */ try { /* 225 */ if ((source instanceof StreamSource)) { /* 226 */ InputStream is = ((StreamSource) source).getInputStream(); /* 227 */ Reader rdr = ((StreamSource) source).getReader(); /* */ /* 229 */ if (is != null) { /* 230 */ this.source = new JAXMStreamSource(is); /* 231 */ } else if (rdr != null) { /* 232 */ this.source = new JAXMStreamSource(rdr); /* */ } else { /* 234 */ log.severe("SAAJ0544.soap.no.valid.reader.for.src"); /* 235 */ throw new SOAPExceptionImpl( "Source does not have a valid Reader or InputStream"); /* */ } /* */ } /* 238 */ else if (FastInfosetReflection.isFastInfosetSource(source)) /* */ { /* 240 */ InputStream is = FastInfosetReflection.FastInfosetSource_getInputStream(source); /* */ /* 247 */ if (!(is instanceof ByteInputStream)) { /* 248 */ ByteOutputStream bout = new ByteOutputStream(); /* 249 */ bout.write(is); /* */ /* 252 */ FastInfosetReflection.FastInfosetSource_setInputStream( source, bout.newInputStream()); /* */ } /* */ /* 255 */ this.source = source; /* */ } /* */ else { /* 258 */ this.source = source; /* */ } /* 260 */ this.sourceWasSet = true; /* */ } /* */ catch (Exception ex) { /* 263 */ ex.printStackTrace(); /* */ /* 265 */ log.severe("SAAJ0545.soap.cannot.set.src.for.part"); /* 266 */ throw new SOAPExceptionImpl( "Error setting the source for SOAPPart: " + ex.getMessage()); /* */ } /* */ }
/** * 生成一张盘点表格 * * @return * @throws Exception */ public String createCheckingExcel() throws Exception { if (date == null || date.trim().equals("")) { date = DateTool.getInstance().DateToPattern1(new Date()); } warehouses = this.warehouseService.findByKeyword(""); if (warehouse != null && warehouse.getId() != 0) { warehouse = this.warehouseService.get(Warehouse.class, warehouse.getId()); stockCheckingList = this.stockCheckingService.findCheckingListByDateAndWarehouse(date, warehouse.getId()); } else { stockCheckingList = this.stockCheckingService.findCheckingListByDate(date); } ByteOutputStream outputStream = new ByteOutputStream(); WritableWorkbook workbook = Workbook.createWorkbook(outputStream); WritableSheet sheet = workbook.createSheet("盘点记录表", 0); int row = 0; { Label label01 = new Label(0, row, "仓库"); sheet.addCell(label01); if (warehouse.getId() != 0) { Label label02 = new Label(1, row, warehouse.getWnickname()); sheet.addCell(label02); } else { Label label02 = new Label(1, row, "全部"); sheet.addCell(label02); } } row++; { Label label01 = new Label(0, row, "行"); Label label02 = new Label(1, row, "产品编码*"); Label label03 = new Label(2, row, "产品型号*"); Label label04 = new Label(3, row, "盘点前数量"); Label label05 = new Label(4, row, "盘点数量"); Label label06 = new Label(5, row, "差额"); Label label07 = new Label(6, row, "盘点人"); Label label08 = new Label(7, row, "时间"); sheet.addCell(label01); sheet.addCell(label02); sheet.addCell(label03); sheet.addCell(label04); sheet.addCell(label05); sheet.addCell(label06); sheet.addCell(label07); sheet.addCell(label08); } row++; for (int i = 0; i < stockCheckingList.size(); i++) { StockChecking checking = stockCheckingList.get(i); Label label01 = new Label(0, row, "" + (i + 1)); Label label02 = new Label(1, row, checking.getProductInfo().getBarcode()); Label label03 = new Label(2, row, checking.getProductInfo().getPdesc()); jxl.write.Number label04 = new jxl.write.Number(3, row, checking.getQuantity_before()); jxl.write.Number label05 = new jxl.write.Number(4, row, checking.getQuantity_after()); jxl.write.Number label06 = new jxl.write.Number( 5, row, checking.getQuantity_after() - checking.getQuantity_before()); Label label07 = new Label(6, row, checking.getOperator()); Label label08 = new Label(7, row, checking.getUpdatetime()); sheet.addCell(label01); sheet.addCell(label02); sheet.addCell(label03); sheet.addCell(label04); sheet.addCell(label05); sheet.addCell(label06); sheet.addCell(label07); sheet.addCell(label08); row++; } for (int i = 0; i < sheet.getColumns(); i++) { sheet.setColumnView(i, 30); } for (int i = 0; i < sheet.getRows(); i++) { sheet.setRowView(i, 300); } workbook.write(); workbook.close(); response.reset(); response.setContentType("application/vn.ms-xls"); response.setCharacterEncoding("utf-8"); this.inputStream = new ByteArrayInputStream(outputStream.getBytes()); // 关键,以 inputstream 输出 return SUCCESS; }