Exemple #1
0
        private void InsertToScan(string employee_no, string picking_department_no, DependencyObjectCollection scanColl)
        {
            DataTable          dtScan        = CreateDtForScanBulk();
            DataTable          dtScanDetail  = CreateDtForScan_DetailBulk();
            IPrimaryKeyService prikeyService = this.GetService <IPrimaryKeyService>("MO_RECEIPT_REQUISTION");

            foreach (DependencyObject scanObj in scanColl)
            {
                DataRow drNew = dtScan.NewRow();
                #region 单头新增
                drNew["ID"]                    = prikeyService.CreateId();
                drNew["employee_no"]           = employee_no;
                drNew["picking_department_no"] = picking_department_no;
                drNew["site_no"]               = scanObj["site_no"];
                drNew["info_lot_no"]           = scanObj["info_lot_no"];
                dtScan.Rows.Add(drNew);
                #endregion
                DependencyObjectCollection detailColl = scanObj["scan_detail"] as DependencyObjectCollection;
                int seqNum = 0;
                List <IGrouping <string, DependencyObject> > groupDColl = detailColl.GroupBy(c => string.Concat(c["doc_no"], c["seq"], c["item_no"], c["item_feature_no"], c["picking_unit_no"], c["warehouse_no"], c["storage_spaces_no"], c["lot_no"])).ToList();//源单+来源序号+品号+特征码+仓库+库位+批号
                foreach (IGrouping <string, DependencyObject> groupD in groupDColl)
                {
                    seqNum++;
                    object id = prikeyService.CreateId();
                    foreach (DependencyObject detailObj in groupD)
                    {
                        DataRow drNewDetail = dtScanDetail.NewRow();
                        #region 单身新增
                        drNewDetail["ID"]                = id;
                        drNewDetail["SequenceNumber"]    = seqNum;
                        drNewDetail["info_lot_no"]       = detailObj["info_lot_no"];
                        drNewDetail["item_no"]           = detailObj["item_no"];
                        drNewDetail["item_feature_no"]   = detailObj["item_feature_no"];
                        drNewDetail["picking_unit_no"]   = detailObj["picking_unit_no"];
                        drNewDetail["doc_no"]            = detailObj["doc_no"];
                        drNewDetail["seq"]               = detailObj["seq"];
                        drNewDetail["warehouse_no"]      = detailObj["warehouse_no"];
                        drNewDetail["storage_spaces_no"] = detailObj["storage_spaces_no"];
                        drNewDetail["lot_no"]            = detailObj["lot_no"];
                        drNewDetail["picking_qty"]       = detailObj["picking_qty"];
                        drNewDetail["barcode_no"]        = detailObj["barcode_no"];
                        dtScanDetail.Rows.Add(drNewDetail);
                        #endregion
                    }
                }
            }
            List <BulkCopyColumnMapping> dtScanMapping = GetBulkCopyColumnMapping(dtScan.Columns);
            _qurService.BulkCopy(dtScan, _Table_scan.Name, dtScanMapping.ToArray());
            dtScanMapping = GetBulkCopyColumnMapping(dtScanDetail.Columns);
            _qurService.BulkCopy(dtScanDetail, _Table_scan_detail.Name, dtScanMapping.ToArray());
        }
        /// <summary>
        /// 根据传入的信息建立送货单
        /// </summary>
        /// <param name="site_no">门店</param>
        /// <param name="delivery_no">送货单号</param>
        /// <param name="create_date">单据日期</param>
        /// <param name="supplier_no">供应商编号</param>
        /// <param name="purchase_type">采购性质</param>
        /// <param name="receipt_address">收货地址</param>
        /// <param name="receipt_no">收货单号</param>
        /// <param name="print_qty">列印次数</param>
        /// <param name="remark">备注</param>
        /// <param name="status">状态</param>
        /// <param name="delivery_detail">单身数据集</param>
        public void InsertFilArrival(string site_no, string delivery_no, string create_date, string supplier_no, string purchase_type, string receipt_address,
                                     string receipt_no, string print_qty, string remark, string status, DependencyObjectCollection delivery_detail)
        {
            try {
                //生成主键服务
                IPrimaryKeyService keyService   = this.GetServiceForThisTypeKey <IPrimaryKeyService>();
                object             filArrivalId = keyService.CreateId();//主键
                //送货单
                DataTable filArrival = FilArrivalNewDt(filArrivalId, site_no, delivery_no, create_date, supplier_no,
                                                       purchase_type, receipt_address, receipt_no, print_qty, remark, status);

                //送货单单身
                DataTable filArrivalD = FilArrivalDNewDt(delivery_detail, site_no, delivery_no, supplier_no, filArrivalId, keyService);

                //获取需要拆入数据表的ColumnMappings
                List <BulkCopyColumnMapping> mapping = GetBulkCopyColumnMapping(filArrival.Columns);
                //获取需要拆入数据表的ColumnMappings
                List <BulkCopyColumnMapping> mappingD = GetBulkCopyColumnMapping(filArrivalD.Columns);

                using (ITransactionService transActionService = GetService <ITransactionService>()) {
                    //插入送货单数据
                    GetService <IQueryService>().BulkCopy(filArrival, filArrival.TableName, mapping.ToArray());
                    //插入送货单单身数据
                    GetService <IQueryService>().BulkCopy(filArrivalD, filArrivalD.TableName, mappingD.ToArray());
                    transActionService.Complete();
                }
            } catch (Exception) {
                throw;
            }
        }
        /// <summary>
        /// 创建送货单单身临时表
        /// </summary>
        /// <returns></returns>
        private DataTable FilArrivalDNewDt(DependencyObjectCollection deliveryDetail, string siteNo, string deliveryNo, string supplierNo, object parentId, IPrimaryKeyService keyService)
        {
            //创建临时表
            DataTable     dataTable = CreateFilArrivalDInfo();
            ILogOnService loginSrv  = GetService <ILogOnService>();

            foreach (DependencyObject item in deliveryDetail)
            {
                //新增行
                DataRow dr = dataTable.NewRow();
                dr["FIL_ARRIVAL_D_ID"] = keyService.CreateId();            //主键
                dr["ParentId"]         = parentId;                         //父主键
                dr["BOOK_CODE"]        = "99";                             //企业编号
                dr["PLANT_CODE"]       = siteNo;                           //门店
                dr["DOC_NO"]           = deliveryNo;                       //发货单号
                dr["SequenceNumber"]   = item["seq"];                      //项次
                dr["COMPANY_CODE"]     = supplierNo;                       //公司代号
                dr["ORDER_NO"]         = item["purchase_no"];              //采购单号
                dr["ORDER_SE"]         = item["purchase_seq"].ToInt32();   //采购单序号
                dr["ORDER_SE_SE"]      = item["line_seq"].ToInt32();       //采购单子序号
                dr["ORDER_SE_SE_SE"]   = item["batch_seq"].ToInt32();      //采购订单子子单身
                dr["ITEM_CODE"]        = item["item_no"];                  //品号
                dr["ITEM_NAME"]        = item["item_name"];                //品名
                dr["ITEM_DESCRIPTION"] = item["item_spec"];                //规格
                dr["WAREHOUSE_CODE"]   = item["warehouse_no"];             //仓库
                dr["UNIT_CODE"]        = item["unit_no"];                  //单位
                dr["PU_QTY"]           = item["purchase_qty"].ToDecimal(); //采购量
                dr["UNARR_QTY"]        = item["unpaid_qty"].ToDecimal();   //未交量
                dr["ACTUAL_QTY"]       = item["qty"].ToDecimal();          //实发量
                dr["RECEIPT_QTY"]      = item["receipt_qty"].ToDecimal();  //收货量
                dr["TAX_INVOICE_NO"]   = string.Empty;                     //发票号
                dr["PACKING_QTY"]      = item["box_qty"].ToDecimal();      //箱装量
                dr["BC_TYPE"]          = item["barcode_type"];             //条码类型

                dr["CHECK_NO"]          = item["qc_type"];
                dr["PRICE_UNIT_CODE"]   = item["valuation_unit_no"];
                dr["PRICE_QTY"]         = item["valuation_qty"];
                dr["RECEIPT_OVER_RATE"] = item["over_deliver_rate"];
                dr["ITEM_FEATURE_CODE"] = item["item_feature_no"];
                dr["STATUS"]            = item["receipt_status"];
                //系统管理字段
                dr["CreateBy"]         = loginSrv.CurrentUserId;
                dr["CreateDate"]       = DateTime.Now;
                dr["ModifiedBy"]       = loginSrv.CurrentUserId;
                dr["ModifiedDate"]     = DateTime.Now;
                dr["LastModifiedBy"]   = loginSrv.CurrentUserId;
                dr["LastModifiedDate"] = DateTime.Now;

                //添加至dataTable中
                dataTable.Rows.Add(dr);
            }
            return(dataTable);
        }
Exemple #4
0
        private List <DependencyObject> InsertCOUNTING(string countingType, string countingNo, DependencyObjectCollection sumColl, DependencyObjectType entityType)
        {
            List <DependencyObject> newList       = new List <DependencyObject>();
            IPrimaryKeyService      prikeyService = this.GetService <IPrimaryKeyService>("COUNTING");
            string countType = string.Empty;

            switch (countingType)
            {
            case "1":
                countingType = "1";
                break;

            case "3":
                countingType = "2";
                break;

            case "4":
                countingType = "3";
                break;

            default:
                break;
            }
            int seqNumberValue = GetMaxSeq(countingNo) + 1;

            foreach (DependencyObject sumObj in sumColl)
            {
                DependencyObject newRecord = new DependencyObject(entityType);
                newRecord["COUNTING_ID"]        = prikeyService.CreateId();
                newRecord["ITEM_ID"]            = sumObj["ITEM_ID"];
                newRecord["ITEM_DESCRIPTION"]   = sumObj["ITEM_DESCRIPTION"];
                newRecord["ITEM_FEATURE_ID"]    = sumObj["ITEM_FEATURE_ID"];
                newRecord["ITEM_SPECIFICATION"] = sumObj["ITEM_SPECIFICATION"];
                newRecord["WAREHOUSE_ID"]       = sumObj["WAREHOUSE_ID"];
                newRecord["BIN_ID"]             = sumObj["BIN_ID"];
                newRecord["ITEM_LOT_ID"]        = sumObj["ITEM_LOT_ID"];
                newRecord["COUNT_TYPE"]         = countingType;
                newRecord["COUNTING_QTY"]       = sumObj["QTY"];
                newRecord["SECOND_QTY"]         = sumObj["SECOND_QTY"];
                newRecord["PLAN_DATE"]          = sumObj["PLAN_DATE"];
                newRecord["COUNTING_DATE"]      = sumObj["complete_date"];
                //20170302 add by shenbao for P001-170302001 ===begin===
                string rtk = sumObj["BO_ID_RTK"].ToStringExtension();
                if (string.IsNullOrEmpty(rtk))
                {
                    rtk = "OTHER";
                }
                //20170302 add by shenbao for P001-170302001  ===end===
                ((DependencyObject)newRecord["BO_ID"])["RTK"]  = rtk; //20170302 modi by shenbao for P001-170302001  sumObj["BO_ID_RTK"]==>rtk
                ((DependencyObject)newRecord["BO_ID"])["ROid"] = sumObj["BO_ID_ROid"];
                newRecord["COMPANY_ID"]       = sumObj["COMPANY_ID"];
                newRecord["COUNTING_PLAN_ID"] = sumObj["COUNTING_PLAN_ID"];
                newRecord["DOC_NO"]           = countingNo;
                newRecord["BUSINESS_UNIT_ID"] = sumObj["STOCK_UNIT_ID"];
                newRecord["BUSINESS_QTY"]     = sumObj["QTY"];
                if (sumObj["SequenceNumber"] == null || sumObj["SequenceNumber"].ToInt32() <= 0)
                {
                    newRecord["SequenceNumber"] = seqNumberValue;
                    seqNumberValue++;
                }
                else
                {
                    newRecord["SequenceNumber"] = sumObj["SequenceNumber"];
                }
                ((DependencyObject)newRecord["Owner_Org"])["RTK"]  = "PLANT";
                ((DependencyObject)newRecord["Owner_Org"])["ROid"] = sumObj["PLANT_ID"];
                newList.Add(newRecord);
            }
            return(newList);
        }
        private string InsertPoArrivalInspection(string receiptNo, DependencyObjectCollection receiptList, List <int> paiSequenceNumber, Dictionary <int, object> docIdDt)
        {
            //获取生成到货检验单基础数据
            DataTable poArrivalInspection = GetInsertPoArrivalInspection(receiptNo, paiSequenceNumber);
            //把查询数据以序号为Key,存入字典中。方便后期直接根据序号拿数据
            Dictionary <int, DataRow> poArrivalDictionary = new Dictionary <int, DataRow>();

            foreach (DataRow item in poArrivalInspection.Rows)
            {
                if (!poArrivalDictionary.ContainsKey(item["SequenceNumber"].ToInt32()))
                {
                    poArrivalDictionary.Add(item["SequenceNumber"].ToInt32(), item);
                }
            }
            //创建生成采购到货检验单缓存临时表
            DataTable poArrivalInspectionInfo = poArrivalInspection.Clone(); //复制表结构

            poArrivalInspectionInfo.TableName = "PO_ARRIVAL_INSPECTION";
            //创建生成采购到货检验单计数单身缓存临时表
            DataTable poArrivalInspectionDInfo = CreatePoArrivalInspectionDInfo();
            //创建生成采购到货检验单计量单身缓存临时表
            DataTable poArrivalInspectionD1Info = CreatePoArrivalInspectionD1Info();
            //创建计数品质检验不良原因缓存临时表
            DataTable defectiveReasonsAiId = CreateDefectiveReasonsAiIdInfo();

            IPrimaryKeyService             keyService              = GetService <IPrimaryKeyService>(TypeKey);                                                     //生成主键服务
            IDocumentNumberGenerateService docNumService           = GetService <IDocumentNumberGenerateService>("PO_ARRIVAL_INSPECTION");                         //自动编号服务
            ICreateInspectionService       createInspectionService = GetService <ICreateInspectionService>("PO_ARRIVAL_INSPECTION");                               //顺序检查服务
            IGenerateOrDeletePurchaseArivalQCResultService generatePurchaseArivalQc = GetService <IGenerateOrDeletePurchaseArivalQCResultService>("PO_QC_RESULT"); //生成/删除采购质检业务信息服务

            IItemQtyConversionService   itemQtyConversionService = GetService <IItemQtyConversionService>(TypeKey);
            ILogOnService               loginService             = GetService <ILogOnService>();
            List <DocmentInfo>          listDocuments            = new List <DocmentInfo>();
            Dictionary <string, string> salesReturnDocNo         = new Dictionary <string, string>(); //记录产生的单号用于批量生成的时候防止重复单号
            const decimal               defaultDecimal           = 0m;
            string resutQcNo = string.Empty;                                                          //返回结果单号

            //循环入参数据,分别给到货检验单、货检验单计数单身、货检验单计量单身身临时表插入数据
            foreach (DependencyObject receiptListItem in receiptList)
            {
                object poArrivalInspectionId = keyService.CreateId(); //主键
                if (poArrivalDictionary.ContainsKey(receiptListItem["seq"].ToInt32()))
                {
                    #region 到货检验单临时表插入数据
                    //获取生单基础数据
                    DataRow dr = poArrivalDictionary[receiptListItem["seq"].ToInt32()];

                    //获取单据性质
                    object docId = Maths.GuidDefaultValue();
                    if (docIdDt.ContainsKey(dr["SequenceNumber"].ToInt32()))
                    {
                        docId = docIdDt[dr["SequenceNumber"].ToInt32()];
                    }
                    if (dr["PURCHASE_TYPE"].ToStringExtension() == "1" || dr["PURCHASE_TYPE"].ToStringExtension() == "5")
                    {
                        dr["CATEGORY"] = "Q1";
                    }
                    else if (dr["PURCHASE_TYPE"].ToStringExtension() == "2" || dr["PURCHASE_TYPE"].ToStringExtension() == "3")
                    {
                        dr["CATEGORY"] = "Q2";
                    }

                    //计算列赋值
                    dr["PO_ARRIVAL_INSPECTION_ID"] = poArrivalInspectionId;                         //主键
                    dr["DOC_ID"]   = docId;                                                         //单据类型
                    dr["DOC_DATE"] = DateTime.Now.Date;                                             //单据日期

                    dr["DOC_NO"] = docNumService.NextNumber(dr["DOC_ID"], dr["DOC_DATE"].ToDate()); //单号
                    if (!salesReturnDocNo.ContainsKey(dr["DOC_NO"].ToString()))
                    {
                        salesReturnDocNo.Add(dr["DOC_NO"].ToString(), dr["DOC_NO"].ToString());
                    }
                    else
                    {
                        string oldDocNo = salesReturnDocNo[dr["DOC_NO"].ToString()]; //取得字典中存储的最大单号
                        string docNo    = NewDocNo(oldDocNo);                        //产生新单号
                        salesReturnDocNo[dr["DOC_NO"].ToString()] = docNo;           //更新字段中单号
                        dr["DOC_NO"] = docNo;                                        //当前笔单号重新赋值
                    }

                    object[] createInspection = createInspectionService.GetInspectionId(dr["ITEM_ID"],
                                                                                        dr["Owner_Org_ROid"],
                                                                                        dr["ITEM_FEATURE_ID"], dr["OPERATION_ID"]);
                    if (!Maths.IsEmpty(createInspection))
                    {
                        dr["INSPECTION_PLAN_ID"] = createInspection[0]; //质检方案ID
                        dr["INSPECTION_TIMES"]   = createInspection[1]; //最大抽样次数
                    }

                    dr["INSPECTION_QTY"]      = receiptListItem["receipt_qty"];                                                                                      //送检数量
                    dr["INSPECTION_DUE_DATE"] = Maths.AddTimeValue(dr["ARRIVAL_DATE"].ToDate(), 1,
                                                                   dr["INSPECT_DAYS"].ToInt32());                                                                    //检验期限
                    dr["INVENTORY_QTY"] = itemQtyConversionService.GetConvertedQty(dr["ITEM_ID"],
                                                                                   dr["INSPECTION_UNIT_ID"], dr["INSPECTION_QTY"].ToDecimal(), dr["STOCK_UNIT_ID"]); //库存单位数量
                    dr["SECOND_QTY"] = itemQtyConversionService.GetConvertedQty(dr["ITEM_ID"], dr["INSPECTION_UNIT_ID"],
                                                                                dr["INSPECTION_QTY"].ToDecimal(), dr["SECOND_UNIT_ID"]);                             //库存单位数量
                    dr["ACCEPTABLE_QTY"]  = receiptListItem["ok_qty"];                                                                                               //送检数量
                    dr["UNQUALIFIED_QTY"] = receiptListItem["unqualified_qty"];                                                                                      //不合格数量
                    dr["DESTROYED_QTY"]   = receiptListItem["checkdestroy_qty"];                                                                                     //破坏数量
                    //判定结果
                    if (receiptListItem["result_type"].ToStringExtension() == "Y")
                    {
                        dr["DECISION"] = "1";
                    }
                    else
                    {
                        dr["DECISION"] = "2";
                    }

                    //后道工序
                    if (!Maths.IsEmpty(dr["MO_ROUTING_D_ID"]))
                    {
                        DependencyObject moRouting = GetMoRouting(dr["MO_ROUTING_D_ID"]);
                        dr["TO_MO_ROUTING_D_ID"] = moRouting["MO_ROUTING_D_ID"];
                        dr["TO_OPERATION_ID"]    = moRouting["OPERATION_ID"];
                    }

                    dr["Owner_Emp"]  = GetEmployeeInfo(loginService.CurrentUserId);
                    dr["Owner_Dept"] = GetAdminUnitInfo(dr["Owner_Emp"]);
                    //系统管理字段
                    AddManagementData(dr, loginService);
                    poArrivalInspectionInfo.Rows.Add(dr.ItemArray);

                    #endregion

                    #region 到货检验单计数单身临时表插入数据

                    DependencyObjectCollection qcList = receiptListItem["qc_list"] as DependencyObjectCollection;
                    if (qcList == null)
                    {
                        continue;                 //不存在qc_list集合数据跳出循环
                    }
                    foreach (var qcListItem in qcList)
                    {
                        if (qcListItem["qc_seq"].ToInt32() == 0)
                        {
                            continue;                                     //序号为0的数据是默认数据只是为了json结构完整插入的,虚无插入E10系统
                        }
                        DataRow qcListDr = poArrivalInspectionDInfo.NewRow();
                        qcListDr["PO_ARRIVAL_INSPECTION_D_ID"] = keyService.CreateId(); //主键
                        qcListDr["ParentId"]           = poArrivalInspectionId;         //父主键
                        qcListDr["SEQUENCE"]           = qcListItem["qc_seq"];
                        qcListDr["DEFECT_CLASS"]       = qcListItem["defect_level"];
                        qcListDr["INSPECTION_QTY"]     = qcListItem["test_qty"];
                        qcListDr["INSPECTION_QQ"]      = qcListItem["return_qty"];
                        qcListDr["INSPECTION_ITEM_ID"] = GetInspectionItem(qcListItem["test_no"], dr["Owner_Org_ROid"]);
                        qcListDr["INSPECTION_AC"]      = qcListItem["acceptable_qty"];
                        qcListDr["INSPECTION_RE"]      = qcListItem["rejected_qty"];
                        if (receiptListItem["result_type"].ToStringExtension() == "Y")
                        {
                            qcListDr["DECISION"] = true;
                        }
                        else
                        {
                            qcListDr["DECISION"] = false;
                        }
                        qcListDr["IMPACT_RESULT"] = true;
                        qcListDr["REMARK"]        = string.Empty;

                        qcListDr["DEFECTIVE_REASONS_ID"] = Maths.GuidDefaultValue();
                        //系统管理字段
                        AddManagementData(qcListDr, loginService);


                        DependencyObjectCollection reasonlist = qcListItem["reason_list"] as DependencyObjectCollection;
                        if (reasonlist == null)
                        {
                            continue;
                        }
                        //defect_qty为0且reason_no为空的数据是默认数据只是为了json结构完整插入的,不需要插入E10系统
                        if (reasonlist.Count == 1 && (!Maths.IsEmpty(reasonlist[0]["reason_no"]) || reasonlist[0]["defect_qty"].ToInt32() != 0))
                        {
                            qcListDr["DEFECTIVE_REASONS_ID"] = GetDefectiveReasonsId(reasonlist[0]["reason_no"].ToStringExtension());
                        }
                        else
                        {
                            //defect_qty为0且reason_no为空的数据是默认数据只是为了json结构完整插入的,不需要插入E10系统
                            if (!Maths.IsEmpty(reasonlist[0]["reason_no"]) || reasonlist[0]["defect_qty"].ToInt32() != 0)
                            {
                                foreach (DependencyObject reasonlistItem in reasonlist)
                                {
                                    DataRow reasonlistDr = defectiveReasonsAiId.NewRow();
                                    reasonlistDr["DEFECTIVE_REASONS_AI_ID"] = keyService.CreateId();               //主键
                                    reasonlistDr["ParentId"]             = qcListDr["PO_ARRIVAL_INSPECTION_D_ID"]; //父主键
                                    reasonlistDr["DEFECTS"]              = reasonlistItem["defect_qty"];
                                    reasonlistDr["REMARK"]               = string.Empty;
                                    reasonlistDr["DEFECTIVE_REASONS_ID"] =
                                        GetDefectiveReasonsId(reasonlistItem["reason_no"].ToStringExtension());
                                    //系统管理字段
                                    AddManagementData(reasonlistDr, loginService);
                                    defectiveReasonsAiId.Rows.Add(reasonlistDr.ItemArray);

                                    //子单身第一笔时把不良原因主键赋值给单身不良原因
                                    if (reasonlist.IndexOf(reasonlistItem) == 0)
                                    {
                                        qcListDr["DEFECTIVE_REASONS_ID"] = reasonlistDr["DEFECTIVE_REASONS_ID"];
                                    }
                                }
                            }
                        }
                        //把对应数据添加至预生单缓存中
                        poArrivalInspectionDInfo.Rows.Add(qcListDr.ItemArray);
                    }

                    #endregion

                    #region 到货检验单计量单身临时表插入数据

                    DependencyObjectCollection collection =
                        createInspectionService.CreateInspection(dr["INSPECTION_PLAN_ID"], dr["OPERATION_ID"]);
                    foreach (DependencyObject item in collection)
                    {
                        if (item["INSPECTION_TYPE"].Equals("VI")) //collection.检验类型=‘VI’
                        {
                            DataRow itemDr = poArrivalInspectionD1Info.NewRow();
                            itemDr["PO_ARRIVAL_INSPECTION_D1_ID"] = keyService.CreateId();
                            itemDr["ParentId"] = poArrivalInspectionId;
                            itemDr["SEQUENCE"] = item["SEQUENCE"]; //检验顺序
                            DependencyObject inspectionPlantD = GetInspectionPlantD(dr["INSPECTION_PLAN_ID"],
                                                                                    item["INSPECTION_ITEM_ID"]);
                            itemDr["DEFECT_CLASS"]         = inspectionPlantD["DEFECT_CLASS"];
                            itemDr["INSPECTION_QTY"]       = defaultDecimal;
                            itemDr["INSPECTION_QQ"]        = defaultDecimal;
                            itemDr["DECISION"]             = false;
                            itemDr["IMPACT_RESULT"]        = inspectionPlantD["IMPACT_RESULT"];
                            itemDr["REMARK"]               = string.Empty;
                            itemDr["INSPECTION_ITEM_ID"]   = item["INSPECTION_ITEM_ID"]; //检验项目
                            itemDr["DEFECTIVE_REASONS_ID"] = Maths.GuidDefaultValue();
                            itemDr["ACCEPTANCE_CONSTANT"]  = defaultDecimal;
                            itemDr["SS"] = defaultDecimal;
                            itemDr["XX"] = defaultDecimal;
                            //系统管理字段
                            AddManagementData(itemDr, loginService);
                            poArrivalInspectionD1Info.Rows.Add(itemDr.ItemArray);
                        }
                    }

                    #endregion

                    //记录单据信息
                    DocmentInfo docmentInfo = new DocmentInfo();
                    docmentInfo.Id         = dr["PO_ARRIVAL_INSPECTION_ID"];
                    docmentInfo.OwnerOrgId = dr["Owner_Org_ROid"];
                    docmentInfo.DocId      = dr["DOC_ID"];
                    docmentInfo.DocNo      = dr["DOC_NO"].ToStringExtension();
                    listDocuments.Add(docmentInfo);

                    if (Maths.IsEmpty(resutQcNo))
                    {
                        resutQcNo = dr["DOC_NO"].ToStringExtension();
                    }
                    else
                    {
                        resutQcNo += "," + dr["DOC_NO"].ToStringExtension();
                    }
                }
            }
            #region 将数据统一插入数据库中

            using (ITransactionService trans = GetService <ITransactionService>()) {
                IQueryService querySrv = GetService <IQueryService>();
                //生成采购到货检验单
                if (poArrivalInspectionInfo.Rows.Count > 0)
                {
                    poArrivalInspectionInfo.Columns.Remove("SequenceNumber");
                    poArrivalInspectionInfo.Columns.Remove("ARRIVAL_DATE");
                    poArrivalInspectionInfo.Columns.Remove("INSPECT_DAYS");
                    poArrivalInspectionInfo.Columns.Remove("STOCK_UNIT_ID");
                    poArrivalInspectionInfo.Columns.Remove("SECOND_UNIT_ID");
                    poArrivalInspectionInfo.Columns.Remove("PURCHASE_TYPE");
                    BulkCopyAll(poArrivalInspectionInfo, querySrv);
                }
                //生成采购到货检验单计数单身
                if (poArrivalInspectionDInfo.Rows.Count > 0)
                {
                    BulkCopyAll(poArrivalInspectionDInfo, querySrv);
                }
                //生成采购到货检验单计量单身
                if (poArrivalInspectionD1Info.Rows.Count > 0)
                {
                    BulkCopyAll(poArrivalInspectionD1Info, querySrv);
                }
                //生成计数品质检验不良原因
                if (defectiveReasonsAiId.Rows.Count > 0)
                {
                    BulkCopyAll(defectiveReasonsAiId, querySrv);
                }

                //EFNET签核
                var infos = listDocuments.GroupBy(c => new { DOC_ID = c.DocId, OwnerOrgID = c.OwnerOrgId });
                foreach (var item in infos)
                {
                    IEFNETStatusStatusService efnetSrv = GetService <IEFNETStatusStatusService>();
                    efnetSrv.GetFormFlow("PO_ARRIVAL_INSPECTION.I01", item.Key.DOC_ID, item.Key.OwnerOrgID,
                                         item.Select(c => c.Id).ToArray());
                }

                //保存单据
                IReadService readSrv  = GetService <IReadService>("PO_ARRIVAL_INSPECTION");
                object[]     entities = readSrv.Read(listDocuments.Select(c => c.Id).Distinct().ToArray());
                if (entities != null && entities.Length > 0)
                {
                    ISaveService saveSrv = GetService <ISaveService>("PO_ARRIVAL_INSPECTION");
                    saveSrv.Save(entities);
                }

                trans.Complete();
            }

            #endregion
            return(resutQcNo);
        }