Example #1
0
        public IEnumerable <PageGrouped> GetAllByRole(int id)
        {
            var result = _context.PagesEx.AsNoTracking().FromSql("usp_GetPagesByRole_sel {0}", id).
                         Select(pg => new PagesEx
            {
                PagesID          = pg.PagesID,
                PageName         = pg.PageName,
                FullPath         = pg.FullPath,
                IsActive         = pg.IsActive,
                PagesGroupsID    = pg.PagesGroupsID,
                PagesGroupsName  = pg.PagesGroupsName,
                RoleTypeID       = pg.RoleTypeID,
                RoleTypeName     = pg.RoleTypeName,
                PageInUserRoleID = pg.PageInUserRoleID
            });

            var groupedresult = from so in result
                                group so by so.PagesGroupsName into ByGroup
                                select new PageGrouped
            {
                PageGroup = ByGroup.Key,
                Pages     = ByGroup.ToList()
            };

            return(groupedresult);
        }
Example #2
0
        public JsonResult GetPagesForUser(int id)
        {
            /* by parent
             * IQueryable<PagesEx> result = _context.PagesEx.FromSql(@"usp_GetPagesByUser_sel {0}", id).
             * Select(pg => new PagesEx
             * {
             *     PagesID = pg.PagesID,
             *     PageName = pg.PageName,
             *     FullPath = pg.FullPath,
             *     IsActive = pg.IsActive,
             *     PagesGroupsID = pg.PagesGroupsID,
             *     PagesGroupsName = pg.PagesGroupsName,
             *     RoleTypeID = pg.RoleTypeID,
             *     RoleTypeName = pg.RoleTypeName,
             *     ParentGroupID = pg.ParentGroupID,
             *     ParentGroupName = pg.ParentGroupName,
             *     PageInUserRoleID = pg.PageInUserRoleID
             * });
             *
             * var groupedresult = from so in result
             *                  group so by so.ParentGroupName into GroupedbyParent
             *                  select new
             *                  {
             *                      ParentGroup = GroupedbyParent.Key,
             *                      PageGroups = from grp2 in GroupedbyParent
             *                                   group grp2 by grp2.PagesGroupsName into GroupedbyGroupName
             *                                   select new
             *                                   {
             *                                       PageGroup = GroupedbyGroupName.Key,
             *                                       Pages = GroupedbyGroupName.ToList()
             *                                   }
             *                  };
             */
            IQueryable <PagesEx> result = _context.PagesEx.FromSql(@"usp_GetPagesByUser_sel {0}", id).
                                          Select(pg => new PagesEx
            {
                PagesID         = pg.PagesID,
                PageName        = pg.PageName,
                FullPath        = pg.FullPath,
                IsActive        = pg.IsActive,
                PagesGroupsID   = pg.PagesGroupsID,
                PagesGroupsName = pg.PagesGroupsName,
                RoleTypeID      = pg.RoleTypeID,
                RoleTypeName    = pg.RoleTypeName,
                //ParentGroupID = null,
                //ParentGroupName = null,
                PageInUserRoleID = pg.PageInUserRoleID
            });

            var groupedresult = from so in result
                                group so by so.PagesGroupsName into ByGroup
                                select new
            {
                PageGroup = ByGroup.Key,
                Pages     = ByGroup.ToList()
            };

            return(Json(groupedresult));
        }
Example #3
0
        /// <summary>
        ///     获取下一步处理人员信息
        /// </summary>
        /// <param name="doubleWay"></param>
        /// <returns></returns>
        private IEnumerable <WorkflowEngineReceiveUserOutput> GetWorkflowEngineTaskNextReceiveUser(WorkflowEngineNextActivitysDoubleWay doubleWay)
        {
            ReceiveUserFactory receiveUserFactory = new ByUser();

            switch (doubleWay.ProcessorType)
            {
            case EnumActivityProcessorType.岗位:
                receiveUserFactory = new ByPost();
                break;

            case EnumActivityProcessorType.工作组:
                receiveUserFactory = new ByGroup();
                break;

            case EnumActivityProcessorType.所有成员:
                receiveUserFactory = new ByAll();
                break;

            case EnumActivityProcessorType.部门:
                receiveUserFactory = new ByOrganization();
                break;
            }
            return(receiveUserFactory.GetWorkflowEngineReceiveUserOutputs(doubleWay));
        }
Example #4
0
        public async Task <IActionResult> SummanyReportByJobNumber([FromBody] SummanyReportViewModel summany)
        {
            var Message = "Data not been found.";

            try
            {
                if (summany != null)
                {
                    if (!summany.PlanMasterId.HasValue)
                    {
                        return(NoContent());
                    }
                    // return BadRequest(new { error = "Data not been found." });

                    Expression <Func <PlanMaster, bool> > exp = e => e.PlanMasterId == summany.PlanMasterId;

                    // if (!string.IsNullOrEmpty(summany.Where))
                    //TODO Filter or do someing

                    if (!string.IsNullOrEmpty(summany.WorkGroup))
                    {
                        exp = exp.And(x => x.PlanDetails.Any
                                          (z => z.AssignmentToGroup == summany.WorkGroup));
                    }

                    if (summany.BomLevel.HasValue)
                    {
                        exp = exp.And(x => x.PlanDetails.Any
                                          (z => z.BillofMaterialId == summany.BomLevel));
                    }

                    var GetData = await this.repository.GetFirstOrDefaultAsync(
                        x => x, exp,
                        z => z.OrderByDescending(x => x.Revised));

                    var Rate = (await this.repositoryRate.GetFirstOrDefaultAsync(e => e, e =>
                                                                                 e.StandardTimeForWorkGroup.Name.ToLower().Contains("fabricate") &&
                                                                                 GetData.CreateDate.Value.Date >= e.ValidFrom && GetData.CreateDate.Value.Date <= e.ValidTo))?.RateBathPerManHour ?? 0;

                    var NickName = await this.repositoryNickName.GetAllAsync();

                    var SummanyDatas = new List <SummanyDataPlanVsActual>();

                    //Get Detail Data
                    var DetailData = await this.repositoryPlanDetail.GetToListAsync(
                        z => z,
                        z => z.PlanMasterId == GetData.PlanMasterId,
                        null,
                        z => z.Include(x => x.FabricationManHour));

                    var TotalRow = DetailData.GroupBy(x => x.AssignmentToGroup).Count();
                    // foreach(var ByGroup in DetailData.GroupBy(x => x.AssignmentToGroup).Skip(summany.Skip ?? 0).Take(summany.Take ?? 10))
                    foreach (var ByGroup in DetailData.GroupBy(x => x.AssignmentToGroup))
                    {
                        if (ByGroup.Key == null)
                        {
                            continue;
                        }

                        var WorkGroup = await this.repositoryGroupMis.GetFirstOrDefaultAsync(
                            x => x,
                            m => m.GroupMis == ByGroup.Key, null,
                            x => x.Include(z => z.WorkGroupHasWorkShop).ThenInclude(z => z.WorkShop));

                        var WorkShop = WorkGroup?.WorkGroupHasWorkShop.FirstOrDefault()?.WorkShop ?? null;
                        //EngMH
                        //var EngMH = ByGroup.Sum(x => (x?.EngineerManHour?.CuttingPlanMH ?? 0) +
                        //                             (x?.EngineerManHour?.CuttingPlanCheckMH ?? 0) +
                        //                             (x?.EngineerManHour?.PackingCheckMH ?? 0) +
                        //                             (x?.EngineerManHour?.PackingMH ?? 0) +
                        //                             (x?.EngineerManHour?.ShopDrawingCheckMH ?? 0) +
                        //                             (x?.EngineerManHour?.ShopDrawingMH ?? 0));
                        ////FabMH
                        var FabMH = ByGroup.Sum(x => (x?.FabricationManHour?.FabricationMH ?? 0) +
                                                (x?.FabricationManHour?.PerAssemblyMH ?? 0));
                        //PackMH
                        //var PackMH = ByGroup.Sum(x => (x?.PackingManHour?.PackingMH ?? 0));
                        //WeldMH
                        //var WeldMH = ByGroup.Sum(x => (x?.WeldManHour?.WeldMH ?? 0));
                        var TotalWeight = ByGroup.Sum(x => x.ContentWeigth ?? 0);
                        SummanyDatas.Add(new SummanyDataPlanVsActual
                        {
                            WorkShopName   = WorkShop?.WorkShopName ?? "Data not found",
                            WorkGroup      = WorkGroup != null ? (NickName.FirstOrDefault(x => x.GroupCode == WorkGroup.GroupMis)?.NickName ?? WorkGroup?.GroupDesc ?? "-") : "Data not found",
                            Item           = string.Join(", ", ByGroup.Select(x => x.Description)),
                            Weight         = TotalWeight,
                            EngManHour     = 0,
                            FabManHour     = FabMH,
                            FabRateManHour = Rate > 0 && TotalWeight > 0 && FabMH > 0 ? (FabMH * Rate) / (TotalWeight * 1000) : 0,
                            PackManHour    = 0,
                            WeldManHour    = 0,
                        });
                    }

                    if (SummanyDatas.Any())
                    {
                        return(new JsonResult(new
                        {
                            SummanyDatas = SummanyDatas.OrderBy(x => x.WorkShopName),
                            TotalRow
                        }, this.DefaultJsonSettings));
                    }
                }
            }
            catch (Exception ex)
            {
                Message = $"Has error {ex.ToString()}";
            }

            return(BadRequest(new { error = Message }));
        }