示例#1
0
  public List<String> getUnusedStocks(
      long breedID, Map<String, String> propertys, String firmID, double quantity) {
    List<String> result = new ArrayList();
    WareHouseStockDAO wareHouseStockDAO = Server.getInstance().getWareHouseStockDAO();

    List<StockVO> stockList = wareHouseStockDAO.getUnusedStocksVOList(breedID, firmID, quantity);
    if ((stockList == null) || (stockList.size() <= 0)) {
      return result;
    }
    List<Map<String, Object>> propertyList =
        wareHouseStockDAO.getCategoryPropertyByBreedID(breedID);
    if ((propertyList != null) && (propertyList.size() > 0)) {
      for (Map<String, Object> map : propertyList) {
        if ((map.get("stockcheck") != null) && (map.get("stockcheck").equals("Y"))) {
          String propValue = (String) propertys.get(map.get("propertyname").toString());
          List<StockVO> removeStock = new ArrayList();
          for (StockVO stockVO : stockList) {
            List<GoodsPropertyPO> props = stockVO.getStockPropertys();
            if ((props == null) || (props.size() <= 0)) {
              removeStock.add(stockVO);
            } else {
              String stockP = null;
              for (GoodsPropertyPO goodsPropertyPO : props) {
                if (map.get("propertyname").toString().equals(goodsPropertyPO.getPropertyName())) {
                  stockP = goodsPropertyPO.getPropertyValue();
                  break;
                }
              }
              if (((propValue == null) && (stockP != null))
                  || ((propValue != null) && (stockP == null))
                  || ((propValue != null) && (stockP != null) && (!propValue.equals(stockP)))) {
                removeStock.add(stockVO);
              }
            }
          }
          for (StockVO stockVO : removeStock) {
            stockList.remove(stockVO);
          }
        } else if ((map.get("stockcheck") != null) && (map.get("stockcheck").equals("M"))) {
          String propValue = (String) propertys.get(map.get("propertyname").toString());
          List<StockVO> removeStock = new ArrayList();
          for (StockVO stockVO : stockList) {
            List<GoodsPropertyPO> props = stockVO.getStockPropertys();
            if ((props == null) || (props.size() <= 0)) {
              removeStock.add(stockVO);
            } else {
              String stockP = null;
              for (GoodsPropertyPO goodsPropertyPO : props) {
                if (map.get("propertyname").toString().equals(goodsPropertyPO.getPropertyName())) {
                  stockP = goodsPropertyPO.getPropertyValue();
                  break;
                }
              }
              if (((propValue == null) && (stockP != null))
                  || ((propValue != null) && (stockP == null))
                  || ((propValue != null)
                      && (stockP != null)
                      && (!("|" + propValue + "|").contains("|" + stockP + "|")))) {
                removeStock.add(stockVO);
              }
            }
          }
          for (StockVO stockVO : removeStock) {
            stockList.remove(stockVO);
          }
        }
      }
    }
    for (StockVO stockVO : stockList) {
      result.add(stockVO.getStock().getStockID());
    }
    return result;
  }
示例#2
0
  public ResultVO dismantleStock(String stockID, boolean result, Map<String, String> dismantleMap) {
    ResultVO resultVO = new ResultVO();
    resultVO.setResult(-1L);
    WareHouseStockDAO wareHouseStockDAO = Server.getInstance().getWareHouseStockDAO();

    StockPO stockPO = wareHouseStockDAO.getStockPOByIDAndLocked(stockID);
    if (stockPO == null) {
      resultVO.addErrorInfo(-1262L, new Object[] {stockID});
      return resultVO;
    }
    if (stockPO.getStockStatus() != 4) {
      resultVO.addErrorInfo(-1263L, new Object[] {stockPO.getStockStatusMeaning()});
      return resultVO;
    }
    List<DismantlePO> dismantlePOList =
        wareHouseStockDAO.getDismantleList(
            " and stockID='" + stockPO.getStockID() + "' and status=0 ");
    if ((dismantlePOList == null)
        || (dismantlePOList.size() == 0)
        || (!"0".equals(((DismantlePO) dismantlePOList.get(0)).getStatus()))) {
      resultVO.addErrorInfo(-1264L, new Object[] {stockID});
      return resultVO;
    }
    wareHouseStockDAO.deleteStockOperation(stockPO.getStockID(), StockOperation.DISMANTLE);
    if (result) {
      wareHouseStockDAO.updateStockStatus(stockPO.getStockID(), 3);
      for (DismantlePO wDismantlePO : dismantlePOList) {
        StockPO newStockPO = new StockPO();
        newStockPO.setBreedID(stockPO.getBreedID());
        newStockPO.setOwnerFirm(stockPO.getOwnerFirm());
        newStockPO.setQuantity(wDismantlePO.getAmount());
        if ((dismantleMap == null) || (dismantleMap.get(wDismantlePO.getDismantleID()) == null)) {
          resultVO.addErrorInfo(-1265L, new Object[] {Long.valueOf(wDismantlePO.getDismantleID())});

          throw new BillCoreException(resultVO.getErrorDetailInfo());
        }
        newStockPO.setRealStockCode((String) dismantleMap.get(wDismantlePO.getDismantleID()));

        newStockPO.setStockStatus(0);
        newStockPO.setUnit(stockPO.getUnit());
        newStockPO.setWarehouseID(stockPO.getWarehouseID());

        String newStockID = wareHouseStockDAO.insertStock(newStockPO) + "";

        List<GoodsPropertyPO> propertyList = wareHouseStockDAO.getGoodsProperty(stockID);

        List<GoodsPropertyPO> newPropertyList = new ArrayList();
        for (GoodsPropertyPO wGoodsPropertyPO : propertyList) {
          GoodsPropertyPO newGoodsPropertyPO = new GoodsPropertyPO();
          newGoodsPropertyPO.setPropertyName(wGoodsPropertyPO.getPropertyName());
          newGoodsPropertyPO.setPropertyValue(wGoodsPropertyPO.getPropertyValue());
          newGoodsPropertyPO.setStockID(newStockID);
          newGoodsPropertyPO.setPropertyTypeID(wGoodsPropertyPO.getPropertyTypeID());
          newPropertyList.add(newGoodsPropertyPO);
        }
        wareHouseStockDAO.insertGoodsProperty(newPropertyList);

        wareHouseStockDAO.dismantleSucess(
            wDismantlePO.getDismantleID(),
            newStockID,
            (String) dismantleMap.get(wDismantlePO.getDismantleID()));
      }
    } else {
      for (DismantlePO wDismantlePO : dismantlePOList) {
        wareHouseStockDAO.dismantleFail(wDismantlePO.getDismantleID());
      }
      wareHouseStockDAO.updateStockStatus(stockPO.getStockID(), 0);
    }
    wareHouseStockDAO.addGlobalLog(
        "系统",
        Server.getInstance().getIp(),
        1301,
        "处理拆仓单,仓单号为:" + stockID + ";仓库处理结果:" + (result ? "拆仓单处理成功" : "拆仓单处理失败"),
        1);

    resultVO.setResult(1L);
    return resultVO;
  }