Example #1
0
        public SiteContext()
        {
            Auth = new AuthConfig();
            LocalAuth = new LocalAuthConfig();
            Stripe = new StripeConfig();
            Email = new EmailConfig();
            Membership = new MembershipConfig();
            Paging = new PagingConfig();

            ConfigurationBuilder.LoadConfiguration(this);
        }
Example #2
0
        public IEnumerable <SelectListItem> GetLocationNameList()
        {
            IList <Location> lst = new List <Location>();
            PagingConfig     cfg = new PagingConfig()
            {
                IsPaging = false,
                Where    = string.Format("Level='{0}'", Convert.ToInt32(LocationLevel.Room))
            };

            using (LocationServiceClient client = new LocationServiceClient())
            {
                MethodReturnResult <IList <Location> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null)
                {
                    lst = result.Data;
                }
            }
            return(from item in lst
                   select new SelectListItem()
            {
                Text = item.Key,
                Value = item.Key
            });
        }
Example #3
0
        //
        // GET: /FMM/ScheduleDetail/
        public async Task <ActionResult> Index(string scheduleName)
        {
            using (ScheduleServiceClient client = new ScheduleServiceClient())
            {
                MethodReturnResult <Schedule> result = await client.GetAsync(scheduleName ?? string.Empty);

                if (result.Code > 0 || result.Data == null)
                {
                    return(RedirectToAction("Index", "Schedule"));
                }
                ViewBag.Schedule = result.Data;
            }

            using (ScheduleDetailServiceClient client = new ScheduleDetailServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        Where = string.Format(" Key.ScheduleName = '{0}'"
                                              , scheduleName)
                    };
                    MethodReturnResult <IList <ScheduleDetail> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new ScheduleDetailQueryViewModel()
            {
                ScheduleName = scheduleName
            }));
        }
Example #4
0
 private IList <RouteStepParameter> GetParameterList(string routeName, string routeStepName, EnumLotState stateFlag)
 {
     if (stateFlag != EnumLotState.WaitTrackIn && stateFlag != EnumLotState.WaitTrackOut)
     {
         return(null);
     }
     //如果本次请求有获取过参数清单,则直接返回。
     if (ViewBag.ParameterList != null)
     {
         return(ViewBag.ParameterList);
     }
     using (RouteStepParameterServiceClient client = new RouteStepParameterServiceClient())
     {
         PagingConfig cfg = new PagingConfig()
         {
             IsPaging = false,
             OrderBy  = "ParamIndex",
             Where    = string.Format(@"DataFrom='{0}' AND DCType='{1}' AND IsDeleted=0
                                    AND Key.RouteName='{2}'
                                    AND Key.RouteStepName='{3}'"
                                      , Convert.ToInt32(EnumDataFrom.Manual)
                                      , stateFlag == EnumLotState.WaitTrackIn
                                         ? Convert.ToInt32(EnumDataCollectionAction.TrackIn)
                                         : Convert.ToInt32(EnumDataCollectionAction.TrackOut)
                                      , routeName
                                      , routeStepName)
         };
         MethodReturnResult <IList <RouteStepParameter> > result = client.Get(ref cfg);
         if (result.Code <= 0 && result.Data != null)
         {
             ViewBag.ParameterList = result.Data;
             return(result.Data);
         }
     }
     return(null);
 }
Example #5
0
        /// <summary>
        /// 取得排班列表
        /// </summary>
        /// <returns></returns>
        public IEnumerable <SelectListItem> GetSchedulingList()
        {
            using (ShiftServiceClient client = new ShiftServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = ""
                };

                MethodReturnResult <IList <Shift> > result = client.Get(ref cfg);
                if (result.Code <= 0)
                {
                    IEnumerable <SelectListItem> lst = from item in result.Data
                                                       select new SelectListItem()
                    {
                        Text  = item.Key,
                        Value = item.Key
                    };
                    return(lst);
                }
            }
            return(new List <SelectListItem>());
        }
Example #6
0
        //
        // GET: /PPM/WorkOrderRoute/
        public async Task <ActionResult> Index(string orderNumber)
        {
            using (WorkOrderServiceClient client = new WorkOrderServiceClient())
            {
                MethodReturnResult <WorkOrder> result = await client.GetAsync(orderNumber ?? string.Empty);

                if (result.Code > 0 || result.Data == null)
                {
                    return(RedirectToAction("Index", "WorkOrder"));
                }
                ViewBag.WorkOrder = result.Data;
            }

            using (WorkOrderRouteServiceClient client = new WorkOrderRouteServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        Where = string.Format(" Key.OrderNumber = '{0}'"
                                              , orderNumber)
                    };
                    MethodReturnResult <IList <WorkOrderRoute> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new WorkOrderRouteQueryViewModel()
            {
                OrderNumber = orderNumber
            }));
        }
Example #7
0
        //
        //POST: /WIP/LotQuery/GetLotMaterial
        public async Task <ActionResult> GetLotMaterial(string lotNumber)
        {
            using (LotQueryServiceClient client = new LotQueryServiceClient())
            {
                await Task.Run(() =>
                {
                    MethodReturnResult <Lot> result = client.Get(lotNumber);

                    if (result.Code == 0)
                    {
                        ViewBag.Lot = result.Data;
                    }
                });
            }


            using (LotQueryServiceClient client = new LotQueryServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format(@" Key.LotNumber='{0}'"
                                                 , lotNumber),
                        OrderBy = "Key.ItemNo"
                    };
                    MethodReturnResult <IList <LotBOM> > result = client.GetLotBOM(ref cfg);
                    if (result.Code == 0)
                    {
                        ViewBag.MaterialList = result.Data;
                    }
                });
            }
            return(PartialView("_MaterialListPartial"));
        }
Example #8
0
        public List <string> GetCodeAndItemNo(OemData oemData)
        {
            List <string> dic = new List <string>();

            using (WorkOrderPowersetServiceClient client = new WorkOrderPowersetServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    PageNo   = 0,
                    PageSize = 1,
                    Where    = string.Format("PowerName='{0}' AND Key.OrderNumber='{1}'", oemData.PnName, oemData.OrderNumber.ToString().Trim().ToUpper())
                };
                MethodReturnResult <IList <WorkOrderPowerset> > result = client.Get(ref cfg);

                if (result.Code == 0 && result.Data != null & result.Data.Count > 0)
                {
                    dic.Add(result.Data[0].Key.Code);
                    dic.Add(result.Data[0].Key.ItemNo.ToString());
                    //string iii = dic[0];
                    return(dic);
                }
            }
            return(null);
        }
Example #9
0
        public ActionResult GetMaterialLot(string materialLot, string materialCode, string orderNumber, string lineStoreName)
        {
            IList <LineStoreMaterialDetail> lstDetail = new List <LineStoreMaterialDetail>();

            using (LineStoreMaterialServiceClient client = new LineStoreMaterialServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format(@"Key.LineStoreName='{0}'
                                            AND Key.MaterialCode='{1}'
                                            AND Key.OrderNumber='{3}'
                                            AND Key.MaterialLot LIKE '{2}%'
                                            AND CurrentQty>0"
                                             , lineStoreName
                                             , materialCode
                                             , materialLot
                                             , orderNumber),
                    OrderBy = "Key"
                };

                MethodReturnResult <IList <LineStoreMaterialDetail> > result = client.GetDetail(ref cfg);
                if (result.Code <= 0 && result.Data != null)
                {
                    lstDetail = result.Data;
                }
            }

            return(Json(from item in lstDetail
                        select new
            {
                @label = string.Format("{0}[{1}]", item.Key.MaterialLot, item.Key.MaterialCode),
                @value = item.Key.MaterialLot,
                @qty = item.CurrentQty
            }, JsonRequestBehavior.AllowGet));
        }
Example #10
0
        //获取基础数据库位表
        public IEnumerable <SelectListItem> GetStoreLocationList()
        {
            IList <BaseAttributeValue> lstResource = new List <BaseAttributeValue>();

            using (BaseAttributeValueServiceClient client = new BaseAttributeValueServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Key.CategoryName='StoreLocation' AND Key.AttributeName='StoreLocationName'")
                };
                MethodReturnResult <IList <BaseAttributeValue> > lstStoreLocationName = client.Get(ref cfg);
                if (lstStoreLocationName.Data != null && lstStoreLocationName.Data.Count > 0)
                {
                    lstResource = lstStoreLocationName.Data;
                }
            }
            return(from item in lstResource
                   select new SelectListItem()
            {
                Text = item.Value,
                Value = item.Value
            });
        }
Example #11
0
        public IEnumerable <SelectListItem> GetRouteEnterpriseNameList()
        {
            using (RouteEnterpriseServiceClient client = new RouteEnterpriseServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Status='{0}'", Convert.ToInt32(EnumObjectStatus.Available))
                };

                MethodReturnResult <IList <RouteEnterprise> > result = client.Get(ref cfg);
                if (result.Code <= 0)
                {
                    IEnumerable <SelectListItem> lst = from item in result.Data
                                                       select new SelectListItem()
                    {
                        Text  = item.Key,
                        Value = item.Key
                    };
                    return(lst);
                }
            }
            return(new List <SelectListItem>());
        }
Example #12
0
        public IEnumerable <SelectListItem> GetTechnologyList()
        {
            IList <BaseAttributeValue> lstValues = new List <BaseAttributeValue>();

            using (BaseAttributeValueServiceClient client = new BaseAttributeValueServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Key.CategoryName='Technology'"),
                    OrderBy  = "Key.ItemOrder"
                };

                MethodReturnResult <IList <BaseAttributeValue> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null)
                {
                    lstValues = result.Data;
                }
            }

            var lnqValue = from item in lstValues
                           where item.Key.AttributeName == "VALUE"
                           select item;

            var lnqName = from item in lstValues
                          where item.Key.AttributeName == "NAME"
                          select item;

            return(from item in lnqValue
                   join itemName in lnqName on item.Key.ItemOrder equals itemName.Key.ItemOrder
                   select new SelectListItem()
            {
                Text = string.Format("{0}-{1}", item.Value, itemName.Value),
                Value = item.Value
            });
        }
        public ActionResult GetRouteStepNames(string routeName)
        {
            IList <RouteStep> lst = new List <RouteStep>();

            using (RouteStepServiceClient client = new RouteStepServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Key.RouteName='{0}'", routeName),
                    OrderBy  = "SortSeq"
                };
                MethodReturnResult <IList <RouteStep> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null)
                {
                    lst = result.Data;
                }
            }
            return(Json(from item in lst
                        select new {
                Text = item.Key.RouteStepName,
                Value = item.Key.RouteStepName
            }, JsonRequestBehavior.AllowGet));
        }
Example #14
0
        public IEnumerable <SelectListItem> GetGradeList(string lotGrade)
        {
            if (string.IsNullOrEmpty(lotGrade) || lotGrade.Length == 0)
            {
                lotGrade = "A";
            }
            IList <BaseAttributeValue> lstValues = new List <BaseAttributeValue>();

            using (BaseAttributeValueServiceClient client = new BaseAttributeValueServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format(@"Key.CategoryName='Grade' AND Key.AttributeName='VALUE'
                            AND Exists( from BaseAttributeValue as p 
                                        where p.Key.CategoryName='Grade' 
                                           AND p.Key.AttributeName='VALUE' AND p.Value='{0}'
                                        AND self.Key.ItemOrder >= p.Key.ItemOrder
                                   )
                    ", lotGrade),
                    OrderBy  = "Key.ItemOrder"
                };

                MethodReturnResult <IList <BaseAttributeValue> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null)
                {
                    lstValues = result.Data;
                }
            }
            return(from item in lstValues
                   select new SelectListItem()
            {
                Text = item.Value,
                Value = item.Value
            });
        }
Example #15
0
        public IEnumerable <SelectListItem> GetReasonCodeCategoryName(EnumReasonCodeType type)
        {
            using (ReasonCodeCategoryServiceClient client = new ReasonCodeCategoryServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Type='{0}'", Convert.ToInt32(type))
                };

                MethodReturnResult <IList <ReasonCodeCategory> > result = client.Get(ref cfg);
                if (result.Code <= 0)
                {
                    IEnumerable <SelectListItem> lst = from item in result.Data
                                                       select new SelectListItem()
                    {
                        Text  = item.Key,
                        Value = item.Key
                    };
                    return(lst);
                }
            }
            return(new List <SelectListItem>());
        }
        public IEnumerable <SelectListItem> GetParameterNameList()
        {
            using (ParameterServiceClient client = new ParameterServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Type='{0}'", Convert.ToInt32(EnumParameterType.Route))
                };

                MethodReturnResult <IList <Parameter> > result = client.Get(ref cfg);
                if (result.Code <= 0)
                {
                    IEnumerable <SelectListItem> lst = from item in result.Data
                                                       select new SelectListItem()
                    {
                        Text  = item.Key,
                        Value = item.Key
                    };
                    return(lst);
                }
            }
            return(new List <SelectListItem>());
        }
        /// <summary>
        /// 获取生产线列表
        /// </summary>
        /// <returns></returns>
        public IEnumerable <SelectListItem> GetProductionLineList()
        {
            //获取用户拥有权限的生产线。
            IList <Resource> lstResource = new List <Resource>();

            using (UserAuthenticateServiceClient client = new UserAuthenticateServiceClient())
            {
                MethodReturnResult <IList <Resource> > result = client.GetResourceList(HttpContext.Current.User.Identity.Name, ResourceType.ProductionLine);
                if (result.Code <= 0 && result.Data != null)
                {
                    lstResource = result.Data;
                }
            }
            IList <ProductionLine> lst = new List <ProductionLine>();
            PagingConfig           cfg = new PagingConfig()
            {
                IsPaging = false
            };

            using (ProductionLineServiceClient client = new ProductionLineServiceClient())
            {
                MethodReturnResult <IList <ProductionLine> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null)
                {
                    lst = result.Data;
                }
            }

            return(from item in lst
                   where lstResource.Any(m => m.Data.ToUpper() == item.Key.ToUpper())
                   select new SelectListItem()
            {
                Text = string.Format("{0}[{1}]", item.Name, item.Key),
                Value = item.Key
            });
        }
Example #18
0
        public ActionResult GetProductMaterialCode(string q)
        {
            using (MaterialServiceClient client = new MaterialServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Key LIKE '{0}%' AND IsProduct='1' AND Status='1'", q)
                };


                MethodReturnResult <IList <Material> > result = client.Get(ref cfg);
                if (result.Code <= 0)
                {
                    return(Json(from item in result.Data
                                select new
                    {
                        @label = string.Format("{0}[{1}]", item.Key, item.Name),
                        @value = item.Key
                    }, JsonRequestBehavior.AllowGet));;
                }
            }
            return(Json(null, JsonRequestBehavior.AllowGet));;
        }
Example #19
0
        public static async Task <IPagedList <T> > ToPagedListAsync <T>(this IQueryable <T> query, int page, int pageSize)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            var pagingConfig = new PagingConfig(page, pageSize);
            var skipCount    = ValidatePagePropertiesAndGetSkipCount(pagingConfig);

            var data = await query.Skip(skipCount)
                       .Take(pagingConfig.PageSize)
                       .ToListAsync();

            if (skipCount > 0 && data.Count == 0)
            {
                // Requested page has no records, just return the first page
                pagingConfig.Page = 1;
                data = await query.Take(pagingConfig.PageSize)
                       .ToListAsync();
            }

            return(new PagedList <T>(data, pagingConfig.Page, pagingConfig.PageSize, await query.CountAsync()));
        }
Example #20
0
        /// <summary>
        /// 取得车间代码
        /// </summary>
        /// <returns></returns>
        public IEnumerable <SelectListItem> GetLocationName()
        {
            using (LocationServiceClient client = new LocationServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Level='{0}'", Convert.ToInt32(LocationLevel.Room))
                };

                MethodReturnResult <IList <Location> > result = client.Get(ref cfg);
                if (result.Code <= 0)
                {
                    IEnumerable <SelectListItem> lst = from item in result.Data
                                                       select new SelectListItem()
                    {
                        Text  = item.Key,
                        Value = item.Key
                    };
                    return(lst);
                }
            }
            return(new List <SelectListItem>());
        }
Example #21
0
        /// <summary>
        /// 初始化查询列表
        /// </summary>
        /// <returns></returns>
        public async Task <ActionResult> Index()
        {
            using (RouteOperationServiceClient client = new RouteOperationServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        Where = string.Format(" Status = '{0}'"
                                              , EnumObjectStatus.Available.GetHashCode()),
                        OrderBy = "SortSeq"
                    };
                    MethodReturnResult <IList <RouteOperation> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }

            return(View(new RouteOperationQueryViewModel()));
        }
Example #22
0
        //
        // GET: /FMM/RouteOperationEquipment/
        public async Task <ActionResult> Index(string routeOperationName)
        {
            using (RouteOperationServiceClient client = new RouteOperationServiceClient())
            {
                MethodReturnResult <RouteOperation> result = await client.GetAsync(routeOperationName ?? string.Empty);

                if (result.Code > 0 || result.Data == null)
                {
                    return(RedirectToAction("Index", "RouteOperation"));
                }
                ViewBag.RouteOperation = result.Data;
            }

            using (RouteOperationEquipmentServiceClient client = new RouteOperationEquipmentServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        Where = string.Format(" Key.RouteOperationName = '{0}'"
                                              , routeOperationName)
                    };
                    MethodReturnResult <IList <RouteOperationEquipment> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new RouteOperationEquipmentQueryViewModel()
            {
                RouteOperationName = routeOperationName
            }));
        }
        /// <summary>
        /// 取得工步清单
        /// </summary>
        /// <returns></returns>
        public IEnumerable <SelectListItem> GetRouteOperationList()
        {
            //获取用户拥有权限的工序。
            IList <Resource> lstResource = new List <Resource>();

            using (UserAuthenticateServiceClient client = new UserAuthenticateServiceClient())
            {
                MethodReturnResult <IList <Resource> > result = client.GetResourceList(HttpContext.Current.User.Identity.Name, ResourceType.RouteOperation);
                if (result.Code <= 0 && result.Data != null)
                {
                    lstResource = result.Data;
                }
            }

            IList <string> lstPackageOperation = new List <string>();
            PagingConfig   cfg = new PagingConfig()
            {
                IsPaging = false,
                Where    = "Key.AttributeName='IsPackageOperation'"
            };

            using (RouteOperationAttributeServiceClient client = new RouteOperationAttributeServiceClient())
            {
                MethodReturnResult <IList <RouteOperationAttribute> > result = client.Get(ref cfg);

                if (result.Code <= 0 && result.Data != null)
                {
                    bool isPackageOperation = false;
                    lstPackageOperation = (from item in result.Data
                                           where bool.TryParse(item.Value, out isPackageOperation) == true &&
                                           isPackageOperation == true
                                           select item.Key.RouteOperationName).ToList();
                }
            }

            IList <RouteOperation> lst = new List <RouteOperation>();

            cfg.Where   = "Status=1";
            cfg.OrderBy = "SortSeq";

            using (RouteOperationServiceClient client = new RouteOperationServiceClient())
            {
                MethodReturnResult <IList <RouteOperation> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null)
                {
                    lst = result.Data;
                }
            }


            return(from item in lst
                   where lstResource.Any(m => m.Data.ToUpper() == item.Key.ToUpper())
                   select new SelectListItem()
            {
                Text = item.Key,
                Value = item.Key
            });

            //return from item in lst
            //       where lstPackageOperation.Contains(item.Key.ToUpper())==false
            //             && lstResource.Any(m => m.Data.ToUpper() == item.Key.ToUpper())
            //       select new SelectListItem()
            //       {
            //           Text = item.Key,
            //           Value = item.Key
            //       };
        }
Example #24
0
        public ActionResult Delete(string packageNo, int itemNo, string lotNumber)
        {
            MethodReturnResult result = new MethodReturnResult();

            try
            {
                //获取包装记录
                using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                {
                    MethodReturnResult <Package> rst1 = client.Get(packageNo);
                    if (rst1.Code > 0 || rst1.Data == null)
                    {
                        return(Json(rst1));
                    }
                    //判断包装记录目前是否处于包装中状态。
                    if (rst1.Data.PackageState != EnumPackageState.Packaging)
                    {
                        result.Code    = 1001;
                        result.Message = string.Format("包装{0}为非{1}状态,不能删除。"
                                                       , packageNo
                                                       , EnumPackageState.Packaging.GetDisplayName());
                        return(Json(result));
                    }
                }
                //获取最后一笔包装记录。
                IList <string> lstTransactionKey = new List <string>();
                using (LotQueryServiceClient client = new LotQueryServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format("LotNumber='{0}' AND UndoFlag=0"
                                                 , lotNumber)
                    };

                    MethodReturnResult <IList <LotTransaction> > rst1 = client.GetTransaction(ref cfg);
                    if (rst1.Code <= 0 && rst1.Data != null)
                    {
                        var lnq = from item in rst1.Data
                                  orderby item.CreateTime descending
                                  select item;
                        foreach (LotTransaction item in lnq)
                        {
                            lstTransactionKey.Add(item.Key);
                            if (item.Activity == EnumLotActivity.Package)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        return(Json(rst1));
                    }
                }
                //可撤销操作主键不为空。
                if (lstTransactionKey.Count > 0)
                {
                    UndoParameter p = new UndoParameter()
                    {
                        Creator             = User.Identity.Name,
                        LotNumbers          = new List <string>(),
                        OperateComputer     = Request.UserHostAddress,
                        Operator            = User.Identity.Name,
                        UndoTransactionKeys = new Dictionary <string, IList <string> >()
                    };

                    p.LotNumbers.Add(lotNumber);
                    p.UndoTransactionKeys.Add(lotNumber, lstTransactionKey);

                    using (LotUndoServiceClient client = new LotUndoServiceClient())
                    {
                        result = client.Undo(p);
                        if (result.Code == 0)
                        {
                            result.Message = string.Format("删除 ({0}:{1}:{2}) 成功。"
                                                           , packageNo, itemNo, lotNumber);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result.Code    = 1000;
                result.Message = ex.Message;
                result.Detail  = ex.ToString();
            }
            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(Json(result));
        }
Example #25
0
        // GET: /PPM/PlanDay/
        /// <summary>
        /// 页面开始处理事物
        /// </summary>
        /// <param name="year">         年</param>
        /// <param name="month">        月</param>
        /// <param name="locationname"> 车间</param>
        /// <returns></returns>
        public async Task <ActionResult> Index(string year, string month, string locationname)
        {
            MethodReturnResult result = new MethodReturnResult();

            try
            {
                //初始化参数
                string sYear  = System.DateTime.Now.ToString("yyyy");
                string sMonth = System.DateTime.Now.ToString("MM");

                //获取日生产计划。
                using (PlanDayServiceClient client = new PlanDayServiceClient())
                {
                    await Task.Run(() =>
                    {
                        //设置查询条件
                        PagingConfig cfg = new PagingConfig()
                        {
                            IsPaging = false,
                            Where    = string.Format(@" Key.Year = '{0}' 
                                                    AND Key.Month = '{1}'",
                                                     sYear,
                                                     sMonth
                                                     )
                        };

                        //取得列表数据
                        MethodReturnResult <IList <PlanDay> > resultlist = client.Get(ref cfg);

                        if (resultlist.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = resultlist.Data;
                        }
                        else
                        {
                            //数据错误
                            result.Code    = resultlist.Code;       //错误代码
                            result.Message = resultlist.Message;    //错误信息
                            result.Detail  = resultlist.Message;    //错误明细
                        }
                    });

                    //处理错误信息
                    if (result.Code > 0)
                    {
                        return(Json(result));            //终止并返回程序
                    }
                }

                PlanDayQueryViewModel model = new PlanDayQueryViewModel
                {
                    //初始化参数
                    qYear  = sYear,                       //年
                    qMonth = sMonth,                      //月
                };

                return(View(model));
            }
            catch (Exception ex)
            {
                result.Code    = 1000;
                result.Message = ex.Message;
                result.Detail  = ex.ToString();

                return(Json(result));
            }
        }
Example #26
0
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <ActionResult> Query(PlanDayQueryViewModel model)
        {
            MethodReturnResult result = new MethodReturnResult();

            try
            {
                using (PlanDayServiceClient client = new PlanDayServiceClient())
                {
                    //取得数据
                    await Task.Run(() =>
                    {
                        //取数条件
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            //年度条件
                            if (!string.IsNullOrEmpty(model.qYear))
                            {
                                where.AppendFormat(" {0} Key.Year = '{1}'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.qYear);
                            }

                            //月度条件
                            if (!string.IsNullOrEmpty(model.qMonth))
                            {
                                where.AppendFormat(" {0} Key.Month = '{1}'"
                                                   , where.Length > 0 ? "and" : string.Empty
                                                   , model.qMonth);
                            }

                            //车间条件
                            if (!string.IsNullOrEmpty(model.LocationName))
                            {
                                where.AppendFormat(" {0} Key.LocationName = '{1}'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.LocationName);
                            }

                            //产品条件
                            if (!string.IsNullOrEmpty(model.ProductCode))
                            {
                                where.AppendFormat(" {0} Key.ProductCode = '{1}'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.ProductCode);
                            }
                        }

                        //设置参数
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key",
                            Where   = where.ToString()
                        };

                        //取得数据
                        MethodReturnResult <IList <PlanDay> > resultlist = client.Get(ref cfg);

                        if (resultlist.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = resultlist.Data;
                        }
                        else
                        {
                            //数据错误
                            result.Code    = resultlist.Code;       //错误代码
                            result.Message = resultlist.Message;    //错误信息
                            result.Detail  = resultlist.Message;    //错误明细
                        }
                    });

                    //处理错误信息
                    if (result.Code > 0)
                    {
                        return(Json(result));                        //终止并返回程序
                    }
                }

                return(PartialView("_ListPartial"));
            }
            catch (Exception e)
            {
                result.Code    = 1002;
                result.Message = e.Message;
                result.Detail  = e.ToString();

                return(Json(result));
            }
        }
Example #27
0
        public ActionResult Query(ChestMonitorQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                StringBuilder where = new StringBuilder();
                where.AppendFormat(string.Format(@" (ChestState = 0 OR ChestState = 6)"));
                if (model.OrderNumber != null && model.OrderNumber != "")
                {
                    where.AppendFormat(" {0} OrderNumber = '{1}'"
                                       , where.Length > 0 ? "AND" : string.Empty
                                       , model.OrderNumber.Trim().ToUpper());
                }

                if (model.MaterialCode != null && model.MaterialCode != "")
                {
                    where.AppendFormat(" {0} MaterialCode = '{1}'"
                                       , where.Length > 0 ? "AND" : string.Empty
                                       , model.MaterialCode.Trim().ToUpper());
                }

                if (model.PowerName != null && model.PowerName != "")
                {
                    where.AppendFormat(" {0} PowerName LIKE '{1}%'"
                                       , where.Length > 0 ? "AND" : string.Empty
                                       , model.PowerName.Trim().ToUpper());
                }

                if (model.Grade != null && model.Grade != "")
                {
                    where.AppendFormat(" {0} Grade LIKE '{1}%'"
                                       , where.Length > 0 ? "AND" : string.Empty
                                       , model.Grade.Trim().ToUpper());
                }

                if (model.Color != null && model.Color != "")
                {
                    where.AppendFormat(" {0} Color LIKE '{1}%'"
                                       , where.Length > 0 ? "AND" : string.Empty
                                       , model.Color.Trim().ToUpper());
                }

                if (model.PowerSubCode != null && model.PowerSubCode != "")
                {
                    where.AppendFormat(" {0} PowerSubCode = '{1}'"
                                       , where.Length > 0 ? "AND" : string.Empty
                                       , model.PowerSubCode.Trim().ToUpper());
                }
                using (PackageInChestServiceClient client = new PackageInChestServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "EditTime",
                        Where    = where.ToString()
                    };
                    MethodReturnResult <IList <Chest> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.List = result.Data;
                    }
                }
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ListPartial", model));
            }
            else
            {
                return(View(model));
            }
        }
Example #28
0
        public ActionResult RefreshChestList(string orderNumber, string materialCode, string grade, string powerName, string color, string powerSubCode)
        {
            if (ModelState.IsValid)
            {
                StringBuilder where = new StringBuilder();
                where.AppendFormat(string.Format(@" (ChestState = 0 OR ChestState = 6)"));
                if (orderNumber != null && orderNumber != "")
                {
                    where.AppendFormat(" {0} OrderNumber = '{1}'"
                                       , where.Length > 0 ? "AND" : string.Empty
                                       , orderNumber.Trim().ToUpper());
                }

                if (materialCode != null && materialCode != "")
                {
                    where.AppendFormat(" {0} MaterialCode = '{1}'"
                                       , where.Length > 0 ? "AND" : string.Empty
                                       , materialCode.Trim().ToUpper());
                }

                if (powerName != null && powerName != "")
                {
                    where.AppendFormat(" {0} PowerName LIKE '{1}%'"
                                       , where.Length > 0 ? "AND" : string.Empty
                                       , powerName.Trim().ToUpper());
                }

                if (grade != null && grade != "")
                {
                    where.AppendFormat(" {0} Grade LIKE '{1}%'"
                                       , where.Length > 0 ? "AND" : string.Empty
                                       , grade.Trim().ToUpper());
                }

                if (color != null && color != "")
                {
                    where.AppendFormat(" {0} Color LIKE '{1}%'"
                                       , where.Length > 0 ? "AND" : string.Empty
                                       , color.Trim().ToUpper());
                }

                if (powerSubCode != null && powerSubCode != "")
                {
                    where.AppendFormat(" {0} PowerSubCode = '{1}'"
                                       , where.Length > 0 ? "AND" : string.Empty
                                       , powerSubCode.Trim().ToUpper());
                }
                using (PackageInChestServiceClient client = new PackageInChestServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "EditTime",
                        Where    = where.ToString()
                    };
                    MethodReturnResult <IList <Chest> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.List = result.Data;
                    }
                }
            }
            return(PartialView("_ListPartial", new ChestMonitorQueryViewModel()));
        }
Example #29
0
        public async Task <ActionResult> ExportToExcel(LotDefectQueryViewModel model)
        {
            IList <LotTransactionDefect> lst = new List <LotTransactionDefect>();

            using (LotQueryServiceClient client = new LotQueryServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "EditTime",
                        Where    = GetQueryCondition(model)
                    };
                    MethodReturnResult <IList <LotTransactionDefect> > result = client.GetLotTransactionDefect(ref cfg);

                    if (result.Code == 0)
                    {
                        lst = result.Data;
                    }
                });
            }
            //创建工作薄。
            IWorkbook wb = new HSSFWorkbook();
            //设置EXCEL格式
            ICellStyle style = wb.CreateCellStyle();

            style.FillForegroundColor = 10;
            //有边框
            style.BorderBottom = BorderStyle.THIN;
            style.BorderLeft   = BorderStyle.THIN;
            style.BorderRight  = BorderStyle.THIN;
            style.BorderTop    = BorderStyle.THIN;
            IFont font = wb.CreateFont();

            font.Boldweight = 10;
            style.SetFont(font);
            ICell  cell = null;
            IRow   row  = null;
            ISheet ws   = null;

            for (int j = 0; j < lst.Count; j++)
            {
                if (j % 65535 == 0)
                {
                    ws  = wb.CreateSheet();
                    row = ws.CreateRow(0);
                    #region //列名
                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(StringResource.ItemNo);  //项目号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.LotNumber);  //批次号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("工单号");  //工单号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("工序");  //工序

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("线别");  //线别

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.LotDefectViewModel_DefectQuantity);  //数量

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.ReasonCodeCategoryName);  //原因代码组

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.ReasonCodeName);  //原因代码

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.ReasonDescription);  //原因描述

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.LotDefectViewModel_RouteOperationName);  //责任工序

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.LotDefectViewModel_ResponsiblePerson);  //责任人

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(StringResource.Description);  //描述

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("操作时间");  //操作时间

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("操作人");  //操作人
                    #endregion
                    font.Boldweight = 5;
                }
                LotTransactionDefect  obj       = lst[j];
                LotTransaction        transObj  = null;
                LotTransactionHistory lotHisObj = null;
                using (LotQueryServiceClient client = new LotQueryServiceClient())
                {
                    MethodReturnResult <LotTransaction> result = client.GetTransaction(obj.Key.TransactionKey);
                    if (result.Code == 0)
                    {
                        transObj = result.Data;
                    }

                    MethodReturnResult <LotTransactionHistory> result1 = client.GetLotTransactionHistory(obj.Key.TransactionKey);
                    if (result1.Code == 0)
                    {
                        lotHisObj = result1.Data;
                    }
                }
                row = ws.CreateRow(j + 1);

                #region //数据
                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(j + 1);  //项目号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(transObj.LotNumber);  //批次号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(transObj.OrderNumber);  //工单号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(transObj.RouteStepName);  //工序

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(lotHisObj != null ? lotHisObj.LineCode : string.Empty);  //线别

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Quantity);  //数量

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Key.ReasonCodeCategoryName);  //原因代码组

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Key.ReasonCodeName);  //原因代码

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Description);  //原因描述

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.RouteOperationName);  //责任工序

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.ResponsiblePerson);  //责任人

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Description);  //描述

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(string.Format("{0:yyyy-MM-dd HH:mm:ss}", obj.EditTime));  //操作时间

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Editor);  //操作人
                #endregion
            }

            MemoryStream ms = new MemoryStream();
            wb.Write(ms);
            ms.Flush();
            ms.Position = 0;
            return(File(ms, "application/vnd.ms-excel", "LotDefectData.xls"));
        }
Example #30
0
        public ActionResult Query(WIPDisplayQueryViewModel model)
        {
            DataTable dtWIPData = new DataTable();

            using (WIPDisplayServiceClient client = new WIPDisplayServiceClient())
            {
                MethodReturnResult <DataSet> rst = client.Get(new WIPDisplayGetParameter()
                {
                    LocationName = model.LocationName,
                    MaterialCode = model.MaterialCode,
                    OnlineTime   = model.OnlineTime,
                    OrderNumber  = model.OrderNumber
                });
                if (rst.Code <= 0 && rst.Data != null && rst.Data.Tables.Count > 0)
                {
                    dtWIPData = rst.Data.Tables[0];
                }
            }

            IList <RouteOperation> lstRouteOperation = new List <RouteOperation>();

            using (RouteOperationServiceClient client = new RouteOperationServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = "Status=1",
                    OrderBy  = "SortSeq"
                };
                MethodReturnResult <IList <RouteOperation> > rst = client.Get(ref cfg);
                if (rst.Code <= 0 && rst.Data != null)
                {
                    lstRouteOperation = rst.Data;
                }
            }

            #region 整理成显示格式的数据
            const string SUMMARY_COLUMN_NAME = "合计";
            DataTable    dt = new DataTable();
            //增加状态列
            DataColumn dcStatus = new DataColumn("状态");
            dt.Columns.Add(dcStatus);
            DataRow dr0 = dt.NewRow();
            dr0[0] = "暂停";
            dt.Rows.Add(dr0);
            DataRow dr1 = dt.NewRow();
            dr1[0] = "等待";
            dt.Rows.Add(dr1);
            DataRow dr2 = dt.NewRow();
            dr2[0] = "运行";
            dt.Rows.Add(dr2);
            DataRow dr3 = dt.NewRow();
            dr3[0] = "总计";
            dt.Rows.Add(dr3);
            //增加工序列表
            for (int i = 0; i < lstRouteOperation.Count; i++)
            {
                string     colName = lstRouteOperation[i].Key;
                DataColumn col     = new DataColumn(colName);
                col.DataType = typeof(double);
                dt.Columns.Add(col);
                dr0[col] = "0";
                dr1[col] = "0";
                dr2[col] = "0";
                dr3[col] = "0";
            }
            //增加合计列
            DataColumn dcSum = new DataColumn(SUMMARY_COLUMN_NAME);
            dcSum.DataType = typeof(double);
            dt.Columns.Add(dcSum);

            double sumHold = 0;
            double sumWait = 0;
            double sumRun  = 0;
            ///凑数据源的表头
            for (int i = 0; i < dtWIPData.Rows.Count; i++)
            {
                //工序
                string stepName = Convert.ToString(dtWIPData.Rows[i]["ROUTE_STEP_NAME"]);
                //状态
                string strState_flag = Convert.ToString(dtWIPData.Rows[i]["STATE_FLAG"]);
                //数量
                double qty = Convert.ToDouble(dtWIPData.Rows[i]["QTY"]);
                switch (strState_flag)
                {
                case "暂停":
                    dr0[stepName] = qty.ToString();
                    sumHold      += qty;
                    break;

                case "等待":
                    dr1[stepName] = qty.ToString();
                    sumWait      += qty;
                    break;

                case "运行":
                    dr2[stepName] = qty.ToString();
                    sumRun       += qty;
                    break;

                default:
                    break;
                }
                dr3[stepName] = Convert.ToInt32(dr0[stepName]) + Convert.ToInt32(dr1[stepName]) + Convert.ToInt32(dr2[stepName]);
            }
            dr0[SUMMARY_COLUMN_NAME] = sumHold;
            dr1[SUMMARY_COLUMN_NAME] = sumWait;
            dr2[SUMMARY_COLUMN_NAME] = sumRun;
            dr3[SUMMARY_COLUMN_NAME] = sumWait + sumRun + sumHold;
            #endregion

            string key = Convert.ToString(Session.SessionID);
            string routeOperationKey = string.Format("{0}_RouteOperation", key);
            HttpContext.Cache[key] = dtWIPData;
            HttpContext.Cache[routeOperationKey] = lstRouteOperation;
            ViewBag.ListData = dt;
            ViewBag.Key      = key;
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ListPartial", model));
            }
            else
            {
                return(View(model));
            }
        }
Example #31
0
        //
        // GET: /FMM/ScheduleDay/
        public async Task <ActionResult> Index(string locationName, string routeOperationName, string year, string month)
        {
            string   sStartDate = string.Format("{0}-{1}-01", year, month);
            DateTime startDate  = DateTime.Now;

            if (!DateTime.TryParse(sStartDate, out startDate))
            {
                return(RedirectToAction("Index", "ScheduleMonth"));
            }
            string scheduleName = string.Empty;

            //获取月排班计划。
            using (ScheduleMonthServiceClient client = new ScheduleMonthServiceClient())
            {
                MethodReturnResult <ScheduleMonth> result = await client.GetAsync(new ScheduleMonthKey
                {
                    LocationName       = locationName,
                    RouteOperationName = routeOperationName,
                    Year  = year,
                    Month = month
                });

                if (result.Code > 0 || result.Data == null)
                {
                    return(RedirectToAction("Index", "ScheduleMonth"));
                }
                scheduleName          = result.Data.ScheduleName;
                ViewBag.ScheduleMonth = result.Data;
            }
            //获取排班计划明细。
            using (ScheduleDetailServiceClient client = new ScheduleDetailServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format(@"Key.ScheduleName='{0}'", scheduleName)
                };
                MethodReturnResult <IList <ScheduleDetail> > result = client.Get(ref cfg);

                if (result.Code == 0)
                {
                    ViewBag.ScheduleDetailList = result.Data;
                }
            }
            //获取日排班计划。
            using (ScheduleDayServiceClient client = new ScheduleDayServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format(@"Key.LocationName='{0}' 
                                                AND Key.RouteOperationName='{1}' 
                                                AND Key.Day>='{2}' 
                                                AND Key.Day<='{3}'",
                                                 locationName,
                                                 routeOperationName,
                                                 startDate.ToString("yyyy-MM-dd"),
                                                 startDate.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd"))
                    };
                    MethodReturnResult <IList <ScheduleDay> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.ScheduleDayList = result.Data;
                    }
                });
            }
            return(View());
        }