@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));
       }
     }
   }
 }