Пример #1
0
        /// <summary>
        /// 更新领退料单
        /// </summary>
        /// <param name="employeeNo">扫描人员</param>
        /// <param name="scanType">扫描类型 1.有箱条码 2.无箱条码</param>
        /// <param name="reportDatetime">上传时间</param>
        /// <param name="pickingDepartmentNo">领料部门</param>
        /// <param name="recommendedOperations">建议执行作业</param>
        /// <param name="recommendedFunction">A.新增  S.过帐</param>
        /// <param name="scanDocNo">扫描单号</param>
        /// <param name="collection">接口传入的领料单单身数据集合</param>
        public DependencyObjectCollection UpdateIssueReceipt(string employeeNo, string scanType, DateTime reportDatetime, string pickingDepartmentNo
                                                             , string recommendedOperations, string recommendedFunction, string scanDocNo, DependencyObjectCollection collection)
        {
            DependencyObjectCollection rtnColl = CreateReturnCollection();

            #region 参数检查
            if (Maths.IsEmpty(recommendedOperations))
            {
                throw new BusinessRuleException(EncodeSrv.GetMessage("A111201", new object[] { "recommended_operations" }));
            }
            if (Maths.IsEmpty(recommendedFunction))
            {
                throw new BusinessRuleException(EncodeSrv.GetMessage("A111201", new object[] { "recommended_function" }));
            }
            #endregion

            //创建临时表需要的DataTable和Mapping信息
            DataTable issueReceiptD = null;
            List <BulkCopyColumnMapping> issueReceiptDMap = null;
            this.CreateRelateTable(ref issueReceiptD,
                                   ref issueReceiptDMap);
            List <string> docNos = new List <string>();  //记录单身的单号,保存时需要,可以避免后续再查

            //组织数据BulkCopy需要的DataTable数据
            InsertDataTable(issueReceiptD, collection, docNos);

            #region 更新逻辑
            using (ITransactionService trans = this.GetService <ITransactionService>()) {
                IQueryService querySrv = this.GetService <IQueryService>();

                //新增临时表
                IDataEntityType issueReceiptDTmp = CreateIssueReceiptDTmpTable(querySrv);

                //批量新增到临时表
                querySrv.BulkCopy(issueReceiptD, issueReceiptDTmp.Name, issueReceiptDMap.ToArray());
                if (issueReceiptD.Rows.Count <= 00 || issueReceiptD.Rows.Count <= 0)  //没有数据值不再往下执行
                {
                    return(rtnColl);
                }
                DataRow[] drs = issueReceiptD.Select("BARCODE_NO<>\'\'");

                //利用临时表批量更新相关数据
                //20170905 add by wangyq for P001-170717001  =================begin===================
                if (recommendedOperations == "7-5")
                {
                    UpdateBcCheckStatus(querySrv, issueReceiptDTmp);
                }
                else
                {
                    //20170905 add by wangyq for P001-170717001  =================end===================
                    UpdateIssueReceiptD(querySrv, issueReceiptDTmp);
                }//20170905 add by wangyq for P001-170717001
                if (drs.Length > 0)  //条码不为""的记录大于0时,才执行如下更新,避免多余的性能损失
                {
                    bool bcLintFlag = UtilsClass.IsBCLineManagement(querySrv);
                    if (bcLintFlag)
                    {
                        DeleteBCLine(querySrv, issueReceiptDTmp);  //先删除
                        InsertBCLine(querySrv, issueReceiptDTmp);  //再重新生成
                    }
                }

                //保存
                DependencyObjectCollection ids = GetIssueReceipt(docNos);
                IReadService readSrv           = this.GetService <IReadService>("ISSUE_RECEIPT");
                object[]     entities          = readSrv.Read(ids.Select(c => c["ISSUE_RECEIPT_ID"]).ToArray());
                if (entities != null && entities.Length > 0)
                {
                    ISaveService saveSrv = this.GetService <ISaveService>("ISSUE_RECEIPT");
                    saveSrv.Save(entities);
                }

                //保存时没有自动审核的,需要重新审核
                entities = readSrv.Read(ids.Where(c => !c["AUTO_APPROVE"].ToBoolean()).Select(c => c["ISSUE_RECEIPT_ID"]).ToArray());
                IConfirmService confirmService = this.GetService <IConfirmService>("ISSUE_RECEIPT");
                ILogOnService   logOnSrv       = this.GetService <ILogOnService>();
                foreach (DependencyObject obj in entities)
                {
                    ConfirmContext context = new ConfirmContext(obj.Oid, logOnSrv.CurrentUserId, reportDatetime.ToDate());
                    confirmService.Execute(context);
                }

                trans.Complete();
            }
            #endregion

            #region 组织返回结果

            foreach (string item in docNos)
            {
                DependencyObject obj = rtnColl.AddNew();
                obj["doc_no"] = item;
            }

            #endregion

            return(rtnColl);
        }
        /// <summary>
        /// 更新库存交易单单身
        /// </summary>
        /// <param name="employeeNo">扫描人员</param>
        /// <param name="scanType">扫描类型1.有箱条码 2.无箱条码</param>
        /// <param name="reportDatetime">上传时间</param>
        /// <param name="pickingDepartmentNo">领料部门</param>
        /// <param name="recommendedOperations">建议执行作业</param>
        /// <param name="recommendedFunction">A.新增  S.过帐</param>
        /// <param name="scanDocNo">扫描单号</param>
        /// <param name="collScan">参数集合</param>
        /// <returns>新生成的单号DocNo</returns>
        public DependencyObjectCollection DoUpdateTransactionDoc(string employeeNo, string scanType, DateTime reportDatetime,
                                                                 string pickingDepartmentNo, string recommendedOperations, string recommendedFunction,
                                                                 string scanDocNo, DependencyObjectCollection collScan)
        {
            #region 参数检查
            if (Maths.IsEmpty(recommendedOperations))
            {
                throw new BusinessRuleException(InfoEncodeSrv.GetMessage("A111201", "recommended_operations"));//‘入参【recommended_operations】未传值’
            }
            if (Maths.IsEmpty(recommendedFunction))
            {
                throw new BusinessRuleException(InfoEncodeSrv.GetMessage("A111201", "recommended_function"));//‘入参【recommended_function】未传值’
            }

            #endregion

            #region 准备临时表的列映射与数据
            _collDocNos = CreateReturnCollection();
            List <string> lstDocNos = new List <string>();
            _lstQueryProperties = new List <QueryProperty>();
            //DataTable dtTempScan = null;//临时表Scan的DataTable结构
            DataTable dtTempScanDetail = null;                                             //临时表ScanDetail的DataTable结构
            List <BulkCopyColumnMapping> lstColumnMappingsScanDetail = null;               //临时表ScanDetail的映射列
            CreateTempTableMapping(ref dtTempScanDetail, ref lstColumnMappingsScanDetail); //创建临时表#Table_scan的列映射
            InsertTempTableData(dtTempScanDetail, collScan, lstDocNos);                    //插入DataTable数据
            #endregion

            using (var transService = GetService <ITransactionService>()) {
                using (var myConnectionSr = GetService <IConnectionService>()) {
                    InitParameters();//初始化全局变量

                    #region 7.1更新出入库单实体

                    //创建临时表Scan与ScanDetail
                    CreateTempTableScanDetail();
                    _querySrv.BulkCopy(dtTempScanDetail, _TEMP_SCAN_DETAIL.Name, lstColumnMappingsScanDetail.ToArray()); //批量插入数据到临时表ScanDetail

                    int    decimalPlace = 8;                                                                             //金额小数位数
                    int    carryMode    = 1;                                                                             //金额取位模式
                    object companyId    = Maths.GuidDefaultValue();
                    DependencyObjectCollection collPalnt = QueryPlant();
                    if (collPalnt.Count > 0)
                    {
                        companyId = collPalnt[0]["COMPANY_ID"];

                        //调用系统参数服务 获取 记账本位币
                        object currencyId = _sysParameterSrv.GetValue("FUNCTION_CURRENCY_ID", companyId);

                        //Call 货币单价金额取位服务
                        ICurrencyPrecisionService currencyPrecisionSrv = GetServiceForThisTypeKey <ICurrencyPrecisionService>();
                        object[] arrPrecision = currencyPrecisionSrv.GetPrecision(companyId, currencyId);
                        decimalPlace = arrPrecision[0].ToInt32();
                        carryMode    = arrPrecision[1].ToInt32();
                    }

                    UpdateTransactionDocD(decimalPlace, carryMode); //更新库存交易单单身
                    UpdateTransactionDoc();                         //更新库存交易单单头
                    DependencyObjectCollection collParaFil = QueryParaFil();
                    if (collParaFil.Count > 0 && collParaFil[0]["BC_LINE_MANAGEMENT"].ToBoolean())
                    {
                        DeleteBcLine(); //删除条码交易明细 BC_LINE
                        InsertBcLine(); //插入条码交易明细 BC_LINE
                    }

                    #endregion

                    //7.2审核

                    //保存单据
                    DependencyObjectCollection collTransactionDoc = QueryDoc(lstDocNos);
                    IReadService readSrv  = GetService <IReadService>("TRANSACTION_DOC");
                    object[]     entities = readSrv.Read(collTransactionDoc.Select(c => c["TRANSACTION_DOC_ID"]).ToArray());
                    if (entities != null && entities.Length > 0)
                    {
                        ISaveService saveSrv = GetService <ISaveService>("TRANSACTION_DOC");
                        saveSrv.Save(entities);
                    }

                    //保存时没有自动审核的,需要重新审核

                    entities = readSrv.Read(collTransactionDoc.Where(c => c["AUTO_APPROVE"].ToBoolean() == false).Select(c => c["TRANSACTION_DOC_ID"]).ToArray());
                    IConfirmService confirmService = GetService <IConfirmService>("TRANSACTION_DOC");
                    ILogOnService   logOnSrv       = GetService <ILogOnService>();
                    foreach (DependencyObject obj in entities)
                    {
                        ConfirmContext context = new ConfirmContext(obj.Oid, logOnSrv.CurrentUserId, reportDatetime.ToDate());
                        confirmService.Execute(context);
                    }
                }

                transService.Complete(); //事务提交
            }
            return(_collDocNos);
        }
        public DependencyObjectCollection UpdateSalesIssue(string employeeNo, string scanType, DateTime reportDatetime, string pickingDepartmentNo
                                                           , string recommendedOperations, string recommendedFunction, string scanDocNo, DependencyObjectCollection collection)
        {
            DependencyObjectCollection rtnColl = CreateReturnCollection();

            #region 参数检查
            IInfoEncodeContainer encodeSrv = this.GetService <IInfoEncodeContainer>();
            if (Maths.IsEmpty(recommendedOperations))
            {
                throw new BusinessRuleException(encodeSrv.GetMessage("A111201", new object[] { "recommended_operations" }));
            }
            if (Maths.IsEmpty(recommendedFunction))
            {
                throw new BusinessRuleException(encodeSrv.GetMessage("A111201", new object[] { "recommended_function" }));
            }
            #endregion

            //创建临时表需要的DataTable和Mapping信息
            DataTable dtEntityD = new DataTable();
            List <BulkCopyColumnMapping> entityDMap = new List <BulkCopyColumnMapping>();
            CreateRelateTable(dtEntityD, entityDMap);
            List <string> docNos = new List <string>();  //记录单身的单号,保存时需要,可以避免后续再查

            //组织数据BulkCopy需要的DataTable数据
            InsertDataTable(dtEntityD, collection, docNos);
            if (dtEntityD.Rows.Count <= 0)
            {
                return(rtnColl);
            }

            #region 更新逻辑
            using (ITransactionService trans = this.GetService <ITransactionService>()) {
                using (IConnectionService connService = this.GetService <IConnectionService>()) {
                    IQueryService querySrv = this.GetService <IQueryService>();
                    //新增临时表
                    IDataEntityType dtTemp = CreateDTmpTable(querySrv);

                    //批量新增到临时表
                    querySrv.BulkCopy(dtEntityD, dtTemp.Name, entityDMap.ToArray());
                    //利用临时表批量更新相关数据
                    UpdateSalesIssueD(querySrv, dtTemp);

                    DataRow[] drs = dtEntityD.Select("BARCODE_NO<>\'\'");
                    if (drs.Length > 0)    //条码不为""的记录大于0时,才执行如下更新,避免多余的性能损失
                    {
                        ICreateService createService = this.GetService <ICreateService>("PARA_FIL");
                        if (createService != null)  //PARA_FIL实体存在,服务端可以这么判断
                        {
                            bool bcLintFlag = UtilsClass.IsBCLineManagement(querySrv);
                            if (bcLintFlag)
                            {
                                DeleteBCLine(querySrv, dtTemp);  //先删除
                                InsertBCLine(querySrv, dtTemp);  //再重新生成
                            }
                        }
                    }
                }

                //保存
                DependencyObjectCollection ids = GetSalesIssue(docNos);
                IReadService readSrv           = this.GetService <IReadService>("SALES_ISSUE");
                object[]     entities          = readSrv.Read(ids.Select(c => c["SALES_ISSUE_ID"]).ToArray());
                if (entities != null && entities.Length > 0)
                {
                    ISaveService saveSrv = this.GetService <ISaveService>("SALES_ISSUE");
                    saveSrv.Save(entities);
                }

                //保存时没有自动审核的,需要重新审核
                entities = readSrv.Read(ids.Where(c => !c["AUTO_APPROVE"].ToBoolean()).Select(c => c["SALES_ISSUE_ID"]).ToArray());
                IConfirmService confirmService = this.GetService <IConfirmService>("SALES_ISSUE");
                ILogOnService   logOnSrv       = this.GetService <ILogOnService>();
                foreach (DependencyObject obj in entities)
                {
                    ConfirmContext context = new ConfirmContext(obj.Oid, logOnSrv.CurrentUserId, reportDatetime.ToDate());
                    confirmService.Execute(context);
                }

                trans.Complete();
            }
            #endregion

            #region 组织返回结果

            foreach (string item in docNos)
            {
                DependencyObject obj = rtnColl.AddNew();
                obj["doc_no"] = item;
            }

            #endregion

            return(rtnColl);
        }