Exemple #1
0
        /// <summary>
        /// InsertInfo
        /// </summary>
        /// <param name="info">对象</param>
        /// <returns></returns>
        public long InsertInfo(BomRepleaceConditionVehicleInfo info)
        {
            BomRepleaceConditionInfo conditionInfo = new BomRepleaceConditionDAL().GetList(" [FID] = N'" + info.ConditionFid + "'", string.Empty).FirstOrDefault();

            if (conditionInfo == null)
            {
                throw new Exception("MC:0x00000084");///数据错误
            }
            if (conditionInfo.Status != (int)BreakPointOrderStatusConstants.Created)
            {
                throw new Exception("MC:0x00000488");///已创建状态才可进行物料添加
            }
            return(dal.Add(info));
        }
Exemple #2
0
        /// <summary>
        /// UpdateInfo
        /// </summary>
        /// <param name="fields">更新字段</param>
        /// <returns></returns>
        public bool UpdateInfo(string fields, long id)
        {
            BomRepleaceConditionVehicleInfo vehicleInfo = dal.GetInfo(id);

            if (vehicleInfo == null)
            {
                throw new Exception("MC:0x00000084");///数据错误
            }
            BomRepleaceConditionInfo conditionInfo = new BomRepleaceConditionDAL().GetList(" [FID] = N'" + vehicleInfo.ConditionFid + "'", string.Empty).FirstOrDefault();

            if (conditionInfo == null)
            {
                throw new Exception("MC:0x00000084");///数据错误
            }
            if (conditionInfo.Status != (int)BreakPointOrderStatusConstants.Created)
            {
                throw new Exception("MC:0x00000084");///已创建状态才可进行修改
            }
            return(dal.UpdateInfo(fields, id) > 0 ? true : false);
        }
Exemple #3
0
        /// <summary>
        /// 替换条件
        /// </summary>
        /// <param name="pullOrdersInfo"></param>
        /// <param name="loginUser"></param>
        /// <returns></returns>
        public string ReplacementCriteria(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);
            }
            ///TT_BPM_BOM_REPLEACE_CONDITION 替换条件信息
            List <BomRepleaceConditionInfo> bomRepleaceConditionInfos = new BomRepleaceConditionDAL().GetList("" +
                                                                                                              " and [STATUS] = " + (int)BasicDataStatusConstants.Enable + "" +
                                                                                                              " and [OLD_PART_NO] in ('" + string.Join("','", pullOrderBomInfos.Select(d => d.Zcomno).ToArray()) + "')" +
                                                                                                              " and GETDATE() between [EXECUTE_START_TIME] and [EXECUTE_END_TIME]", string.Empty);

            if (bomRepleaceConditionInfos.Count == 0)
            {
                return(string.Empty);
            }

            ///车型信息 TT_BPM_BOM_REPLEACE_CONDITION_VEHICLE
            List <BomRepleaceConditionVehicleInfo> bomRepleaceConditionVehicleInfos = new BomRepleaceConditionVehicleBLL().GetList("" +
                                                                                                                                   " and [STATUS] = " + (int)BasicDataStatusConstants.Enable + "" +
                                                                                                                                   " and [CONDITION_FID] in ('" + string.Join("','", bomRepleaceConditionInfos.Select(d => d.Fid).ToArray()) + "')" +
                                                                                                                                   " and [PART_NO]=N'" + pullOrdersInfo.PartNo + "'" +
                                                                                                                                   " and [MODEL_YEAR]=N'" + pullOrdersInfo.ModelYear + "'" +
                                                                                                                                   " and [FARBAU]=N'" + pullOrdersInfo.Farbau + "'" +
                                                                                                                                   " and [PNR_STRING]=N'" + pullOrdersInfo.PnrString + "'" +
                                                                                                                                   " and [ZCOLORI]=N'" + pullOrdersInfo.Zcolori + "'", string.Empty);
            StringBuilder @string = new StringBuilder();

            foreach (BomRepleaceConditionInfo bomRepleaceConditionInfo in bomRepleaceConditionInfos)
            {
                ///物料号
                List <PullOrderBomInfo> pullOrderBoms = pullOrderBomInfos.Where(d => d.Zcomno == bomRepleaceConditionInfo.OldPartNo).ToList();
                if (pullOrderBoms.Count == 0)
                {
                    continue;
                }
                ///工位
                if (!string.IsNullOrEmpty(bomRepleaceConditionInfo.OldLocation))
                {
                    pullOrderBoms = pullOrderBoms.Where(d => d.Zloc == bomRepleaceConditionInfo.OldLocation).ToList();
                }
                ///供应商
                if (!string.IsNullOrEmpty(bomRepleaceConditionInfo.OldSupplierNum))
                {
                    pullOrderBoms = pullOrderBoms.Where(d => d.SupplierNum == bomRepleaceConditionInfo.OldSupplierNum).ToList();
                }
                if (pullOrderBoms.Count == 0)
                {
                    continue;
                }
                ///车型
                BomRepleaceConditionVehicleInfo bomRepleaceConditionVehicleInfo = bomRepleaceConditionVehicleInfos.FirstOrDefault(d => d.ConditionFid == bomRepleaceConditionInfo.Fid);
                foreach (PullOrderBomInfo pullOrderBom in pullOrderBoms)
                {
                    ///更新物料清单
                    @string.AppendFormat("update [LES].[TT_BAS_PULL_ORDER_BOM] set " +
                                         "[ZCOMNO]=N'" + bomRepleaceConditionInfo.NewPartNo + "',");
                    if (bomRepleaceConditionInfo.OldPartQty.GetValueOrDefault() != 0)
                    {
                        @string.AppendFormat("[ZQTY]=" + bomRepleaceConditionInfo.NewPartQty.GetValueOrDefault() + ",");
                    }
                    if (!string.IsNullOrEmpty(bomRepleaceConditionInfo.OldLocation))
                    {
                        @string.AppendFormat("[ZLOC]=N'" + bomRepleaceConditionInfo.NewLocation + "',");
                    }
                    if (!string.IsNullOrEmpty(bomRepleaceConditionInfo.OldSupplierNum))
                    {
                        @string.AppendFormat("[SUPPLIER_NUM]=N'" + bomRepleaceConditionInfo.NewSupplierNum + "',");
                    }
                    @string.AppendFormat("[MODIFY_DATE] = GETDATE()," +
                                         "[MODIFY_USER] = N'" + loginUser + "'" +
                                         "where [ID]=" + pullOrderBom.Id + "");
                    ///旧物料多的情况
                    if (pullOrderBom.Zqty > bomRepleaceConditionInfo.NewPartQty)
                    {
                        PullOrderBomInfo info = new PullOrderBomInfo();
                        ///FID,
                        info.Fid = Guid.NewGuid();
                        ///ORDERFID,订单外键
                        info.Orderfid = pullOrdersInfo.Fid;
                        ///ZORDNO,订单号
                        info.Zordno = pullOrdersInfo.OrderNo;
                        ///ZKWERK,工厂
                        info.Zkwerk = pullOrderBom.Zkwerk;
                        ///ZBOMID,MBOM项目号
                        info.Zbomid = pullOrderBom.Zbomid;
                        ///ZCOMNO,零件号
                        info.Zcomno = bomRepleaceConditionInfo.NewPartNo;
                        ///ZCOMDS,零件描述
                        info.Zcomds = pullOrderBom.Zcomds;
                        ///ZVIN,ZVIN
                        info.Zvin = pullOrderBom.Zvin;
                        ///ZQTY,数量
                        info.Zqty = pullOrderBom.Zqty.GetValueOrDefault() - Convert.ToInt32(bomRepleaceConditionInfo.NewPartQty.GetValueOrDefault());
                        ///ZDATE,计划下线日期
                        info.Zdate = pullOrderBom.Zdate;
                        ///ZLOC,工位
                        info.Zloc = bomRepleaceConditionInfo.OldLocation == null ? pullOrderBom.Zloc : bomRepleaceConditionInfo.NewLocation;
                        ///ZST,操作状态
                        info.Zst = pullOrderBom.Zst;
                        ///ZMEMO,备注
                        info.Zmemo = pullOrderBom.Zmemo;
                        ///ZMEINS,单位
                        info.Zmeins = pullOrderBom.Zmeins;
                        ///SUPPLIER_NUM,供应商
                        info.SupplierNum = bomRepleaceConditionInfo.OldSupplierNum == null ? pullOrderBom.SupplierNum : bomRepleaceConditionInfo.NewSupplierNum;
                        ///PLATFORM,平台
                        info.Platform = pullOrderBom.Platform;
                        ///VALID_FLAG,
                        info.ValidFlag = true;
                        ///CREATE_USER,COMMON_CREATE_USER
                        info.CreateUser = loginUser;
                        ///CREATE_DATE,COMMON_CREATE_DATE
                        info.CreateDate = DateTime.Now;
                        ///MODIFY_USER,COMMON_UPDATE_USER
                        info.ModifyUser = null;
                        ///MODIFY_DATE,COMMON_UPDATE_DATE
                        info.ModifyDate = null;
                        @string.AppendFormat(PullOrderBomDAL.GetInsertSql(info));
                    }
                    ///同时生成物料替换记录
                    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 = bomRepleaceConditionInfo.OldPartNo;
                    ///新物料号
                    porderBomRepleaceRecordInfo.NewPartNo = bomRepleaceConditionInfo.NewPartNo;
                    ///旧供应商
                    porderBomRepleaceRecordInfo.OldSupplierNum = bomRepleaceConditionInfo.OldSupplierNum;
                    ///新供应商
                    porderBomRepleaceRecordInfo.NewSupplierNum = bomRepleaceConditionInfo.NewSupplierNum;
                    ///旧工位
                    porderBomRepleaceRecordInfo.OldLocation = bomRepleaceConditionInfo.OldLocation;
                    ///新工位
                    porderBomRepleaceRecordInfo.NewLocation = bomRepleaceConditionInfo.NewLocation;
                    ///旧物料版本
                    porderBomRepleaceRecordInfo.OldPartVersion = bomRepleaceConditionInfo.OldPartVersion;
                    ///新物料版本
                    porderBomRepleaceRecordInfo.NewPartVersion = bomRepleaceConditionInfo.NewPartVersion;
                    ///旧物料用量
                    porderBomRepleaceRecordInfo.OldPartQty = bomRepleaceConditionInfo.OldPartQty;
                    ///新物料用量
                    porderBomRepleaceRecordInfo.NewPartQty = bomRepleaceConditionInfo.NewPartQty;
                    ///替换时间
                    porderBomRepleaceRecordInfo.RepleaceTime = DateTime.Now;
                    ///状态 TODO:暂时没有想好干嘛的
                    porderBomRepleaceRecordInfo.Status = 10;
                    ///同时生成物料替换记录
                    @string.AppendFormat(PorderBomRepleaceRecordDAL.GetInsertSql(porderBomRepleaceRecordInfo));
                }
                //车型不为空
                if (bomRepleaceConditionVehicleInfo != null && @string.Length > 0)
                {
                    @string.AppendFormat("update [LES].[TT_BPM_BOM_REPLEACE_CONDITION_VEHICLE] set " +
                                         "[REPLEACED_VEHICLE_QTY]=isnull([REPLEACED_VEHICLE_QTY],0)+" + pullOrderBoms.Count + "," +
                                         "[MODIFY_DATE] = GETDATE()," +
                                         "[MODIFY_USER] = N'" + loginUser + "'" +
                                         "where [ID]=" + bomRepleaceConditionVehicleInfo.Id + "");
                }
            }
            if (@string.Length > 0 && bomRepleaceConditionInfos.Where(d => d.NewPartNo != d.OldPartNo || d.OldSupplierNum != d.NewSupplierNum || d.NewPartQty != d.OldPartQty).ToList().Count > 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());
        }