@Override
 protected void occur(Context context, CheckInEvent event) throws Throwable {
   if (CheckIsNull.isEmpty(event.getRelaOrderId()) || CheckIsNull.isEmpty(event.getType())) {
     throw new Throwable("相关单据编号和入库类型不能为空");
   }
   OrderInfo info = null;
   BillsEnum billsEnum = null;
   switch (event.getType()) {
       //			Purchase("01", "采购入库"), //
       //			Irregular("02", "零星采购"), //
       //			Return("03", "销售退货"), //
       //			RetailReturn("04","零售退货"),
       //			Other("05", "其他入库");
     case Purchase:
       info = context.find(PurchaseOrderInfo.class, event.getRelaOrderId());
       billsEnum = BillsEnum.PURCHASE;
       break;
     case Return:
       info = context.find(SaleCancel.class, event.getRelaOrderId());
       billsEnum = BillsEnum.SALE_CANCEL;
       break;
       //			case DirectSupply:
       //				info = context.find(PurchaseOrderInfo.class, event.getRelaOrderId());
       //				billsEnum = BillsEnum.PURCHASE;
       //				break;
     default:
       return;
   }
   if (CheckIsNull.isEmpty(info)) {
     throw new Throwable("相关单据编号在订单中不存在");
   }
   StatusEnum newstatus = InventoryDataUtil.getOrderStatusByIn(context, event.getRelaOrderId());
   if (!newstatus.isThis(info.getStatus())) {
     OrderUtil.modifystatus(
         billsEnum, context, info.getRECID(), newstatus, StatusEnum.getstatus(info.getStatus()));
     // 全部出库完成出库
     if (newstatus == StatusEnum.Store_All) {
       if (BillsEnum.PURCHASE == billsEnum) {
         context.dispatch(
             new PurchaseOrderChangedEvent(info.getRECID(), ChangedType.StoreFinish));
       } else {
         context.dispatch(new SalesReturnChangedEvent(info.getRECID(), ChangedType.StoreFinish));
       }
     }
   }
 }
 @Override
 protected void occur(Context context, CheckOutEvent event) throws Throwable {
   if (CheckIsNull.isEmpty(event.getRelaOrderId()) || CheckIsNull.isEmpty(event.getType())) {
     throw new Throwable("相关单据编号和出库类型不能为空");
   }
   OrderInfo info = null;
   BillsEnum billsEnum = null;
   switch (event.getType()) {
       //			Sales("01", "销售出库"), //
       //			Return("02", "采购退货"), //
       //			Retail("03", "零售出库"), //
       //			Kit("04", "其他出库");
     case Sales:
       info = context.find(SaleOrderInfo.class, event.getRelaOrderId());
       billsEnum = BillsEnum.SALE;
       break;
     case Return:
       info = context.find(PurchaseCancel.class, event.getRelaOrderId());
       billsEnum = BillsEnum.PURCHASE_CANCEL;
       break;
     default:
       return;
   }
   if (CheckIsNull.isEmpty(info)) {
     throw new Throwable("相关单据编号在订单中不存在");
   }
   StatusEnum newstatus = InventoryDataUtil.getOrderStatusByOut(context, event.getRelaOrderId());
   if (!newstatus.isThis(info.getStatus())) {
     OrderUtil.modifystatus(
         billsEnum, context, info.getRECID(), newstatus, StatusEnum.getstatus(info.getStatus()));
     // 全部出库完成出库
     if (newstatus == StatusEnum.Store_All) {
       if (BillsEnum.SALE == billsEnum) {
         context.dispatch(new SalesOrderChangedEvent(info.getRECID(), ChangedType.StoreFinish));
       } else {
         context.dispatch(
             new PurchaseReturnChangedEvent(info.getRECID(), ChangedType.StoreFinish));
       }
     }
   }
 }
示例#3
0
    @Override
    protected void handle(Context context, InstoAddTask task) throws Throwable {
      if (null == task.getEntity()) {
        return;
      }
      fillEntity(context, task.getEntity(), CheckingInType.Purchase.getCode());
      task.getEntity().setStatus(CheckingInStatus.None.getCode());
      InstorageTask it = new InstorageTask();
      it.setInstorageEntity(task.getEntity());
      context.handle(it, Method.INSERT);
      addDetails(context, task.getEntity(), task.getDetailList());
      // 采购在途
      modfiyCountOnWay(context, task, false);

      CheckingInEvent event = new CheckingInEvent();
      event.setCheckInSheetId(task.getEntity().getRECID());
      context.dispatch(event);
    }
 @Override
 protected void handle(Context context, ChangeCheckinRealAmount task) throws Throwable {
   UpdateSqlBuilder ub = new UpdateSqlBuilder(context);
   double amount = task.getAmount();
   if (amount < 0) {
     amount = DoubleUtil.sub(0, amount);
   }
   ub.setTable(ERPTableNames.Inventory.CheckinSheet.getTableName());
   ub.addExpression("value", ub.DOUBLE, amount, "paidAmount = t.paidAmount+@value");
   ub.addCondition("id", ub.guid, task.getId(), "t.RECID=@id");
   ub.addCondition("xxx", ub.STRING, "a", "t.amount-t.paidAmount>=@value");
   int count = ub.execute();
   if (0 == count) {
     throw new Exception("付款金额超出入库金额,请核对!");
   }
   CheckInBaseInfo info = context.find(CheckInBaseInfo.class, task.getId());
   if (info.getAmount() == info.getPaidAmount()) {
     context.dispatch(
         new CheckInSheetAmountBalanceCompleteEvent(info.getRelaBillsId(), info.getSheetType()));
   }
 }