예제 #1
0
 /**
  * 作废盘点
  *
  * @return
  * @throws Exception
  */
 public String cancelChecking() throws Exception {
   this.setReturnurl(
       request.getContextPath()
           + FILESEPARATOR
           + "checking"
           + FILESEPARATOR
           + "toCheckingPage.action");
   if (scid != null && scid != 0) {
     stockChecking = this.stockCheckingService.get(StockChecking.class, scid);
     stockChecking.setStatus(0);
     pstock = stockChecking.getPstock();
     pstock.setQuantity(stockChecking.getQuantity_before());
     this.stockCheckingService.update(stockChecking);
     this.pstockService.update(pstock);
     this.setMessage(SUCCMESSAGE);
     return SUCCESS;
   } else {
     return INPUT;
   }
 }
예제 #2
0
 /**
  * 保存一个盘点数
  *
  * @return
  * @throws Exception
  */
 public String addChecking() throws Exception {
   this.setReturnurl(
       request.getContextPath()
           + FILESEPARATOR
           + "checking"
           + FILESEPARATOR
           + "toCheckingPage.action");
   if (warehouse != null && warehouse.getId() != null) {
     warehouse = this.warehouseService.get(Warehouse.class, warehouse.getId());
     if (barcode != null) {
       productInfo = this.productinfoService.findByBaecode(barcode);
       if (productInfo == null) {
         this.setMessage("产品编码有错误");
         return INPUT;
       }
       if (quantity == null) {
         this.setMessage("请输入盘点数量");
         return INPUT;
       }
       User user = (User) request.getSession().getAttribute("user");
       pstock = this.pstockService.findbyBarcodeAndWarehouse(barcode, warehouse.getWname());
       stockChecking = new StockChecking(pstock, productInfo, quantity, warehouse);
       if (user != null) {
         stockChecking.setOperator(user.getUsername());
       }
       this.stockCheckingService.add(stockChecking);
       pstock.setQuantity(quantity); // 更新数量
       this.pstockService.update(pstock);
       return SUCCESS;
     } else {
       this.setMessage("产品编码不能为空!");
       return INPUT;
     }
   } else {
     this.setMessage("产品编码不能为空!");
     return INPUT;
   }
 }
예제 #3
0
 /**
  * 生成一张盘点表格
  *
  * @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;
 }