public boolean approvalStockLoss(String id, int approval) { ArrayList<LogisticsLossPO> stocklosslist = new ArrayList<LogisticsLossPO>(); stocklosslist = slds.getStockLoss(); LogisticsLossVO sofv = new LogisticsLossVO(); for (LogisticsLossPO slp : stocklosslist) { if (slp.getId().equals(id)) { slp.setApproval(approval); slds.update(slp); sofv = stockLossPoToVo(slp); break; } } if (sofv.approval == 1) { for (CommodityVO cv : cb.getCommodity()) { if (sofv.name.equals(cv.commodityname) && sofv.model.equals(cv.model)) { CommodityVO newCv = (CommodityVO) cv.clone(); newCv.number = cv.number - sofv.lossNumber; if (cb.updateCommodity(cv, newCv, cb.getFather(cv))) { if (newCv.number < newCv.dangerNumber) { mb.add(new MessageVO("物流报警", cv.commodityname, cv.model, newCv.number, "空", false)); } return true; } else { return false; } } } } return true; }
@Override public boolean add(LogisticsLossVO slv) { // TODO Auto-generated method stub if (slv == null) { return false; } for (CommodityVO cv : cb.getCommodity()) { if (cv.commodityname.equals(slv.name) && cv.model.equals(slv.model)) { if (cv.number - slv.lossNumber < 0) { return false; } } } if (slds.add(stockLossVoToPo(slv))) { return true; } return false; }