/**
  * 查询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;
 }
 /**
  * 保存一个盘点数
  *
  * @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;
   }
 }