Example #1
0
        /// <summary>
        /// 有检测废的物品直接生成领料单
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="billInfo">单据信息</param>
        void InsertIntoMaterialRequisition(DepotManagementDataContext ctx, Business_QualityManagement_Isolation billInfo)
        {
            string error  = null;
            string billNo = null;

            ServerModule.IMaterialRequisitionServer serverMaterialBill =
                ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionServer>();

            try
            {
                billNo = _assignBill.AssignNewNo(serverMaterialBill, CE_BillTypeEnum.领料单.ToString());

                var varData = from a in ctx.S_MaterialRequisition
                              where a.Bill_ID == billNo
                              select a;

                S_MaterialRequisition lnqMaterial = null;

                List <string> listPersonnel = UniversalFunction.GetStorageOrStationPrincipal(billInfo.StorageID);

                if (listPersonnel.Contains("0008"))
                {
                    listPersonnel.Remove("0008");
                }

                if (listPersonnel.Contains("0417"))
                {
                    listPersonnel.Remove("0417");
                }

                if (varData.Count() != 0)
                {
                    error = string.Format("自动生成的报废物品领料单单号 {0} 已被占用,请尝试重新进行此操作" +
                                          ",再三出现无法生成可用的单号时与管理员联系", billNo);
                    throw new Exception(error);
                }
                else
                {
                    lnqMaterial = new S_MaterialRequisition();

                    lnqMaterial.Bill_ID             = billNo;
                    lnqMaterial.Bill_Time           = ServerModule.ServerTime.Time;
                    lnqMaterial.AssociatedBillNo    = billInfo.BillNo;
                    lnqMaterial.AssociatedBillType  = "不合格品隔离处置单";
                    lnqMaterial.BillStatus          = "已出库";
                    lnqMaterial.Department          = "ZK03";
                    lnqMaterial.DepartmentDirector  = "";
                    lnqMaterial.DepotManager        = UniversalFunction.GetPersonnelInfo(listPersonnel[0]).姓名;
                    lnqMaterial.FetchCount          = 0;
                    lnqMaterial.FetchType           = "零星领料";
                    lnqMaterial.FillInPersonnel     = UniversalFunction.GetPersonnelInfo(BasicInfo.LoginID).姓名;
                    lnqMaterial.FillInPersonnelCode = BasicInfo.LoginID;
                    lnqMaterial.ProductType         = "";
                    lnqMaterial.PurposeCode         = UniversalFunction.GetPurpose(CE_PickingPurposeProperty.破坏性检测).Code;
                    lnqMaterial.Remark       = "因入库零件进行了破坏性检测,由系统自动生成的破坏件领料单,对应单据号:" + billInfo.BillNo;
                    lnqMaterial.StorageID    = billInfo.StorageID;
                    lnqMaterial.OutDepotDate = ServerTime.Time;

                    if (!serverMaterialBill.AutoCreateBill(ctx, lnqMaterial, out error))
                    {
                        throw new Exception(error);
                    }

                    S_MaterialRequisitionGoods lnqMaterialGoods = new S_MaterialRequisitionGoods();

                    lnqMaterialGoods.Bill_ID      = billNo;
                    lnqMaterialGoods.BasicCount   = 0;
                    lnqMaterialGoods.BatchNo      = billInfo.BatchNo;
                    lnqMaterialGoods.GoodsID      = billInfo.GoodsID;
                    lnqMaterialGoods.ProviderCode = billInfo.Provider;
                    lnqMaterialGoods.RealCount    = Convert.ToDecimal(billInfo.QC_ScraptCount);
                    lnqMaterialGoods.Remark       = "";
                    lnqMaterialGoods.RequestCount = Convert.ToDecimal(billInfo.QC_ScraptCount);
                    lnqMaterialGoods.ShowPosition = 1;

                    ServerModule.IMaterialRequisitionGoodsServer serverMaterialGoods =
                        ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionGoodsServer>();

                    if (!serverMaterialGoods.AutoCreateGoods(ctx, lnqMaterialGoods, out error))
                    {
                        throw new Exception(error);
                    }

                    ctx.SubmitChanges();

                    if (!serverMaterialBill.FinishBill(ctx, lnqMaterial.Bill_ID, "", out error))
                    {
                        throw new Exception(error);
                    }

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                serverMaterialBill.DeleteBill(billNo, out error);
                throw new Exception(ex.Message);
            }
        }
Example #2
0
        void CreateMaterialRequisition(DepotManagementDataContext ctx, Business_WarehouseOutPut_WholeMachineRequisition billInfo,
                                       List <Business_WarehouseOutPut_WholeMachineRequisitionDetail> listDetail,
                                       List <Business_WarehouseOutPut_WholeMachineRequisition_StorageID> listStorage, out List <string> listBillNo)
        {
            listBillNo = null;
            ServerModule.IMaterialRequisitionGoodsServer serviceGoods = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionGoodsServer>();
            ServerModule.IMaterialRequisitionServer      serviceBill  = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionServer>();
            ServerModule.IStoreServer serviceStore = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IStoreServer>();
            IFlowServer serviceFlow = FlowControlService.ServerModuleFactory.GetServerModule <IFlowServer>();

            ServerModule.IMaterialRequisitionPurposeServer servicePurpose = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionPurposeServer>();

            BillNumberControl billControl = new BillNumberControl(CE_BillTypeEnum.领料单, serviceBill);

            List <CommonProcessInfo> listProcessInfo = serviceFlow.GetFlowData(billInfo.BillNo);

            try
            {
                List <GoodsInfo> listGoodsInfo = new List <GoodsInfo>();

                foreach (Business_WarehouseOutPut_WholeMachineRequisitionDetail detail in listDetail)
                {
                    decimal requstCount = detail.GoodsCount;

                    foreach (Business_WarehouseOutPut_WholeMachineRequisition_StorageID storage in listStorage)
                    {
                        if (requstCount == 0)
                        {
                            break;
                        }

                        List <View_S_Stock> lstStock = serviceStore.GetGoodsStoreOnlyForAssembly(detail.GoodsID, storage.StorageID).ToList();

                        foreach (View_S_Stock stock in lstStock)
                        {
                            if (requstCount == 0)
                            {
                                break;
                            }

                            if (stock.库存数量 <= requstCount)
                            {
                                GoodsInfo goodsInfo = new GoodsInfo();

                                goodsInfo.GoodsID    = detail.GoodsID;
                                goodsInfo.BatchNo    = stock.批次号;
                                goodsInfo.Provider   = stock.供货单位;
                                goodsInfo.GoodsCount = stock.库存数量;

                                goodsInfo.ListInfo = new List <string>();

                                goodsInfo.ListInfo.Add(listGoodsInfo.Count.ToString());
                                goodsInfo.ListInfo.Add(storage.StorageID);
                                goodsInfo.ListInfo.Add(stock.库存数量.ToString());

                                listGoodsInfo.Add(goodsInfo);

                                requstCount = requstCount - stock.库存数量;
                            }
                            else
                            {
                                GoodsInfo goodsInfo = new GoodsInfo();

                                goodsInfo.GoodsID    = detail.GoodsID;
                                goodsInfo.BatchNo    = stock.批次号;
                                goodsInfo.Provider   = stock.供货单位;
                                goodsInfo.GoodsCount = requstCount;

                                goodsInfo.ListInfo = new List <string>();

                                goodsInfo.ListInfo.Add(listGoodsInfo.Count.ToString());
                                goodsInfo.ListInfo.Add(storage.StorageID);
                                goodsInfo.ListInfo.Add(detail.GoodsCount.ToString());

                                listGoodsInfo.Add(goodsInfo);

                                requstCount = 0;
                            }
                        }
                    }
                }

                if (listGoodsInfo != null && listGoodsInfo.Count > 0)
                {
                    listBillNo = new List <string>();
                    CommonProcessInfo firstProcess  = new CommonProcessInfo();
                    CommonProcessInfo SecondProcess = new CommonProcessInfo();
                    CommonProcessInfo ThridProcess  = new CommonProcessInfo();

                    var varTemp = from a in listProcessInfo where a.操作节点 == "新建" orderby a.时间 descending select a;

                    if (varTemp.Count() != 0)
                    {
                        firstProcess = varTemp.First();
                    }
                    else
                    {
                        throw new Exception("此单据无【新建】流程");
                    }

                    varTemp = from a in listProcessInfo where a.操作节点 == "审核" orderby a.时间 descending select a;

                    if (varTemp.Count() != 0)
                    {
                        SecondProcess = varTemp.First();
                    }
                    else
                    {
                        throw new Exception("此单据无【审核】流程");
                    }

                    varTemp = from a in listProcessInfo where a.操作节点 == "确认" orderby a.时间 descending select a;

                    if (varTemp.Count() != 0)
                    {
                        ThridProcess = varTemp.First();
                    }

                    foreach (Business_WarehouseOutPut_WholeMachineRequisition_StorageID storage in listStorage)
                    {
                        List <GoodsInfo> listGoodsInfoTemp = (from a in listGoodsInfo
                                                              where a.ListInfo[1].ToString() == storage.StorageID
                                                              orderby Convert.ToInt32(a.ListInfo[0])
                                                              select a).ToList();

                        if (listGoodsInfoTemp.Count > 0)
                        {
                            string error = "";

                            S_MaterialRequisition bill = new S_MaterialRequisition();

                            bill.AssociatedBillNo   = billInfo.BillNo;
                            bill.AssociatedBillType = CE_BillTypeEnum.整台份请领单.ToString();
                            bill.Bill_ID            = billControl.GetNewBillNo(ctx);
                            bill.Bill_Time          = ServerTime.Time;
                            bill.BillStatus         = "等待出库";

                            View_HR_Personnel personnelInfo = UniversalFunction.GetPersonnelInfo(firstProcess.工号);

                            bill.Department          = personnelInfo.部门编码;
                            bill.DepartmentDirector  = SecondProcess.人员;
                            bill.DepotManager        = ThridProcess == new CommonProcessInfo() ? BasicInfo.LoginName : ThridProcess.人员;
                            bill.FetchCount          = (int)billInfo.MachineCount;
                            bill.FetchType           = FetchGoodsType.整台领料.ToString();
                            bill.FillInPersonnel     = firstProcess.人员;
                            bill.FillInPersonnelCode = personnelInfo.工号;
                            bill.ProductType         = billInfo.ProductType;
                            bill.PurposeCode         = servicePurpose.GetBillPurpose(ctx, billInfo.BillTypeDetail).Code;
                            bill.Remark    = billInfo.Remark;
                            bill.StorageID = storage.StorageID;

                            if (!serviceBill.AutoCreateBill(ctx, bill, out error))
                            {
                                throw new Exception(error);
                            }

                            listBillNo.Add(bill.Bill_ID);

                            for (int i = 0; i < listGoodsInfoTemp.Count; i++)
                            {
                                S_MaterialRequisitionGoods goodsInfo = new S_MaterialRequisitionGoods();

                                goodsInfo.BasicCount   = Convert.ToDecimal(listGoodsInfoTemp[i].ListInfo[2]);
                                goodsInfo.BatchNo      = listGoodsInfoTemp[i].BatchNo;
                                goodsInfo.Bill_ID      = bill.Bill_ID;
                                goodsInfo.GoodsID      = listGoodsInfoTemp[i].GoodsID;
                                goodsInfo.ProviderCode = listGoodsInfoTemp[i].Provider;
                                goodsInfo.RealCount    = listGoodsInfoTemp[i].GoodsCount;
                                goodsInfo.Remark       = GetWorkBench_WashFlag(billInfo.ProductType, goodsInfo.GoodsID);
                                goodsInfo.RequestCount = listGoodsInfoTemp[i].GoodsCount;

                                IProductOrder serviceProductOrder = ServerModuleFactory.GetServerModule <IProductOrder>();
                                goodsInfo.ShowPosition = 0;
                                //serviceProductOrder.GetPosition(ctx, billInfo.ProductType, goodsInfo.GoodsID);

                                if (!serviceGoods.AutoCreateGoods(ctx, goodsInfo, out error))
                                {
                                    throw new Exception(error);
                                }
                            }
                        }

                        ctx.SubmitChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }