Beispiel #1
0
        /// <summary>
        /// 根据单据信息构造台帐信息
        /// </summary>
        /// <param name="billMaster">单据头</param>
        /// <param name="billOrder">单据明细信息</param>
        /// <param name="storeNum">库存处理后药品库存信息</param>
        /// <param name="accountYear">会计年份</param>
        /// <param name="accountMonth">会计月份</param>
        /// <param name="smallUnit">基本单位</param>
        /// <returns>台帐信息</returns>
        override protected YP_Account BuildAccount(BillMaster billMaster, BillOrder billOrder, decimal storeNum,
                                                   int accountYear, int accountMonth, int smallUnit)
        {
            YP_Account     account = new YP_Account();
            YP_CheckMaster master  = (YP_CheckMaster)billMaster;
            YP_CheckOrder  order   = (YP_CheckOrder)billOrder;

            account.AccountYear  = accountYear;
            account.AccountMonth = accountMonth;;
            account.AccountType  = 2;
            account.Balance_Flag = 0;
            account.BillNum      = master.BillNum;
            account.OpType       = master.OpType;
            account.DeptID       = master.DeptID;
            account.LeastUnit    = smallUnit;
            account.UnitNum      = order.UnitNum;
            account.MakerDicID   = order.MakerDicID;
            account.RegTime      = master.AuditTime;
            account.RetailPrice  = order.RetailPrice;
            account.StockPrice   = order.TradePrice;
            account.OrderID      = order.CheckOrderID;
            if (order.CheckNum - order.FactNum > 0)
            {
                account.LenderNum = order.CheckNum - order.FactNum;
                account.LenderFee = Math.Abs(order.CKRetailFee - order.FTRetailFee);
            }
            else
            {
                account.DebitNum = order.FactNum - order.CheckNum;
                account.DebitFee = Math.Abs(order.CKRetailFee - order.FTRetailFee);
            }
            account.OverNum = storeNum;
            return(account);
        }
        /// <summary>
        /// 删除单据
        /// </summary>
        /// <param name="billMaster">单据头表</param>
        public override void DelBill(BillMaster billMaster)
        {
            try
            {
                YP_OutMaster outStore = (YP_OutMaster)billMaster;
                oleDb.BeginTransaction();
                YP_Dal ypDal = new YP_Dal();
                ypDal._oleDb = oleDb;
                IBaseDAL <YP_OutMaster> ykmasterDao = BindEntity <YP_OutMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_OUTMASTER);

                //删除表头信息
                ykmasterDao.Update(BLL.Tables.yk_outmaster.MASTEROUTSTORAGEID + oleDb.EuqalTo() + outStore.MasterOutStorageID,
                                   BLL.Tables.yf_outmaster.DEL_FLAG + oleDb.EuqalTo() + "1");
                if (outStore.OpType == ConfigManager.OP_YK_OUTTOYF)
                {
                    IBaseDAL <YP_InMaster> yfmasterDao = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INMASTER);

                    //删除表头信息
                    YP_InMaster deleteMaster = yfmasterDao.GetModel("BillNum=" + outStore.RelationNum.ToString()
                                                                    + " AND OpType='" + ConfigManager.OP_YF_APPLYIN + "'"
                                                                    + " AND DeptID=" + outStore.OutDeptId.ToString());
                    if (deleteMaster != null)
                    {
                        deleteMaster.Del_Flag = 1;
                        yfmasterDao.Update(deleteMaster);
                    }
                }
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Beispiel #3
0
        /// <summary>
        /// 修改采购计划单
        /// </summary>
        /// <param name="billMaster">采购计划表头</param>
        /// <param name="listOrder">采购计划明细列表</param>
        /// <param name="deptId">药剂科室ID</param>
        public override void UpdateBill(BillMaster billMaster, List <BillOrder> listOrder, long deptId)
        {
            try
            {
                YP_PlanMaster planMaster = (YP_PlanMaster)billMaster;
                oleDb.BeginTransaction();
                //声明操作对象
                IBaseDAL <YP_PlanMaster> masterDao = BindEntity <YP_PlanMaster> .CreateInstanceDAL(oleDb, Tables.YK_PLANMASTER);

                IBaseDAL <YP_PlanOrder> orderDao = BindEntity <YP_PlanOrder> .CreateInstanceDAL(oleDb, Tables.YK_PLANORDER);

                planMaster.RetailFee = 0;
                planMaster.TradeFee  = 0;
                orderDao.Delete(Tables.yk_planorder.PLANMASTERID + oleDb.EuqalTo() + planMaster.PlanMasterId);
                foreach (YP_PlanOrder planOrder in listOrder)
                {
                    //计算入库金额
                    planMaster.RetailFee  += planOrder.RetailFee;
                    planMaster.TradeFee   += planOrder.TradeFee;
                    planOrder.PlanMasterId = planMaster.PlanMasterId;
                    //依次添加明细记录
                    orderDao.Add(planOrder);
                }
                masterDao.Update(planMaster);
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Beispiel #4
0
        /// <summary>
        /// 保存门诊退药单(门诊退药)
        /// </summary>
        /// <param name="billMaster">单据表头</param>
        /// <param name="listOrder">单据明细列表</param>
        /// <param name="deptId">药剂科室ID</param>
        public override void SaveBill(BillMaster billMaster, List <BillOrder> listOrder, long deptId)
        {
            try
            {
                YP_DRMaster refMaster = (YP_DRMaster)billMaster;
                refMaster.RetailFee = 0;
                oleDb.BeginTransaction();
                //将发药单据表头写入数据库
                if (listOrder.Count > 0)
                {
                    //添加退药表头
                    BindEntity <HIS.Model.YP_DRMaster> .CreateInstanceDAL(oleDb, Tables.YF_DRMASTER).Add(refMaster);

                    foreach (YP_DROrder order in listOrder)
                    {
                        order.MasterDrugOCID = refMaster.MasterDrugOCID;
                        BindEntity <HIS.Model.YP_DROrder> .CreateInstanceDAL(oleDb, Tables.YF_DRORDER).Add(order);

                        refMaster.RetailFee += order.RetailFee;
                    }
                    refMaster.RetailFee = refMaster.RetailFee * refMaster.RecipeNum;
                    BindEntity <HIS.Model.YP_DRMaster> .CreateInstanceDAL(oleDb, Tables.YF_DRMASTER).Update(refMaster);

                    Hashtable storeTable = StoreFactory.GetProcessor(refMaster.OpType).ChangeStoreNum(billMaster, listOrder);
                    AccountFactory.GetWriter(refMaster.OpType).WriteAccount(billMaster, listOrder, storeTable);
                }
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Beispiel #5
0
        /// <summary>
        /// 获取细单
        /// </summary>
        /// <returns></returns>
        public DataTable SearchBillDetail(BillMaster billMaster)
        {
            string parameter = @"Parameter={'Method':'getDetail','ProductCode': '" + "" + "','OperateType':'" + billMaster.BillType + "','OperateArea':'" + "1,2,3" + "','Operator':'" + Dns.GetHostName() + "','BillMasters':" + JsonConvert.SerializeObject(new BillMaster[] { billMaster }) + "}";
            string msg       = util.GetDataFromServer(parameter);
            Result r         = JsonConvert.DeserializeObject <Result>(msg);

            DataTable table = GenDetailTable();


            for (int i = 0; i < r.BillDetails.Length; i++)
            {
                DataRow row = table.NewRow();

                row["DetailID"]             = r.BillDetails[i].DetailID;
                row["operateStorageName"]   = r.BillDetails[i].StorageName;
                row["targetStorageName"]    = r.BillDetails[i].TargetStorageName;
                row["operateName"]          = r.BillDetails[i].BillTypeName;
                row["operateProductName"]   = r.BillDetails[i].ProductName;
                row["operatePieceQuantity"] = r.BillDetails[i].PieceQuantity;
                row["operateBarQuantity"]   = r.BillDetails[i].BarQuantity;
                row["StatusName"]           = r.BillDetails[i].StatusName;

                table.Rows.Add(row);
            }


            return(table);
        }
        /// <summary>
        /// 根据单据信息构造台帐信息
        /// </summary>
        /// <param name="billMaster">单据头</param>
        /// <param name="billOrder">单据明细信息</param>
        /// <param name="storeNum">库存处理后药品库存信息</param>
        /// <param name="accountYear">会计年份</param>
        /// <param name="accountMonth">会计月份</param>
        /// <param name="smallUnit">基本单位</param>
        /// <returns>台帐信息</returns>
        override protected YP_Account BuildAccount(BillMaster billMaster, BillOrder billOrder, decimal storeNum,
                                                   int accountYear, int accountMonth, int smallUnit)
        {
            YP_DRMaster master  = (YP_DRMaster)billMaster;
            YP_DROrder  order   = (YP_DROrder)billOrder;
            YP_Account  account = new YP_Account();

            account.AccountYear  = accountYear;
            account.AccountMonth = accountMonth;;
            account.AccountType  = 2;
            account.Balance_Flag = 0;
            account.BillNum      = (master.InvoiceNum != 0 ? master.InvoiceNum : Convert.ToInt32(master.InpatientID));
            account.OpType       = master.OpType;
            account.DeptID       = master.DeptID;
            account.LeastUnit    = smallUnit;
            account.UnitNum      = order.UnitNum;
            account.MakerDicID   = order.MakerDicID;
            account.RegTime      = master.OPTime;
            account.RetailPrice  = order.RetailPrice;
            account.StockPrice   = order.TradePrice;
            account.OrderID      = order.OrderDrugOCID;
            if (master.InvoiceNum != 0)
            {
                account.DebitFee = order.RetailFee * master.RecipeNum;
                account.DebitNum = order.DrugOCNum * master.RecipeNum;
            }
            else
            {
                account.DebitFee = order.RetailFee;
                account.DebitNum = order.DrugOCNum;
            }
            account.OverNum = storeNum;
            return(account);
        }
Beispiel #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="billMaster"></param>
        public override void DelBill(BillMaster billMaster)
        {
            try
            {
                YP_OutMaster outStore = (YP_OutMaster)billMaster;
                oleDb.BeginTransaction();
                IBaseDAL <YP_OutMaster> masterDao = BindEntity <YP_OutMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_OUTMASTER);

                //删除表头信息
                masterDao.Update(BLL.Tables.yf_outmaster.MASTEROUTSTORAGEID + oleDb.EuqalTo() + outStore.MasterOutStorageID,
                                 BLL.Tables.yf_outmaster.DEL_FLAG + oleDb.EuqalTo() + "1");
                //如果是药品平级调拨
//add  平级药房调拨 张运辉 [20100531]
                object obj = HIS.SYSTEM.Core.BindEntity <HIS.BLL.Tables.yp_deptdic> .CreateInstanceDAL(oleDb).GetFieldValue("DEPTTYPE1", "DEPTID=" + outStore.OutDeptId);

                if (obj != null && obj.ToString() == "药房")
                {
                    IBaseDAL <YP_InMaster> yfInMaster = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INMASTER);

                    yfInMaster.Update("BillNum=" + outStore.RelationNum.ToString()
                                      + " AND OpType='" + ConfigManager.OP_YF_APPLYIN + "'"
                                      + " AND Audit_Flag=0" + " AND DeptID=" + outStore.OutDeptId.ToString(), "DEL_FLAG=1");
                }
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Beispiel #8
0
        /// <summary>
        /// 写入台帐
        /// </summary>
        /// <param name="billMaster">单据头表信息</param>
        /// <param name="orderList">单据明细信息</param>
        /// <param name="storeTable">库存处理后的最新药品库存信息</param>
        public override void WriteAccount(BillMaster billMaster, List <BillOrder> orderList, System.Collections.Hashtable storeTable)
        {
            try
            {
                int                   actYear = 0, actMonth = 0;
                YP_InMaster           master     = (YP_InMaster)billMaster;
                IBaseDAL <YP_Account> accountDao = BindEntity <YP_Account> .CreateInstanceDAL(oleDb, HIS.BLL.Tables.YK_ACCOUNT);

                AccountFactory.GetQuery(ConfigManager.YK_SYSTEM).GetAccountTime(master.AuditTime, ref actYear,
                                                                                ref actMonth, master.DeptID);
                foreach (YP_InOrder order in orderList)
                {
                    string     queryKey  = order.MakerDicID.ToString() + order.BatchNum.ToString();
                    decimal    storeNum  = ((YP_StoreNum)(storeTable[queryKey])).storeNum;
                    int        smallUnit = ((YP_StoreNum)(storeTable[queryKey])).smallUnit;
                    YP_Account account   = BuildAccount(billMaster, order, storeNum, actYear, actMonth, smallUnit);
                    ComputeFee(account);
                    accountDao.Add(account);
                }
            }
            catch (Exception error)
            {
                throw error;
            }
        }
        /// <summary>
        /// 修改盘点单据
        /// </summary>
        /// <param name="billMaster">盘点单表头</param>
        /// <param name="listOrder">盘点单明细列表</param>
        /// <param name="deptId">药剂科室ID</param>
        public override void UpdateBill(BillMaster billMaster, List <BillOrder> listOrder, long deptId)
        {
            try
            {
                YP_CheckMaster masterCheck = (YP_CheckMaster)billMaster;
                ComputeMasterFee(masterCheck, listOrder);
                oleDb.BeginTransaction();
                //声明操作对象
                HIS.DAL.YP_Dal ypDal = new YP_Dal();
                ypDal._oleDb = oleDb;
                YP_CheckOrder checkOrder = new YP_CheckOrder();
                BindEntity <HIS.Model.YP_CheckMaster> .CreateInstanceDAL(oleDb, Tables.YF_CHECKMASTER).Update(masterCheck);

                foreach (BillOrder order in listOrder)
                {
                    checkOrder = (YP_CheckOrder)order;
                    BindEntity <HIS.Model.YP_CheckOrder> .CreateInstanceDAL(oleDb, Tables.YF_CHECKORDER).Update(checkOrder);
                }
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Beispiel #10
0
        /// <summary>
        /// 创建药房期初入库单表头
        /// </summary>
        /// <param name="deptId">药剂科室ID</param>
        /// <param name="userId">用户ID</param>
        /// <returns>药房期初入库单表头</returns>
        public override BillMaster BuildNewMaster(long deptId, long userId)
        {
            BillMaster rtnMaster = base.BuildNewMaster(deptId, userId);

            ((YP_InMaster)rtnMaster).OpType = ConfigManager.OP_YF_INSTORE;
            return(rtnMaster);
        }
 public override Hashtable ChangeStoreNum(BillMaster billMaster, List <BillOrder> orderList)
 {
     try
     {
         Hashtable storeNumHash = new Hashtable();
         foreach (BillOrder order in orderList)
         {
             YP_CheckOrder orderCheck = (YP_CheckOrder)order;
             YP_StoreNum   storeNum   = new YP_StoreNum();
             if (orderCheck.CheckNum != orderCheck.FactNum)
             {
                 storeNum.makerDicId = orderCheck.MakerDicID;
                 storeNum.smallUnit  = orderCheck.LeastUnit;
                 storeNum.storeNum   = Convert.ToInt32(orderCheck.CheckNum);
                 storeNumHash.Add(storeNum.makerDicId, storeNum);
                 UpdateStoreNum(orderCheck.MakerDicID, orderCheck.DeptID, Convert.ToInt32(orderCheck.CheckNum));
             }
         }
         return(storeNumHash);
     }
     catch (Exception error)
     {
         throw error;
     }
 }
 public override Hashtable ChangeStoreNum(BillMaster billMaster, List <BillOrder> orderList)
 {
     try
     {
         Hashtable storeNumHash = new Hashtable();
         foreach (BillOrder order in orderList)
         {
             YP_StoreNum storeNum      = new YP_StoreNum();
             YP_OutOrder orderOutstore = (YP_OutOrder)order;
             storeNum.smallUnit  = orderOutstore.LeastUnit;
             storeNum.makerDicId = orderOutstore.MakerDicID;
             decimal reduceNum = orderOutstore.OutNum;
             decimal rtn       = ReduceStoreNum(orderOutstore.MakerDicID, orderOutstore.DeptID, reduceNum);
             if (rtn != -1)
             {
                 storeNum.storeNum = rtn;
                 storeNum.queryKey = storeNum.makerDicId.ToString() + orderOutstore.ProductNum;
             }
             else
             {
                 string drugName = DrugBaseDataBll.GetDurgName(storeNum.makerDicId);
                 throw new Exception("[" + drugName + "]" + "出库数量过多,审核失败");
             }
             storeNumHash.Add(storeNum.queryKey, storeNum);
         }
         BatchProcessor.ReduceBatchNum(orderList);
         return(storeNumHash);
     }
     catch (Exception error)
     {
         throw error;
     }
 }
 public override Hashtable ChangeStoreNum(BillMaster billMaster, List <BillOrder> orderList)
 {
     try
     {
         Hashtable storeNumHash = new Hashtable();
         //按厂家典ID对每种药品更新库存
         foreach (YP_CheckOrder order in orderList)
         {
             YP_StoreNum storeNum = new YP_StoreNum();
             storeNum.makerDicId = order.MakerDicID;
             storeNum.smallUnit  = order.LeastUnit;
             storeNum.storeNum   = order.CheckNum;
             storeNumHash.Add(order.MakerDicID, storeNum);
             if (order.CheckNum != order.FactNum)
             {
                 UpdateStoreNum(order.MakerDicID, order.DeptID, order.CheckNum);
             }
         }
         return(storeNumHash);
     }
     catch (Exception error)
     {
         throw error;
     }
 }
Beispiel #14
0
        /// <summary>
        /// 写入台帐
        /// </summary>
        /// <param name="billMaster">单据头表信息</param>
        /// <param name="orderList">单据明细信息</param>
        /// <param name="storeTable">库存处理后的最新药品库存信息</param>
        public override void WriteAccount(BillMaster billMaster, List <BillOrder> orderList, Hashtable storeTable)
        {
            try
            {
                int                   actYear = 0, actMonth = 0;
                decimal               storeNum;
                int                   smallUnit;
                YP_CheckMaster        master     = (YP_CheckMaster)billMaster;
                IBaseDAL <YP_Account> accountDao = BindEntity <YP_Account> .CreateInstanceDAL(oleDb, HIS.BLL.Tables.YF_ACCOUNT);

                AccountFactory.GetQuery(ConfigManager.YF_SYSTEM).GetAccountTime(master.AuditTime, ref actYear,
                                                                                ref actMonth, master.DeptID);
                foreach (YP_CheckOrder order in orderList)
                {
                    if (order.CheckNum != order.FactNum)
                    {
                        storeNum  = ((YP_StoreNum)(storeTable[order.MakerDicID])).storeNum;
                        smallUnit = ((YP_StoreNum)(storeTable[order.MakerDicID])).smallUnit;
                        YP_Account account = BuildAccount(billMaster, order, storeNum, actYear, actMonth, smallUnit);
                        ComputeFee(account);
                        accountDao.Add(account);
                    }
                }
            }
            catch (Exception error)
            {
                throw error;
            }
        }
 public override Hashtable ChangeStoreNum(BillMaster billMaster, List <BillOrder> orderList)
 {
     try
     {
         Hashtable   storeNumHash = new Hashtable();
         YP_DRMaster refMaster    = (YP_DRMaster)billMaster;
         foreach (BillOrder billOrder in orderList)
         {
             YP_StoreNum storeNum = new YP_StoreNum();
             YP_DROrder  order    = (YP_DROrder)billOrder;
             storeNum.makerDicId = order.MakerDicID;
             storeNum.smallUnit  = order.LeastUnit;
             int     addNum = Convert.ToInt32(order.DrugOCNum * refMaster.RecipeNum);
             decimal rtn    = AddStoreNum(order.MakerDicID, order.DeptID, addNum);
             if (rtn != -1)
             {
                 storeNum.storeNum = rtn;
                 storeNum.queryKey = storeNum.makerDicId.ToString() + order.OrderRecipeID.ToString();
                 storeNumHash.Add(storeNum.queryKey, storeNum);
             }
             else
             {
                 throw new Exception(order.ChemName + "药品从未入过库");
             }
         }
         return(storeNumHash);
     }
     catch (Exception error)
     {
         throw error;
     }
 }
 public override Hashtable ChangeStoreNum(BillMaster billMaster, List <BillOrder> orderList)
 {
     try
     {
         Hashtable storeNumHash = new Hashtable();
         foreach (BillOrder order in orderList)
         {
             YP_StoreNum storeNum      = new YP_StoreNum();
             YP_OutOrder orderOutstore = (YP_OutOrder)order;
             storeNum.smallUnit  = ypDal.Unit_GetSmallUnit(orderOutstore.MakerDicID);
             storeNum.makerDicId = orderOutstore.MakerDicID;
             decimal reduceNum = orderOutstore.OutNum * orderOutstore.UnitNum;
             decimal rtn       = ReduceStoreNum(orderOutstore.MakerDicID, orderOutstore.DeptID, reduceNum);
             if (rtn != -1)
             {
                 storeNum.storeNum = rtn;
             }
             else
             {
                 throw new Exception("出库数量过多,审核失败");
             }
             storeNumHash.Add(storeNum.makerDicId, storeNum);
         }
         return(storeNumHash);
     }
     catch (Exception error)
     {
         throw error;
     }
 }
Beispiel #17
0
        /// <summary>
        /// 删除药房期初入库单
        /// </summary>
        /// <param name="billMaster">药房期初入库单表头</param>
        public override void DelBill(BillMaster billMaster)
        {
            try
            {
                YP_InMaster inStore = (YP_InMaster)billMaster;
                oleDb.BeginTransaction();
                IBaseDAL <YP_InMaster> yfInMaster = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INMASTER);

                yfInMaster.Update(BLL.Tables.yf_inmaster.MASTERINSTORAGEID + oleDb.EuqalTo() + inStore.MasterInStorageID,
                                  BLL.Tables.yf_inmaster.DEL_FLAG + oleDb.EuqalTo() + "1");
                YP_Dal ypDal = new YP_Dal();
                ypDal._oleDb = oleDb;
                int deleteID = ypDal.YK_Outmaster_GetIDByBillNum(inStore.BillNum, inStore.DeptID);
                //做关联删除
                if (deleteID != -1)
                {
                    IBaseDAL <YP_OutMaster> ykOutMaster = BindEntity <YP_OutMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_OUTMASTER);

                    ykOutMaster.Update(BLL.Tables.yk_outmaster.MASTEROUTSTORAGEID + oleDb.EuqalTo() + deleteID,
                                       BLL.Tables.yk_outmaster.DEL_FLAG + oleDb.EuqalTo() + "1");
                }
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Beispiel #18
0
        /// <summary>
        /// 保存采购计划单
        /// </summary>
        /// <param name="billMaster">采购计划表头</param>
        /// <param name="listOrder">采购计划明细列表</param>
        /// <param name="deptId">药剂科室ID</param>
        public override void SaveBill(BillMaster billMaster, List <BillOrder> listOrder, long deptId)
        {
            try
            {
                YP_PlanMaster            planMaster = (YP_PlanMaster)billMaster;
                IBaseDAL <YP_PlanMaster> masterDao  = BindEntity <YP_PlanMaster> .CreateInstanceDAL(oleDb, Tables.YK_PLANMASTER);

                IBaseDAL <YP_PlanOrder> orderDao = BindEntity <YP_PlanOrder> .CreateInstanceDAL(oleDb, Tables.YK_PLANORDER);

                planMaster.RegTime       = XcDate.ServerDateTime;
                planMaster.LASTCHANGTIME = XcDate.ServerDateTime;
                planMaster.TradeFee      = 0;
                planMaster.RetailFee     = 0;
                oleDb.BeginTransaction();
                //写头表信息获取ID号
                masterDao.Add(planMaster);
                foreach (YP_PlanOrder planOrder in listOrder)
                {
                    //计算头表合计金额
                    planMaster.RetailFee  += planOrder.RetailFee;
                    planMaster.TradeFee   += planOrder.TradeFee;
                    planOrder.PlanMasterId = planMaster.PlanMasterId;
                    //依次添加明细记录
                    orderDao.Add(planOrder);
                }
                masterDao.Update(planMaster);
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Beispiel #19
0
 /// <summary>
 /// 加载药房申请入库单明细
 /// </summary>
 /// <param name="billMaster">单据头表</param>
 /// <returns></returns>
 public override DataTable LoadOrder(BillMaster billMaster)
 {
     try
     {
         if (billMaster != null)
         {
             YP_InMaster inStore  = (YP_InMaster)billMaster;
             string      strWhere = "";
             YP_Dal      ypDal    = new YP_Dal();
             ypDal._oleDb = oleDb;
             if (inStore != null)
             {
                 strWhere  = "A.MasterInStorageID=" + inStore.MasterInStorageID.ToString();
                 strWhere += oleDb.And() + "A.DeptID" + oleDb.EuqalTo() + inStore.DeptID;
             }
             else
             {
                 strWhere = "0<>0";
             }
             return(ypDal.YF_Inorder_GetList(strWhere));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception error)
     {
         throw error;
     }
 }
Beispiel #20
0
        /// <summary>
        /// 根据单据信息构造台帐信息
        /// </summary>
        /// <param name="billMaster">单据头</param>
        /// <param name="billOrder">单据明细信息</param>
        /// <param name="storeNum">库存处理后药品库存信息</param>
        /// <param name="accountYear">会计年份</param>
        /// <param name="accountMonth">会计月份</param>
        /// <param name="smallUnit">基本单位</param>
        /// <returns>台帐信息</returns>
        override protected YP_Account BuildAccount(BillMaster billMaster, BillOrder billOrder, decimal storeNum,
                                                   int accountYear, int accountMonth, int smallUnit)
        {
            YP_OutMaster master  = (YP_OutMaster)billMaster;
            YP_OutOrder  order   = (YP_OutOrder)billOrder;
            YP_Account   account = new YP_Account();

            account.AccountYear  = accountYear;
            account.AccountMonth = accountMonth;
            account.AccountType  = 2;
            account.Balance_Flag = 0;
            account.BillNum      = master.BillNum;
            account.OpType       = master.OpType;
            account.DeptID       = master.DeptID;
            account.LeastUnit    = smallUnit;
            account.UnitNum      = order.UnitNum;
            account.MakerDicID   = order.MakerDicID;
            account.RegTime      = master.AuditTime;
            account.RetailPrice  = order.RetailPrice;
            account.StockPrice   = order.TradePrice;
            account.OrderID      = order.OutStorageID;
            account.DebitFee     = order.RetailFee;
            account.OverNum      = storeNum;
            account.BalanceFee   = 0;
            return(account);
        }
        /// <summary>
        /// 审核调价单
        /// </summary>
        /// <param name="billMaster">调价单头表</param>
        /// <param name="auditerID">审核人员ID</param>
        /// <param name="auditDeptID">审核科室ID</param>
        public override void AuditBill(BillMaster billMaster, long auditerID, long auditDeptID)
        {
            try
            {
                HIS.DAL.YP_Dal ypDal = new YP_Dal();
                ypDal._oleDb = oleDb;
                string       strWhere;
                YP_AdjMaster masterAdj    = (YP_AdjMaster)billMaster;
                string       belongSystem = (masterAdj.OpType == ConfigManager.OP_YF_ADJPRICE ? ConfigManager.YF_SYSTEM : ConfigManager.YK_SYSTEM);
                if (ConfigManager.IsChecking((long)masterAdj.DeptID))
                {
                    string deptName = BaseData.GetDeptName(masterAdj.DeptID.ToString());
                    throw new Exception("[" + deptName + "]" + "库房药品正在盘点中....");
                }
                masterAdj.Audit_Flag = 1;
                masterAdj.Over_Flag  = 1;
                BindEntity <HIS.Model.YP_AdjMaster> .CreateInstanceDAL(oleDb).Update(masterAdj);

                strWhere = Tables.yp_adjorder.MASTERIADJPRICED + oleDb.EuqalTo() + masterAdj.MasterAdjPriceID;
                List <YP_AdjOrder> orderList = BindEntity <HIS.Model.YP_AdjOrder> .CreateInstanceDAL(oleDb).GetListArray(strWhere);

                List <BillOrder> billOrderList = new List <BillOrder>();
                Hashtable        storeTable    = new Hashtable();
                foreach (YP_AdjOrder adjOrder in orderList)
                {
                    YP_StoreNum yp_StoreNum = new YP_StoreNum();
                    decimal     storeNum    = StoreFactory.GetQuery(belongSystem).QueryNum(adjOrder.MakerDicID, adjOrder.DeptID);
                    adjOrder.Audit_Flag    = 1;
                    adjOrder.AdjNum        = storeNum;
                    yp_StoreNum.makerDicId = adjOrder.MakerDicID;
                    if (belongSystem == ConfigManager.YK_SYSTEM)
                    {
                        yp_StoreNum.smallUnit = adjOrder.LeastUnit;
                    }
                    else
                    {
                        yp_StoreNum.smallUnit = ypDal.Unit_GetSmallUnit(adjOrder.MakerDicID);
                    }
                    yp_StoreNum.storeNum = storeNum;
                    storeTable.Add(yp_StoreNum.makerDicId, yp_StoreNum);
                    //计算调赢/亏金额
                    ComputeAdjFee(adjOrder, belongSystem);
                    billOrderList.Add(adjOrder);
                    BindEntity <HIS.Model.YP_AdjOrder> .CreateInstanceDAL(oleDb).Update(adjOrder);
                }
                //记账
                AccountFactory.GetWriter(masterAdj.OpType).WriteAccount(masterAdj, billOrderList, storeTable);
                //更新药典价格
                foreach (YP_AdjOrder adjOrder in orderList)
                {
                    ChangePrice(adjOrder.NewRetailPrice, true, adjOrder.MakerDicID);
                    ChangePrice(adjOrder.NewTradePrice, false, adjOrder.MakerDicID);
                }
            }
            catch (Exception error)
            {
                throw error;
            }
        }
        /// <summary>
        /// 构造退库单对性
        /// </summary>
        /// <param name="deptId">单据所属科室ID</param>
        /// <param name="userId">用户ID</param>
        /// <returns></returns>
        public override HIS.Model.BillMaster BuildNewMaster(long deptId, long userId)
        {
            BillMaster rtnMaster = base.BuildNewMaster(deptId, userId);

            //指定业务类型为退库业务类型
            ((YP_InMaster)rtnMaster).OpType = ConfigManager.OP_YK_BACKSTORE;
            return(rtnMaster);
        }
        public void GetListBillMaster <T>(T objFilter, ref List <T> listData) where T : class, IModel, new()
        {
            string             sQuery  = "GetListBillMaster";
            BillMaster         objData = objFilter as BillMaster;
            List <DbParameter> list    = new List <DbParameter>();

            list.Add(SqlConnManager.GetConnParameters("RecNo", "RecNo", 8, GenericDataType.Long, ParameterDirection.Input, objData.RecNo));
            SqlConnManager.GetList <T>(sQuery, CommandType.StoredProcedure, list.ToArray(), FillBillMasterDataFromReader, ref listData);
        }
Beispiel #24
0
 public long CreateNewBill(BillMaster billMaster)
 {
     using (var context = new InvoiceGenEntities())
     {
         context.BillMasters.Add(billMaster);
         context.SaveChanges();//this generates the Id for customer
         return(billMaster.ID);
     }
 }
        /// <summary>
        /// 根据单据信息构造台帐信息
        /// </summary>
        /// <param name="billMaster">单据头</param>
        /// <param name="billOrder">单据明细信息</param>
        /// <param name="storeNum">库存处理后药品库存信息</param>
        /// <param name="accountYear">会计年份</param>
        /// <param name="accountMonth">会计月份</param>
        /// <param name="smallUnit">基本单位</param>
        /// <returns>台帐信息</returns>
        protected override YP_Account BuildAccount(BillMaster billMaster, BillOrder billOrder, decimal storeNum,
                                                   int accountYear, int accountMonth, int smallUnit)
        {
            YP_InOrder order   = (YP_InOrder)billOrder;
            YP_Account account = base.BuildAccount(billMaster, billOrder, storeNum, accountYear, accountMonth, smallUnit);

            account.LenderNum = order.InNum;
            return(account);
        }
Beispiel #26
0
        /// <summary>
        /// 审核药房申请入库单
        /// </summary>
        /// <param name="billMaster">药房申请入库单表头</param>
        /// <param name="auditerID">审核人员ID</param>
        /// <param name="auditDeptID">审核科室ID</param>
        public override void AuditBill(BillMaster billMaster, long auditerID, long auditDeptID)
        {
            YP_InMaster inStore = (YP_InMaster)billMaster;

            try
            {
                ////update 20100624
                if (HIS.SYSTEM.Core.BindEntity <object> .CreateInstanceDAL(oleDb, "YP_DEPTDIC").GetFieldValue("DEPTTYPE1", "DEPTID=" + inStore.DeptID).ToString() == "药房")
                {
                    boPjdb = true;
                }
                else
                {
                    boPjdb = false;
                }
                if (billMaster == null)
                {
                    throw new Exception("对应领药单丢失");
                }
                IBaseDAL <YP_InMaster> yfInMaster = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INMASTER);

                IBaseDAL <YP_InOrder> yfInOrder = BindEntity <YP_InOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INORDER);

                List <YP_InOrder> listOrder     = yfInOrder.GetListArray("MasterInStorageID=" + inStore.MasterInStorageID + "");
                List <BillOrder>  billListOrder = new List <BillOrder>();
                base.AuditPrice(inStore, listOrder, ConfigManager.YF_SYSTEM);
                inStore.AuditTime     = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime;
                inStore.Audit_Flag    = 1;
                inStore.AuditPeopleID = Convert.ToInt32(auditerID);
                yfInMaster.Update(inStore);
                foreach (YP_InOrder orderInstore in listOrder)
                {
                    orderInstore.Audit_Flag = 1;
                    yfInOrder.Update(orderInstore);
                    billListOrder.Add(orderInstore);
                }


                Hashtable storeTable;
                if (((YP_InMaster)billMaster).OpType == ConfigManager.OP_YF_PJDB)
                {
                    ((YP_InMaster)billMaster).OpType = ConfigManager.OP_YF_APPLYIN;
                    storeTable = StoreFactory.GetProcessor(ConfigManager.OP_YF_APPLYIN).ChangeStoreNum(billMaster, billListOrder);
                }
                else
                {
                    storeTable = StoreFactory.GetProcessor(inStore.OpType).ChangeStoreNum(billMaster, billListOrder);
                }
                AccountFactory.GetWriter(inStore.OpType).WriteAccount(billMaster, billListOrder, storeTable);
            }
            catch (Exception error)
            {
                inStore.Audit_Flag = 0;
                throw error;
            }
        }
        /// <summary>
        /// 保存门诊发药单(门诊发药)
        /// </summary>
        /// <param name="billMaster">门诊发药单表头</param>
        /// <param name="listOrder">门诊发药单明细</param>
        /// <param name="deptId">药剂科室ID</param>
        public override void SaveBill(BillMaster billMaster, List <BillOrder> listOrder, long deptId)
        {
            try
            {
                YP_DRMaster dispMaster = (YP_DRMaster)billMaster;
                dispMaster.RetailFee = 0;
                YP_Storage store = new YP_Storage();
                //将发药单据表头写入数据库
                if (listOrder.Count > 0)
                {
                    //开启发药事务
                    oleDb.BeginTransaction();
                    string strWhere = BLL.Tables.yf_drmaster.RECIPEID + oleDb.EuqalTo() + dispMaster.RecipeID.ToString();
                    if (BindEntity <YP_DRMaster> .CreateInstanceDAL(oleDb, Tables.YF_DRMASTER).Exists(strWhere))
                    {
                        throw new Exception("该张发票已经发过药品,请刷新病人列表");
                    }
                    BindEntity <HIS.Model.YP_DRMaster> .CreateInstanceDAL(oleDb, Tables.YF_DRMASTER).Add(dispMaster);

                    //更新处方头
                    MZ_BLL.YP_Interface.UpdateSendDrugFlag(dispMaster.RecipeID);
                    //将生成的发药单据表头标识ID赋给所有发药明细
                    foreach (BillOrder baseOrder in listOrder)
                    {
                        YP_DROrder order = (YP_DROrder)baseOrder;
                        order.MasterDrugOCID = dispMaster.MasterDrugOCID;
                        YP_DROrder drOrder = (YP_DROrder)order;
                        BindEntity <HIS.Model.YP_DROrder> .CreateInstanceDAL(oleDb, Tables.YF_DRORDER).Add(order);

                        dispMaster.RetailFee += order.RetailFee;
                    }
                    dispMaster.RetailFee = dispMaster.RetailFee * dispMaster.RecipeNum;
                    BindEntity <HIS.Model.YP_DRMaster> .CreateInstanceDAL(oleDb, Tables.YF_DRMASTER).Update(dispMaster);

                    Hashtable storeTable = StoreFactory.GetProcessor(dispMaster.OpType).ChangeStoreNum(billMaster, listOrder);
                    //foreach (YP_StoreNum storeInfo in storeTable.Values)
                    //{
                    //    if (storeInfo.storeNum == -1)
                    //    {
                    //        noStoreList.Add(storeInfo);
                    //    }

                    //}
                    AccountFactory.GetWriter(dispMaster.OpType).WriteAccount(billMaster, listOrder, storeTable);
                    oleDb.CommitTransaction();
                }
            }
            catch (Exception error)
            {
                if (oleDb.IsInTransaction)
                {
                    oleDb.RollbackTransaction();
                }
                throw error;
            }
        }
 private void FillBillMasterDataFromReader <T>(DbDataReader DbReader, ref List <T> listData) where T : class, IModel, new()
 {
     while (DbReader.Read())
     {
         T          obj     = new T();
         BillMaster objData = obj as BillMaster;
         obj.FillDataFromDB(DbReader);
         listData.Add(obj);
     }
 }
Beispiel #29
0
 /// <summary>
 /// 加载采购计划单据明细
 /// </summary>
 /// <param name="billMaster">单据头表</param>
 /// <returns></returns>
 public override DataTable LoadOrder(BillMaster billMaster)
 {
     if (billMaster != null)
     {
         YP_PlanMaster master = (YP_PlanMaster)billMaster;
         if (master.PlanMasterId != -1)
         {
             string strWhere = HIS.BLL.Tables.yk_planmaster.PLANMASTERID + oleDb.EuqalTo()
                               + master.PlanMasterId;
             YP_Dal dal = new YP_Dal();
             dal._oleDb = oleDb;
             return(dal.YK_PlanOrder_GetList(strWhere));
         }
         else
         {
             string strWhere = HIS.BLL.Tables.yk_planmaster.PLANMASTERID + oleDb.EuqalTo()
                               + master.PlanMasterId;
             YP_Dal dal = new YP_Dal();
             dal._oleDb = oleDb;
             DataTable  orderDt        = dal.YK_PlanOrder_GetList(strWhere);
             StoreQuery storeQuery     = StoreFactory.GetQuery(ConfigManager.YK_SYSTEM);
             DataTable  lowerStoreDrug = storeQuery.GetDrugForStoreLimit("", false,
                                                                         (int)master.DeptId, 0);
             for (int index = 0; index < lowerStoreDrug.Rows.Count; index++)
             {
                 DataRow limitRow = lowerStoreDrug.Rows[index];
                 decimal stockNum = Convert.ToDecimal(limitRow["UPPERLIMIT"]) -
                                    Convert.ToDecimal(limitRow["CURRENTNUM"]);
                 if (stockNum > 0)
                 {
                     DataRow newRow = orderDt.NewRow();
                     newRow["MAKERDICID"]   = limitRow["MAKERDICID"];
                     newRow["CHEMNAME"]     = limitRow["CHEMNAME"];
                     newRow["SPEC"]         = limitRow["SPEC"];
                     newRow["PRODUCTNAME"]  = limitRow["PRODUCTNAME"];
                     newRow["PLANMASTERID"] = 0;
                     newRow["PLANORDERID"]  = 0;
                     newRow["RETAILPRICE"]  = limitRow["RETAILPRICE"];
                     newRow["TRADEPRICE"]   = limitRow["TRADEPRICE"];
                     newRow["UNIT"]         = limitRow["LEASTUNIT"];
                     newRow["UNITNAME"]     = limitRow["PACKUNITNAME"];
                     newRow["STOCKNUM"]     = stockNum;
                     newRow["RETAILFEE"]    = stockNum * Convert.ToDecimal(newRow["RETAILPRICE"]);
                     newRow["TRADEFEE"]     = stockNum * Convert.ToDecimal(newRow["TRADEPRICE"]);
                     orderDt.Rows.Add(newRow);
                 }
             }
             return(orderDt);
         }
     }
     else
     {
         return(null);
     }
 }
Beispiel #30
0
        public async Task <ServiceResponseModel <BillMasterModel> > Add(BillMasterModel newBillMasterModel)
        {
            ServiceResponseModel <BillMasterModel> serviceResponse = new ServiceResponseModel <BillMasterModel>();
            BillMaster billMaster = _mapper.Map <BillMaster>(newBillMasterModel);
            await UnitOfWork.BillMasters.AddAsync(billMaster);

            await UnitOfWork.Complete();

            serviceResponse.Data = newBillMasterModel;
            return(serviceResponse);
        }
        protected BillMaster GetObject(DataRow dr)
        {
            BillMaster objBillMaster = new BillMaster();
            objBillMaster.Id = (dr["Id"] == DBNull.Value) ? 0 : (Int64)dr["Id"];
            objBillMaster.BillNo = (dr["BillNo"] == DBNull.Value) ? "" : (String)dr["BillNo"];
            objBillMaster.TenantId = (dr["TenantId"] == DBNull.Value) ? 0 : (Int64)dr["TenantId"];
            objBillMaster.BilGeneratelDate = (dr["BilGeneratelDate"] == DBNull.Value) ? DateTime.MinValue : (DateTime)dr["BilGeneratelDate"];
            objBillMaster.BillMonth = (dr["BillMonth"] == DBNull.Value) ? "" : (String)dr["BillMonth"];
            objBillMaster.BillYear = (dr["BillYear"] == DBNull.Value) ? 0 : (Int32)dr["BillYear"];
            objBillMaster.GenerateBy = (dr["GenerateBy"] == DBNull.Value) ? 0 : (Int32)dr["GenerateBy"];
            objBillMaster.ApprovedBy = (dr["ApprovedBy"] == DBNull.Value) ? 0 : (Int32)dr["ApprovedBy"];
            objBillMaster.TotalAmount = (dr["TotalAmount"] == DBNull.Value) ? 0 : (Decimal)dr["TotalAmount"];
            objBillMaster.TotalPayment = (dr["TotalPayment"] == DBNull.Value) ? 0 : (Decimal)dr["TotalPayment"];
            objBillMaster.Due = (dr["Due"] == DBNull.Value) ? 0 : (Decimal)dr["Due"];
            objBillMaster.LastPaymentDate = (dr["LastPaymentDate"] == DBNull.Value) ? DateTime.MinValue : (DateTime)dr["LastPaymentDate"];

            return objBillMaster;
        }
Beispiel #32
0
 public void GetBillMaster(string[] BillTypes, Result result)
 {
     BillMaster[] billMasters = new BillMaster[] { };
     try
     {
         foreach (var billType in BillTypes)
         {
             switch (billType)
             {
                 case "1"://入库单
                     var inBillMasters = InBillMasterRepository.GetQueryable()
                         .Where(i => i.Status == "4" || i.Status == "5")
                         .Select(i => new BillMaster() { BillNo = i.BillNo, BillType = "1" })
                         .ToArray();
                     billMasters = billMasters.Concat(inBillMasters).ToArray();
                     break;
                 case "2"://出库单
                     var outBillMasters = OutBillMasterRepository.GetQueryable()
                         .Where(i => i.Status == "4" || i.Status == "5")
                         .Select(i => new BillMaster() { BillNo = i.BillNo, BillType = "2" })
                         .ToArray();
                     billMasters = billMasters.Concat(outBillMasters).ToArray();
                     break;
                 case "3"://移库单
                     var moveBillMasters = MoveBillMasterRepository.GetQueryable()
                         .Where(i => i.Status == "2" || i.Status == "3")
                         .Select(i => new BillMaster() { BillNo = i.BillNo, BillType = "3" })
                         .ToArray();
                     billMasters = billMasters.Concat(moveBillMasters).ToArray();
                     break;
                 case "4"://盘点单
                     var checkBillMasters = CheckBillMasterRepository.GetQueryable()
                         .Where(i => i.Status == "2" || i.Status == "3")
                         .Select(i => new BillMaster() { BillNo = i.BillNo, BillType = "4" })
                         .ToArray();
                     billMasters = billMasters.Concat(checkBillMasters).ToArray();
                     break;
                 default:
                     break;
             }
         }
         result.IsSuccess = true;
         result.BillMasters = billMasters;
     }
     catch (Exception e)
     {
         result.IsSuccess = false;
         result.Message = "调用服务器服务查询订单主表失败,详情:" +e.InnerException.Message+"  其他错误:" +e.Message;
     }
 }
Beispiel #33
0
        public void GetBillDetail(BillMaster[] billMasters, string productCode, string OperateType, string OperateAreas, string Operator, Result result)
        {
            BillDetail[] billDetails = new BillDetail[] { };
            var ops = OperateAreas.Split(',').Select(a => Convert.ToInt32(a)).ToArray();

            try
            {
                foreach (var billMaster in billMasters)
                {
                    string billNo = billMaster.BillNo;
                    switch (billMaster.BillType)
                    {
                        #region 读入库单细单
                        case "1"://入库单
                            var inBillDetails = InBillAllotRepository.GetQueryable()
                                .WhereIn(m => m.Cell.Layer, ops)
                                .Where(i => i.BillNo == billNo
                                    && (i.ProductCode == productCode || productCode == string.Empty)
                                    && (i.Status == "0" || (i.Status == "1" && i.Operator == Operator)))
                                .Select(i => new BillDetail() {
                                    BillNo = i.BillNo,
                                    BillType = "1" ,

                                    DetailID = i.ID,
                                    StorageName = i.Cell.CellName,
                                    StorageRfid = i.Storage.Rfid,
                                    CellRfid = i.Cell.Rfid,
                                    TargetStorageName = "",
                                    TargetStorageRfid = "",

                                    ProductCode = i.ProductCode,
                                    ProductName = i.Product.ProductName,

                                    PieceQuantity =Math.Floor(i.AllotQuantity/i.Product.UnitList.Unit01.Count),
                                    BarQuantity = Math.Floor((i.AllotQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),
                                    OperatePieceQuantity = Math.Floor(i.AllotQuantity / i.Product.UnitList.Unit01.Count),
                                    OperateBarQuantity = Math.Floor((i.AllotQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),

                                    OperatorCode = string.Empty,
                                    Operator = i.Operator,
                                    Status = i.Status,
                                })
                                .ToArray();
                            billDetails = billDetails.Concat(inBillDetails).ToArray();
                            break;
                            #endregion
                        #region 读出库单细单
                        case "2"://出库单
                            var outBillDetails = OutBillAllotRepository.GetQueryable()
                                .WhereIn(m => m.Cell.Layer, ops)
                                .Where(i => i.BillNo == billNo
                                    && (i.CanRealOperate == "1" || OperateType != "Real")
                                    && (i.Status == "0" || (i.Status == "1" && i.Operator == Operator)))
                                .Select(i => new BillDetail()
                                {
                                    BillNo = i.BillNo,
                                    BillType = "2",

                                    DetailID = i.ID,
                                    StorageName = i.Cell.CellName,
                                    StorageRfid = i.Storage.Rfid,
                                    CellRfid =i.Cell.Rfid,
                                    TargetStorageName = "",
                                    TargetStorageRfid = "",

                                    ProductCode = i.ProductCode,
                                    ProductName = i.Product.ProductName,

                                    PieceQuantity = Math.Floor(i.AllotQuantity / i.Product.UnitList.Unit01.Count),
                                    BarQuantity = Math.Floor((i.AllotQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),
                                    OperatePieceQuantity = Math.Floor(i.AllotQuantity / i.Product.UnitList.Unit01.Count),
                                    OperateBarQuantity = Math.Floor((i.AllotQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),

                                    OperatorCode = string.Empty,
                                    Operator = i.Operator,
                                    Status = i.Status,
                                })
                                .ToArray();
                            billDetails = billDetails.Concat(outBillDetails).ToArray();

                            var outBillMaster = OutBillMasterRepository.GetQueryable()
                                .Where(i => i.BillNo == billNo)
                                .FirstOrDefault();
                            if (outBillMaster != null && outBillMaster.MoveBillMasterBillNo != null)
                            {
                                billNo = outBillMaster.MoveBillMasterBillNo;
                                //todo;
                                var moveBillDetailss = MoveBillDetailRepository.GetQueryable()
                                        .WhereIn(m => m.InCell.Layer, ops)
                                        .Where(i => i.BillNo == billNo
                                            && (i.CanRealOperate == "1" || OperateType != "Real")
                                            && (i.Status == "0" || (i.Status == "1" && i.Operator == Operator)))
                                        .ToArray()
                                        .Select(i => new BillDetail()
                                        {
                                            BillNo = i.BillNo,
                                            BillType = "3",

                                            DetailID = i.ID,
                                            StorageName = i.OutCell.CellName,
                                            StorageRfid = i.OutCell.Rfid,
                                            TargetStorageName = i.InCell.CellName,
                                            TargetStorageRfid = i.InCell.Rfid,

                                            ProductCode = i.ProductCode,
                                            ProductName = i.Product.ProductName,

                                            PieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count),
                                            BarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),
                                            OperatePieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count),
                                            OperateBarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),

                                            OperatorCode = string.Empty,
                                            Operator = i.Operator,
                                            Status = i.Status,
                                        })
                                        .ToArray();
                                billDetails = billDetails.Concat(moveBillDetailss).ToArray();
                            }
                            break;
                        #endregion
                        #region 读移库单细单
                        case "3"://移库单
                            var moveBillDetails = MoveBillDetailRepository.GetQueryable()
                                .WhereIn(m => m.InCell.Layer, ops)
                                .Where(i => i.BillNo == billNo
                                    && (i.CanRealOperate == "1" || OperateType != "Real")
                                    && (i.Status == "0" || (i.Status == "1" && i.Operator == Operator)))
                                .Select(i => new BillDetail()
                                {
                                    BillNo = i.BillNo,
                                    BillType = "3",

                                    DetailID = i.ID,
                                    StorageName = i.OutCell.CellName,
                                    StorageRfid = i.OutStorage.Rfid,
                                    CellRfid = i.OutCell.Rfid,
                                    TargetStorageName = i.InCell.CellName,
                                    TargetStorageRfid = i.InCell.Rfid,

                                    ProductCode = i.ProductCode,
                                    ProductName = i.Product.ProductName,

                                    PieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count),
                                    BarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),
                                    OperatePieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count),
                                    OperateBarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),

                                    OperatorCode = string.Empty,
                                    Operator = i.Operator,
                                    Status = i.Status,
                                    PalletTag = i.PalletTag??0
                                })
                                .ToArray();
                            billDetails = billDetails.Concat(moveBillDetails).ToArray();
                            break;
                        #endregion
                        #region 读盘点单细单
                        case "4"://盘点单
                            var checkBillDetails = CheckBillDetailRepository.GetQueryable()
                                .WhereIn(m => m.Cell.Layer, ops)
                                .Where(i => i.BillNo == billNo
                                    && (i.Status == "0" || (i.Status == "1" && i.Operator == Operator)))
                                .Select(i => new BillDetail()
                                {
                                    BillNo = i.BillNo,
                                    BillType = "4",

                                    DetailID = i.ID,
                                    StorageName = i.Cell.CellName,
                                    StorageRfid = i.Storage.Rfid,
                                    CellRfid = i.Cell.Rfid,
                                    TargetStorageName = "",
                                    TargetStorageRfid = "",

                                    ProductCode = i.ProductCode,
                                    ProductName = i.Product.ProductName,

                                    PieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count),
                                    BarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),
                                    OperatePieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count),
                                    OperateBarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),

                                    OperatorCode = string.Empty,
                                    Operator = i.Operator,
                                    Status = i.Status,
                                })
                                .ToArray();
                            billDetails = billDetails.Concat(checkBillDetails).ToArray();
                            break;
                        default:
                            break;
                        #endregion
                    }
                }
                result.IsSuccess = true;
                result.BillDetails = billDetails.OrderByDescending(i => i.Status)
                    .ThenByDescending(b => b.TargetStorageName).ToArray();
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message = "调用服务器服务查询订单细表失败,详情:" + e.InnerException.Message + "  其他错误" + e.Message;
            }
        }