Example #1
0
        /// <summary>
        /// UpdateInfo
        /// </summary>
        /// <param name="fields"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool UpdateInfo(string fields, long id)
        {
            string     outputFid  = CommonBLL.GetFieldValue(fields, "OUTPUT_FID");
            int        cnt        = new OutputDAL().GetCounts("[STATUS] = " + (int)WmmOrderStatusConstants.Created + " and [FID] = N'" + outputFid + "'");
            OutputInfo outputInfo = new OutputDAL().GetInfo(Guid.Parse(outputFid));

            if (outputInfo == null)
            {
                throw new Exception("MC:0x00000084");///出库单数据错误
            }
            //if (outputInfo.Status == (int)WmmOrderStatusConstants.Completed
            //    || outputInfo.Status == (int)WmmOrderStatusConstants.Closed)
            //    throw new Exception("MC:0x00000412");///出库单状态为已关闭或已完成时不能修改其内容

            //if (outputInfo.Status == (int)WmmOrderStatusConstants.Published)
            //{
            OutputDetailInfo outputDetailInfo = dal.GetInfo(id);
            ///实收数量
            string actualQty = CommonBLL.GetFieldValue(fields, "ACTUAL_QTY");

            if (string.IsNullOrEmpty(actualQty))
            {
                actualQty = "NULL";
            }
            if (Convert.ToInt32(actualQty) > outputDetailInfo.RequiredQty)
            {
                throw new Exception("MC:0x00000424");    ///实收数不能大于需求数
            }
            ///实收箱数
            string actualBoxNum = CommonBLL.GetFieldValue(fields, "ACTUAL_BOX_NUM");

            if (string.IsNullOrEmpty(actualBoxNum))
            {
                actualBoxNum = "NULL";
            }
            ///修改用户
            string loginUser = CommonBLL.GetFieldValue(fields, "MODIFY_USER");

            fields = "[ACTUAL_QTY] = " + actualQty + ",[ACTUAL_BOX_NUM] = " + actualBoxNum + ",[MODIFY_DATE] = GETDATE(),[MODIFY_USER] = N'" + loginUser + "' ";

            //}
            ///出库单是否按供应商类型校验
            string outputOrderValidSupplierTypeFlag = new ConfigDAL().GetValueByCode("OUTPUT_ORDER_VALID_SUPPLIER_TYPE_FLAG");

            if (outputOrderValidSupplierTypeFlag.ToLower() == "true")
            {
                string supplierNum = CommonBLL.GetFieldValue(fields, "SUPPLIER_NUM");
                string partNo      = CommonBLL.GetFieldValue(fields, "PART_NO");
                ///需要校验入库单的供应商是否为储运供应商
                cnt = new SupplierDAL().GetCounts("[SUPPLIER_TYPE] = " + (int)SupplierTypeConstants.LogisticsSupplier + " and [SUPPLIER_NUM] in (select [SUPPLIER_NUM] from [LES].[TT_WMM_OUTPUT] with(nolock) where [FID] = N'" + outputFid + "' and [VALID_FLAG] = 1)");

                ///储运供应商标记
                bool logisticsSupplierFlag = cnt == 0 ? false : true;
                if (logisticsSupplierFlag)
                {
                    cnt = dal.GetCounts("[ID] <> " + id + " and [PART_NO] = N'" + partNo + "' and [SUPPLIER_NUM] = N'" + supplierNum + "' and [OUTPUT_FID] = N'" + outputFid + "'");
                    if (cnt > 0)
                    {
                        throw new Exception("MC:0x00000142");///同一出库单下不能出现相同供应商的物料编码
                    }
                }
                else
                {
                    ///出库单明细与出库单不是同一家供应商
                    cnt = new OutputDAL().GetCounts("([SUPPLIER_NUM] = N'" + supplierNum + "' or len(isnull([SUPPLIER_NUM],'')) = 0) and [FID] = N'" + outputFid + "'");
                    if (cnt == 0)
                    {
                        throw new Exception("MC:0x00000143");///出库单的物料供应商与出库明细的供应商不一致
                    }
                    cnt = dal.GetCounts("[ID] <> " + id + " and [PART_NO] = N'" + partNo + "' and [OUTPUT_FID] = N'" + outputFid + "'");
                    if (cnt > 0)
                    {
                        throw new Exception("MC:0x00000144");///同一出库单下不能出现相同的物料编码
                    }
                }
            }

            using (TransactionScope trans = new TransactionScope())
            {
                if (dal.UpdateInfo(fields, id) == 0)
                {
                    return(false);
                }
                CommonDAL.ExecuteNonQueryBySql("update [LES].[TT_WMM_OUTPUT] "
                                               + "set [SUM_PART_QTY] = (select sum([ACTUAL_QTY]) from [LES].[TT_WMM_OUTPUT_DETAIL] with(nolock) where [OUTPUT_FID] = N'" + outputFid + "' and [VALID_FLAG] = 1)"
                                               + ",[SUM_OF_PRICE] = (select sum([PART_PRICE]) from [LES].[TT_WMM_OUTPUT_DETAIL] with(nolock) where [OUTPUT_FID] = N'" + outputFid + "' and [VALID_FLAG] = 1) "
                                               + "where [FID] = N'" + outputFid + "'");
                trans.Complete();
            }
            return(true);
        }
        /// <summary>
        /// UpdateInfo
        /// </summary>
        /// <param name="fields"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool UpdateInfo(string fields, long id)
        {
            BusinessExpenseInInfo info = dal.GetInfo(id);

            if (info == null)
            {
                throw new Exception("MC:0x00000084");///数据错误
            }
            if (info.PaymentFlag.GetValueOrDefault())
            {
                throw new Exception("MC:0x00000459");///已销账不允许进行修改
            }
            ///开票->销账之间
            if (info.CheckFlag.GetValueOrDefault())
            {
                ///实收金额
                string actualAmount = CommonBLL.GetFieldValue(fields, "ACTUAL_AMOUNT");
                if (string.IsNullOrEmpty(actualAmount))
                {
                    actualAmount = "NULL";
                }
                ///财务凭证号
                string fiDocNo = CommonBLL.GetFieldValue(fields, "FI_DOC_NO");
                if (string.IsNullOrEmpty(fiDocNo))
                {
                    fiDocNo = string.Empty;
                }
                ///
                string loginUser = CommonBLL.GetFieldValue(fields, "MODIFY_USER");
                return(dal.UpdateInfo("" +
                                      "[ACTUAL_AMOUNT] = " + actualAmount + "," +
                                      "[FI_DOC_NO] = N'" + fiDocNo + "'," +
                                      "[MODIFY_DATE] = GETDATE()," +
                                      "[MODIFY_USER] = N'" + loginUser + "'", id) > 0 ? true : false);
            }
            ///审核->开票之间
            if (info.ApprovalFlag.GetValueOrDefault())
            {
                ///实收金额
                string actualAmount = CommonBLL.GetFieldValue(fields, "ACTUAL_AMOUNT");
                if (string.IsNullOrEmpty(actualAmount))
                {
                    actualAmount = "NULL";
                }
                ///财务凭证号
                string fiDocNo = CommonBLL.GetFieldValue(fields, "FI_DOC_NO");
                if (string.IsNullOrEmpty(fiDocNo))
                {
                    fiDocNo = string.Empty;
                }
                ///发票号
                string invoiceNo = CommonBLL.GetFieldValue(fields, "INVOICE_NO");
                if (string.IsNullOrEmpty(invoiceNo))
                {
                    invoiceNo = string.Empty;
                }
                ///开票抬头
                string invoiceTitle = CommonBLL.GetFieldValue(fields, "INVOICE_TITLE");
                if (string.IsNullOrEmpty(invoiceTitle))
                {
                    invoiceTitle = string.Empty;
                }
                ///
                string loginUser = CommonBLL.GetFieldValue(fields, "MODIFY_USER");
                return(dal.UpdateInfo("" +
                                      "[ACTUAL_AMOUNT] = " + actualAmount + "," +
                                      "[FI_DOC_NO] = N'" + fiDocNo + "'," +
                                      "[INVOICE_NO] = N'" + invoiceNo + "'," +
                                      "[INVOICE_TITLE] = N'" + invoiceTitle + "'," +
                                      "[MODIFY_DATE] = GETDATE()," +
                                      "[MODIFY_USER] = N'" + loginUser + "'", id) > 0 ? true : false);
            }
            return(dal.UpdateInfo(fields, id) > 0 ? true : false);
        }
Example #3
0
        /// <summary>
        /// 入库免检物料重新校验检验模式
        /// </summary>
        /// <param name="receiveInfo"></param>
        /// <param name="receiveDetailInfos"></param>
        /// <param name="loginUser"></param>
        /// <param name="inspectionFlag"></param>
        /// <returns></returns>
        public static string ReloadInspectionMode(ReceiveInfo receiveInfo, ref List <ReceiveDetailInfo> receiveDetailInfos, string loginUser)
        {
            ///是否启用质量系统接口
            string enableQmisFlag = new ConfigDAL().GetValueByCode("ENABLE_QMIS_FLAG");
            ///获取所有涉及的检验模式,只获取单据中免检物料
            List <PartInspectionModeInfo> partInspectionModeInfos = new PartInspectionModeDAL().GetList("" +
                                                                                                        "[PART_NO] in ('" + string.Join("','", receiveDetailInfos.Where(d => d.InspectionMode.GetValueOrDefault() == (int)InspectionModeConstants.ExemptionInspection).Select(d => d.PartNo).ToArray()) + "') and " +
                                                                                                        "[SUPPLIER_NUM] in ('" + string.Join("','", receiveDetailInfos.Select(d => d.SupplierNum).ToArray()) + "')",
                                                                                                        string.Empty);
            ///LOG_FID
            Guid          logFid  = Guid.NewGuid();
            StringBuilder @string = new StringBuilder();

            foreach (ReceiveDetailInfo receiveDetailInfo in receiveDetailInfos)
            {
                PartInspectionModeInfo partInspectionModeInfo = partInspectionModeInfos.FirstOrDefault(d => d.PartNo == receiveDetailInfo.PartNo && d.SupplierNum == receiveDetailInfo.SupplierNum);
                ///没有检验模式时如何处理,按照批检处理,TODO:增加系统配置
                if (partInspectionModeInfo == null)
                {
                    partInspectionModeInfo = new PartInspectionModeInfo();
                    partInspectionModeInfo.InspectionMode = (int)InspectionModeConstants.BatchInspection;
                }
                ///检验模式无变化时,不产生检验任务
                if (partInspectionModeInfo.InspectionMode == receiveDetailInfo.InspectionMode)
                {
                    continue;
                }
                ///将当前检验模式写入入库单明细
                receiveDetailInfo.InspectionMode = partInspectionModeInfo.InspectionMode;
                ///TODO:可以加入LES质量检验模块数据内容生成逻辑
                ///是否启用质量系统接口
                if (enableQmisFlag.ToLower() != "true")
                {
                    continue;
                }
                ///QMIS检验模式
                int qmisCheckMode = 0;
                switch (partInspectionModeInfo.InspectionMode.GetValueOrDefault())
                {
                case (int)InspectionModeConstants.SamplingInspection: qmisCheckMode = (int)QmisInspectionModeConstants.Sampling; break;

                case (int)InspectionModeConstants.BatchInspection: qmisCheckMode = (int)QmisInspectionModeConstants.Batch; break;

                default: continue;
                }
                ///
                QmisAsnPullSheetInfo qmisAsnPullSheetInfo = QmisAsnPullSheetBLL.CreateQmisAsnPullSheetInfo(loginUser);
                ///
                QmisAsnPullSheetBLL.GetQmisAsnPullSheetInfo(receiveDetailInfo, ref qmisAsnPullSheetInfo);
                ///LOG_FID,日志外键
                qmisAsnPullSheetInfo.LogFid = logFid;
                ///CHECK_MODE,检验模式
                qmisAsnPullSheetInfo.CheckMode = qmisCheckMode.ToString();
                ///TOTAL_NO,送检数量,TODO:送检数量即为实收数量?
                qmisAsnPullSheetInfo.TotalNo = Convert.ToInt32(receiveDetailInfo.ActualQty.GetValueOrDefault());
                ///
                @string.AppendLine(QmisAsnPullSheetDAL.GetInsertSql(qmisAsnPullSheetInfo));
            }
            if (@string.Length > 0)
            {
                @string.AppendLine(CommonBLL.GetCreateOutboundLogSql("QMIS", logFid, "LES-QMIS-002", receiveInfo.ReceiveNo, loginUser));
            }
            return(@string.ToString());
        }
Example #4
0
        public bool UpdateInfo(string fields, long id)
        {
            PackageInvnoticeOrderInfo inventoryNoticeOrderInfo = new PackageInvnoticeOrderDAL().GetList("[FID] = N'" + CommonBLL.GetFieldValue(fields, "ORDER_FID") + "'", string.Empty).FirstOrDefault();

            if (inventoryNoticeOrderInfo.Status != (int)InventoryOrderStatusConstants.PUBLISHED)
            {
                throw new Exception("MC:0x00000372");///状态为20.已发布的盘点单只允许修改物料的物料盘点数量以及备注,此时的修改同时计算出两个差异值
            }
            string partQty = CommonBLL.GetFieldValue(fields, "PART_QTY");
            bool   regular = Regex.IsMatch(partQty, @"^(^-?|^\+?|\d)\d+$");

            if (regular == false)
            {
                regular = Regex.IsMatch(partQty, @"^(^-?|^\+?|^\d?)\d*\.\d+$");
                if (regular == false)
                {
                    throw new Exception("MC:0x00000381");///物料盘点数量的数据格式不正确,请输入数字格式
                }
            }
            PCMInventoryOrderPartInfo inventory = dal.GetInfo(id);

            if (inventory == null)
            {
                throw new Exception("MC:0x00000084");///数据错误
            }
            int differenceQty = Convert.ToInt32(partQty) - Convert.ToInt32(inventory.ReferenceQty);

            fields += ",[DIFFERENCE_QTY] = N'" + differenceQty + "'";
            return(dal.UpdateInfo(fields, id) > 0 ? true : false);
        }
        /// <summary>
        /// UpdateInfo
        /// </summary>
        /// <param name="fields"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool UpdateInfo(string fields, long id)
        {
            TwdPartBoxInfo info = dal.GetInfo(id);

            if (info == null)
            {
                throw new Exception("MC:0x00000084");///数据错误
            }
            string partBoxName = CommonBLL.GetFieldValue(fields, "PART_BOX_NAME");

            info.PartBoxName = partBoxName;

            string sZoneNo     = CommonBLL.GetFieldValue(fields, "S_ZONE_NO");
            string tZoneNo     = CommonBLL.GetFieldValue(fields, "T_ZONE_NO");
            string prevSZoneNo = info.SZoneNo;
            string prevTZoneNo = info.TZoneNo;

            info.SZoneNo = sZoneNo;
            info.TZoneNo = tZoneNo;

            string requirement_accumulate_time = CommonBLL.GetFieldValue(fields, "REQUIREMENT_ACCUMULATE_TIME");

            int.TryParse(requirement_accumulate_time, out int requirementAccumulateTime);
            info.RequirementAccumulateTime = requirementAccumulateTime;

            string load_time = CommonBLL.GetFieldValue(fields, "LOAD_TIME");

            int.TryParse(load_time, out int loadTime);
            info.LoadTime = loadTime;

            string transport_time = CommonBLL.GetFieldValue(fields, "TRANSPORT_TIME");

            int.TryParse(transport_time, out int transportTime);
            info.TransportTime = transportTime;

            string unload_time = CommonBLL.GetFieldValue(fields, "UNLOAD_TIME");

            int.TryParse(unload_time, out int unloadTime);
            info.UnloadTime = unloadTime;

            string delay_time = CommonBLL.GetFieldValue(fields, "DELAY_TIME");

            int.TryParse(delay_time, out int delayTime);
            info.DelayTime = delayTime;

            string online_time = CommonBLL.GetFieldValue(fields, "ONLINE_TIME");

            int.TryParse(online_time, out int onlineTime);
            info.OnlineTime = onlineTime;

            string requirement_accumulate_mode = CommonBLL.GetFieldValue(fields, "REQUIREMENT_ACCUMULATE_MODE");

            int.TryParse(requirement_accumulate_mode, out int requirementAccumulateMode);
            info.RequirementAccumulateMode = requirementAccumulateMode;
            string status_point_code = CommonBLL.GetFieldValue(fields, "STATUS_POINT_CODE");

            info.StatusPointCode = status_point_code;

            string twd_pull_mode = CommonBLL.GetFieldValue(fields, "TWD_PULL_MODE");

            int.TryParse(twd_pull_mode, out int twdPullMode);
            int prevTwdPullMode = info.TwdPullMode.GetValueOrDefault();

            info.TwdPullMode = twdPullMode;

            string roundness_mode = CommonBLL.GetFieldValue(fields, "ROUNDNESS_MODE");

            int.TryParse(roundness_mode, out int roundnessMode);
            info.RoundnessMode = roundnessMode;

            ValidTwdPartBoxInfo(info);
            ///校验通过后将拉动模式\地点回复
            info.TwdPullMode = prevTwdPullMode;
            info.SZoneNo     = prevSZoneNo;
            info.TZoneNo     = prevTZoneNo;

            if (info.Status.GetValueOrDefault() == (int)BasicDataStatusConstants.Disabled)
            {
                throw new Exception("MC:0x00000422");///已作废状态的零件类不能修改
            }
            string loginUser = CommonBLL.GetFieldValue(fields, "MODIFY_USER");

            info.ModifyUser = loginUser;
            info.ModifyDate = DateTime.Now;
            ///已发布状态的零件类只能更新部分信息
            if (info.Status.GetValueOrDefault() == (int)BasicDataStatusConstants.Enable)
            {
                return(dal.Update(info) > 0 ? true : false);
            }

            StringBuilder @string = new StringBuilder();

            ///是否更新了拉动模式,需要同步更新物料拉动信息中的拉动模式
            if (info.TwdPullMode.GetValueOrDefault() != twdPullMode)
            {
                @string.AppendLine("update [LES].[TM_BAS_MAINTAIN_INHOUSE_LOGISTIC_STANDARD] " +
                                   "set [INHOUSE_SYSTEM_MODE] = N'" + twdPullMode + "',[MODIFY_USER] = N'" + loginUser + "',[MODIFY_DATE] = GETDATE() " +
                                   "where [INHOUSE_SYSTEM_MODE] = N'" + info.TwdPullMode.GetValueOrDefault() + "' and [INHOUSE_PART_CLASS] = N'" + info.PartBoxCode + "' and [VALID_FLAG] = 1;");
            }
            ///执行
            using (TransactionScope trans = new TransactionScope())
            {
                if (dal.UpdateInfo(fields, id) == 0)
                {
                    return(false);
                }
                if (@string.Length > 0)
                {
                    CommonDAL.ExecuteNonQueryBySql(@string.ToString());
                }
                trans.Complete();
            }
            return(true);
        }