Ejemplo n.º 1
0
        /// <summary>
        /// UpdateInfo
        /// </summary>
        /// <param name="fields">更新字段</param>
        /// <returns></returns>
        public bool UpdateInfo(string fields, long id)
        {
            BomChangeOrderDetailInfo info = dal.GetInfo(id);

            if (info == null)
            {
                throw new Exception("MC:0x00000084");///数据错误
            }
            BomChangeOrderInfo orderInfo = new BomChangeOrderDAL().GetList(" [FID] = N'" + info.OrderFid + "'", string.Empty).FirstOrDefault();

            if (orderInfo == null)
            {
                throw new Exception("MC:0x00000084");///数据错误
            }
            if (orderInfo.Status != (int)BreakPointOrderStatusConstants.Created)
            {
                throw new Exception("MC:0x00000441");///需要校验单据状态⑨为10.已创建
            }
            return(dal.UpdateInfo(fields, id) > 0 ? true : false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更改单
        /// </summary>
        /// <param name="pullOrdersInfo"></param>
        public string TransitionBreakpoint(PullOrdersInfo pullOrdersInfo, string loginUser)
        {
            if (pullOrdersInfo.ChangeFlag == (int)ChangeFlagConstants.Replaced)
            {
                return(string.Empty);
            }
            ///根据生产订单号获取其物料清单,作为后续匹配更改单的源数据
            List <PullOrderBomInfo> pullOrderBomInfos = new PullOrderBomDAL().GetList("and [ORDERFID]='" + pullOrdersInfo.Fid + "'", string.Empty);

            if (pullOrderBomInfos.Count == 0)
            {
                return(string.Empty);
            }
            ///根据生产订单对应的工厂、生产版本(生产线)获取状态为20.已发布且更改类型为20.过渡断点的更改单
            ///TT_BPM_BOM_CHANGE_ORDER 还需要校验过渡开始时间小于等于当前时间
            List <BomChangeOrderInfo> bomChangeOrderInfos = new BomChangeOrderDAL().GetList("" +
                                                                                            " and [PLANT]=N'" + pullOrdersInfo.Werk + "'" +
                                                                                            " and [ASSEMBLY_LINE]=N'" + pullOrdersInfo.AssemblyLine + "' " +
                                                                                            " and [STATUS]=" + (int)BasicDataStatusConstants.Enable + "" +
                                                                                            " and [ORDER_TYPE]=" + (int)BreakPointOrderTypeConstants.TransitionBreakpoint + "" +
                                                                                            " and [TRANSITION_START_TIME] <=GETDATE()", string.Empty);

            if (bomChangeOrderInfos.Count == 0)
            {
                return(string.Empty);
            }
            ///过滤其中旧物料库存数量大于等于旧物料已消耗数量的物料数据
            List <BomChangeOrderDetailInfo> bomChangeOrderDetailInfos = new BomChangeOrderDetailDAL().GetList("" +
                                                                                                              "and [ORDER_FID] in ('" + string.Join("','", bomChangeOrderInfos.Select(d => d.Fid).ToArray()) + "')", string.Empty);

            if (bomChangeOrderDetailInfos.Count == 0)
            {
                return(string.Empty);
            }
            bomChangeOrderDetailInfos = bomChangeOrderDetailInfos.Where(d => d.OldPartStockQty >= d.OldPartConsumedQty).ToList();
            if (bomChangeOrderDetailInfos.Count == 0)
            {
                return(string.Empty);
            }
            ///将物料清单与过渡更改单物料根据新物料号、工位过滤数据
            var replacedParts = (from p in pullOrderBomInfos
                                 join b in bomChangeOrderDetailInfos
                                 on new { PartNo = p.Zcomno, Location = p.Zloc } equals new { PartNo = b.NewPartNo, b.Location }
                                 select new
            {
                p.Id,
                p.SupplierNum,
                b.NewPartNo,
                b.OldPartNo,
                b.NewPartQty,
                b.Location,
                OldPartQty = 1                     //b.OldPartQty TODO:旧物料
            }).ToList();

            ///在更新生产订单物料清单信息(新换旧)
            if (replacedParts.Count == 0)
            {
                return(string.Empty);
            }
            StringBuilder @string = new StringBuilder();

            foreach (var parts in replacedParts)
            {
                @string.AppendFormat("update [LES].[TT_BAS_PULL_ORDER_BOM] set " +
                                     "[ZCOMNO]=N'" + parts.OldPartNo + "'," +
                                     "[ZQTY]=" + parts.OldPartQty + "," +
                                     "[MODIFY_DATE] = GETDATE()," +
                                     "[MODIFY_USER] = N'" + loginUser + "'" +
                                     "where [ID]=" + parts.Id + "");
                ///同时生成物料替换记录
                PorderBomRepleaceRecordInfo porderBomRepleaceRecordInfo = new PorderBomRepleaceRecordInfo();
                ///FID
                porderBomRepleaceRecordInfo.Fid = Guid.NewGuid();
                ///VALID_FLAG
                porderBomRepleaceRecordInfo.ValidFlag = true;
                ///CREATE_DATE
                porderBomRepleaceRecordInfo.CreateDate = DateTime.Now;
                ///CREATE_USER
                porderBomRepleaceRecordInfo.CreateUser = loginUser;
                ///生产订单号
                porderBomRepleaceRecordInfo.OrderNo = pullOrdersInfo.OrderNo;
                ///旧物料号
                porderBomRepleaceRecordInfo.OldPartNo = parts.OldPartNo;
                ///新物料号
                porderBomRepleaceRecordInfo.NewPartNo = parts.NewPartNo;
                ///旧供应商
                porderBomRepleaceRecordInfo.OldSupplierNum = parts.SupplierNum;
                ///新供应商
                porderBomRepleaceRecordInfo.NewSupplierNum = parts.SupplierNum;
                ///旧工位
                porderBomRepleaceRecordInfo.OldLocation = parts.Location;
                ///新工位
                porderBomRepleaceRecordInfo.NewLocation = parts.Location;
                ///旧物料用量
                porderBomRepleaceRecordInfo.OldPartQty = parts.OldPartQty;
                ///新物料用量
                porderBomRepleaceRecordInfo.NewPartQty = parts.NewPartQty;
                ///替换时间
                porderBomRepleaceRecordInfo.RepleaceTime = DateTime.Now;
                ///状态 TODO:暂时没有想好干嘛的
                porderBomRepleaceRecordInfo.Status = 10;
                ///同时生成物料替换记录
                @string.AppendFormat(PorderBomRepleaceRecordDAL.GetInsertSql(porderBomRepleaceRecordInfo));
            }
            if (@string.Length > 0)
            {
                ///在本更改单所有物料替换完成时还需生成一条状态为逆处理的生产订单中间表记录
                SapProductOrderInfo sapProductOrderInfo = SapProductOrderDAL.CreateSapProductOrderInfo(loginUser);
                ///订单号
                sapProductOrderInfo.Aufnr = pullOrdersInfo.OrderNo;
                ///处理状态
                sapProductOrderInfo.ProcessFlag = (int)ProcessFlagConstants.ConverseProgress;
                ///版本号
                sapProductOrderInfo.Verid = pullOrdersInfo.Version.ToString();
                @string.AppendFormat(SapProductOrderDAL.GetInsertSql(sapProductOrderInfo));
            }
            return(@string.ToString());
        }