Exemplo n.º 1
0
 /**
  * 盘点明细 , 按日期输出
  *
  * @return
  * @throws Exception
  */
 public String listCheckingList() throws Exception {
   this.setReturnurl(request.getContextPath() + FILESEPARATOR + "warehousefunction.jsp");
   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);
   }
   return SUCCESS;
 }
Exemplo n.º 2
0
 /**
  * 查询PRODUCTINFO资料, 盘点页面用 传入 warehouse 为 wid , barcode 传出包含完整信息的 info 及 stock
  *
  * @throws Exception
  */
 public void findProductInfo() throws Exception {
   response.setContentType("text/html;charset=utf-8");
   PrintWriter printWriter = response.getWriter();
   if (wid == null) {
     printWriter.write("error01:" + "选择盘点的仓库!");
     printWriter.flush();
     printWriter.close();
     return;
   }
   warehouse = this.warehouseService.get(Warehouse.class, wid);
   if (warehouse == null || warehouse.getWname() == null) {
     printWriter.write("error01:" + "选择盘点的仓库!");
     printWriter.flush();
     printWriter.close();
     return;
   }
   if (barcode == null || barcode.trim().equals("")) {
     printWriter.write("error02:" + "没有找到此产品资料!");
     printWriter.flush();
     printWriter.close();
     return;
   }
   ProductInfo productInfo = this.productinfoService.findByBaecode(barcode);
   if (productInfo == null) {
     printWriter.write("error02:" + "没有找到此产品资料!");
     printWriter.flush();
     printWriter.close();
     return;
   }
   pstock = this.pstockService.findbyBarcodeAndWarehouse(barcode, warehouse.getWname());
   //		System.out.println(pstock);
   if (pstock == null) {
     printWriter.write("error:" + "没有找到此产品库存!");
     printWriter.flush();
     printWriter.close();
     return;
   }
   String json = JsonTool.getInstance().getInfoDetail(productInfo, "", pstock.getQuantity());
   //		System.out.println(json);
   // String json = JsonTool.getInstance().getInfoDesc(productInfo);
   printWriter.write(json.trim());
   printWriter.flush();
   printWriter.close();
   return;
 }
Exemplo n.º 3
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;
   }
 }
Exemplo n.º 4
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;
 }