/// <summary> /// 赋值账务信息_出 /// </summary> /// <param name="ctx">数据上下文</param> /// <param name="lnqOutPut">单据信息</param> /// <param name="detail1">明细信息</param> /// <returns>返回账务信息对象</returns> S_FetchGoodsDetailBill AssignDetailInfo_Out(DepotManagementDataContext ctx, Business_WarehouseOutPut_OutPut lnqOutPut, View_Business_WarehouseOutPut_OutPutDetail detail1) { ServerModule.IStoreServer storeService = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IStoreServer>(); IFlowServer serverFlow = FlowControlService.ServerModuleFactory.GetServerModule <IFlowServer>(); CommonProcessInfo processInfo = new CommonProcessInfo(); CE_OutPutBusinessType OutPutType = GlobalObject.GeneralFunction.StringConvertToEnum <CE_OutPutBusinessType>(lnqOutPut.BillType); S_FetchGoodsDetailBill fetchDetail = new S_FetchGoodsDetailBill(); fetchDetail.AssociatedBillNo = detail1.关联业务; fetchDetail.AssociatedBillType = CE_BillTypeEnum.入库申请单.ToString(); fetchDetail.BatchNo = detail1.批次号; fetchDetail.BillTime = ServerTime.Time; fetchDetail.DepartDirector = ""; fetchDetail.Department = lnqOutPut.ApplyingDepartment; fetchDetail.Depot = UniversalFunction.GetGoodsInfo(detail1.物品ID).物品类别名称; fetchDetail.Price = 0; //Math.Round(detail1.单价 * detail1.数量, 2); fetchDetail.UnitPrice = 0; //detail1.单价; processInfo = serverFlow.GetFlowData(detail1.关联业务).First(); fetchDetail.FillInDate = Convert.ToDateTime(processInfo.时间); fetchDetail.FillInPersonnel = processInfo.人员; fetchDetail.FetchBIllID = lnqOutPut.BillNo; fetchDetail.FetchCount = detail1.数量; fetchDetail.GoodsID = detail1.物品ID; fetchDetail.OperationType = (int)GlobalObject.EnumOperation.OutPutBusinessTypeConvertToSubsidiaryOperationType(OutPutType); fetchDetail.Provider = detail1.供应商; fetchDetail.Remark = detail1.备注; fetchDetail.StorageID = lnqOutPut.StorageID; DataTable stockTable = storeService.GetGoodsStockInfo(fetchDetail.GoodsID, fetchDetail.BatchNo, fetchDetail.Provider, fetchDetail.StorageID); if (stockTable != null && stockTable.Rows.Count > 0) { fetchDetail.ProviderBatchNo = stockTable.Rows[0]["ProviderBatchNo"].ToString(); } else { fetchDetail.ProviderBatchNo = ""; } fetchDetail.Using = lnqOutPut.BillTypeDetail; return(fetchDetail); }
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); } }