Beispiel #1
0
        public object Get()
        {
            var user = User.Identity.GetEmoloyee();

            if (user.Name == "admin")
            {
                var allData = _correctingInsService.GetCorrectingInss().Where(n => n.IsApproved != true).OrderBy(n => n.TaskCode).ThenByDescending(n => n.IsPrimary).ToList();
                var models  = allData.Select(n => new CorrectingInsModel
                {
                    Id            = n.Id,
                    TaskId        = n.TaskId,
                    TaskCode      = n.TaskCode,
                    IsPrimary     = n.IsPrimary,
                    EmployeeModel = new EmployeeModel {
                        Name = n.EmpName, Code = n.EmpCode
                    },
                    DateTime         = n.DateTime,
                    InstitutionModel = new InstitutionModel
                    {
                        Name                  = n.Name != null ? n.Name : (n.OriginalInstitution != null ? n.OriginalInstitution.Name : n.Name),
                        TelNum                = n.TelNum != null ? n.TelNum : (n.OriginalInstitution != null ? n.OriginalInstitution.TelNum : n.TelNum),
                        LocationCode          = n.LocationCode != null ? n.LocationCode : (n.OriginalInstitution != null ? n.OriginalInstitution.LocationCode : n.LocationCode),
                        LocationName          = n.LocationName != null ? n.LocationName : (n.OriginalInstitution != null ? n.OriginalInstitution.LocationName : n.LocationName),
                        Address               = n.Address != null ? n.Address : (n.OriginalInstitution != null ? n.OriginalInstitution.Address : n.Address),
                        SpecializedDepartment = n.InsSpecializedDepartment,
                        LevelName             = n.InsLevel != null ? n.InsLevel : ((n.OriginalInstitution != null && n.OriginalInstitution.LevelId != null) ? n.OriginalInstitution.LevelName : n.InsLevel),
                        TierName              = n.InsTier != null ? n.InsTier : ((n.OriginalInstitution != null && n.OriginalInstitution.TierId != null) ? n.OriginalInstitution.TierName.ToChineseNumerals() : n.InsTier),
                        Nature                = n.InsNature,
                        Attribute             = n.InsAttribute,
                        InstitutionType       = n.InsType,
                        Beds                  = n.Beds,
                        Outpatients           = n.Outpatients,
                        Parent                = n.ParentId != null ? new InstitutionModel {
                            Name = n.ParentInstitution.Name, LocationName = n.ParentInstitution.LocationName
                        } : null,
                        Childrens = allData.Where(p => p.ParentId == n.OriginalId && n.OriginalId != null).Select(p => new InstitutionModel {
                            Name = p.Name
                        }).ToArray()
                    },
                    OriginalInstitutionModel = n.OriginalId != null ? new InstitutionModel
                    {
                        Name         = n.OriginalInstitution.Name,
                        TelNum       = n.OriginalInstitution.TelNum,
                        LocationCode = n.OriginalInstitution.LocationCode,
                        LocationName = n.OriginalInstitution.LocationName,
                        Address      = n.OriginalInstitution.Address,
                        LevelName    = n.OriginalInstitution.LevelName == "未知" ? "无等次" : n.OriginalInstitution.LevelName,
                        TierName     = n.OriginalInstitution.TierId != null ? (n.OriginalInstitution.TierName == "未知" ? "无级别" : n.OriginalInstitution.TierName.ToChineseNumerals() + "级") : null
                    } : null,
                    WhetherToAdd = n.OriginalId == null,
                    IsApproved   = n.IsApproved,
                    IsDeleted    = n.IsDeleted
                });
                return(models);
            }
            return(null);
        }
        public object Get()
        {
            //var source = _correctingInsService.GetCorrectingInss().Where(n => n.IsApproved == true).GroupBy(n => n.EmpCode).Select(n => new ScoreBoardModel { EmpCode = n.Key, Score = n.GroupBy(p => p.TaskId).Count(), EmpName = n.Select(p => p.EmpName).FirstOrDefault() }).OrderBy(n => n.Score).Take(20).ToList();
            var noapproved = _correctingInsService.GetCorrectingInss().Where(n => n.IsApproved != true);
            var data       = _correctingInsService.GetCorrectingInss().Where(n => n.IsApproved == true && n.IsDeleted != true);
            //var source = data.Where(n => n.IsPrimary && noapproved.Any(p => p.TaskId == n.TaskId)==false).GroupBy(n => n.EmpCode).Select(n => new ScoreBoardModel { EmpCode = n.Key, Score = n.GroupBy(p => p.TaskId).Count(), EmpName = n.Select(p => p.EmpName).FirstOrDefault() }).OrderBy(n => n.Score).Take(20).ToList();
            var source =
                data.Where(n => n.IsPrimary && noapproved.Any(p => p.TaskId == n.TaskId) == false)
                .GroupBy(n => n.EmpCode)
                .Select(
                    n =>
                    new ScoreBoardModel
            {
                EmpCode = n.Key,
                Score   = n.Where(p => p.IsPrimary).Select(p => (p.LocationCode != null && p.InsTier != null && p.InsLevel != null && p.InsNature != null && p.InsAttribute != null && p.InsType != null) ? 2 : 1).Sum(),
                EmpName = n.Select(p => p.EmpName).FirstOrDefault()
            })
                .OrderByDescending(n => n.Score)
                .Take(20)
                .ToList();

            return(source);
        }
        public object Get(Guid id)
        {
            var model = _institutionService.GetInstitution(id);

            if (model != null)
            {
                var correctingIns = _correctingInsService.GetCorrectingInss().FirstOrDefault(n => n.OriginalId == model.Id);
                var parent        = (correctingIns != null && correctingIns.ParentId != null) ? _institutionService.GetInstitution(correctingIns.ParentId.Value) : null;
                var childrens     = _correctingInsService.GetCorrectingInss().Where(n => n.ParentId == model.Id).Select(n => new InstitutionModel {
                    Id = n.Id, Name = n.Name
                }).ToArray();

                return(new InstitutionModel
                {
                    Id = model.Id,
                    Name = correctingIns != null && correctingIns.Name != null ? correctingIns.Name : model.Name,
                    Address = correctingIns != null && correctingIns.Address != null ? correctingIns.Address : model.Address,
                    TierName = (correctingIns != null && correctingIns.InsLevel != null) ? correctingIns.InsTier : (model.TierName != null ? (model.TierName == "未知" ? "无级别" : model.TierName.ToChineseNumerals() + "级") : null),
                    LevelName = (correctingIns != null && correctingIns.InsLevel != null) ? correctingIns.InsLevel : (model.LevelName != null ? (model.LevelName == "未知" ? "无等次" : model.LevelName) : null),
                    LocationCode = correctingIns != null && correctingIns.LocationCode != null ? correctingIns.LocationCode : model.LocationCode,
                    LocationName = correctingIns != null && correctingIns.LocationName != null ? correctingIns.LocationName : model.LocationName,
                    InstitutionType = correctingIns != null && correctingIns.InsType != null ? correctingIns.InsType : null,
                    Nature = correctingIns != null && correctingIns.InsNature != null ? correctingIns.InsNature : null,
                    Attribute = correctingIns != null && correctingIns.InsAttribute != null ? correctingIns.InsAttribute : null,
                    SpecializedDepartment = correctingIns != null && correctingIns.InsSpecializedDepartment != null ? correctingIns.InsSpecializedDepartment : null,
                    Beds = correctingIns != null && correctingIns.Beds != null ? correctingIns.Beds : null,
                    Outpatients = correctingIns != null && correctingIns.Outpatients != null ? correctingIns.Outpatients : null,
                    TelNum = correctingIns != null && correctingIns.TelNum != null ? correctingIns.TelNum : model.TelNum,
                    Childrens = childrens,
                    Parent = parent != null ? new InstitutionModel {
                        Id = parent.Id, Name = parent.Name
                    } : null,
                });
            }
            return(null);
        }
Beispiel #4
0
        /// <summary>
        /// 检查是否允许编辑
        /// </summary>
        /// <param name="id">InstitutionId</param>
        /// <returns></returns>
        public object Get(Guid id)
        {
            var currentUser = User.Identity.GetEmoloyee();
            var res         = new ResponseModel {
                Error = false
            };
            //当前存在的数据
            var existing = _correctingInsService.GetCorrectingInss().FirstOrDefault(n => n.OriginalId == id);

            if (existing != null && existing.EmpCode != currentUser.Code)
            {
                var employee = _employeeService.GetEmployees().Where(n => n.Code == existing.EmpCode).FirstOrDefault();

                if (employee != null)
                {
                    res.Error   = true;
                    res.Message = employee.Name + "抢先一步正在更新";
                    return(res);
                }
            }
            return(res);
        }
Beispiel #5
0
        public object Post(InstitutionModel model)
        {
            var currentUser = User.Identity.GetEmoloyee();
            //当前存在的数据(删除)
            var existing = _correctingInsService.GetCorrectingInss().FirstOrDefault(n => n.OriginalId == model.Id);

            if (existing != null && existing.EmpCode != currentUser.Code)
            {
                var employee = _employeeService.GetEmployees().Where(n => n.Code == existing.EmpCode).FirstOrDefault();
                var res      = new ResponseModel {
                    Error = true, Message = ""
                };
                if (employee != null)
                {
                    res.Message = employee.Name + "抢先一步正在更新";
                    return(res);
                }
            }
            if (existing != null && existing.EmpCode == currentUser.Code)
            {
                var tasks = _correctingInsService.GetCorrectingInss().Where(n => n.TaskId == existing.TaskId);
                foreach (var task in tasks)
                {
                    task.IsDeleted = true;
                    task.DateTime  = DateTime.Now;
                }
            }
            var taskId   = Guid.NewGuid();
            var taskCode = _correctingInsService.GetMaxTaskCode() + 1;

            //先添加childs
            if (model.Childrens != null)
            {
                foreach (var child in model.Childrens)
                {
                    _correctingInsService.Insert(new CorrectingIns
                    {
                        Id                       = Guid.NewGuid(),
                        TaskCode                 = taskCode,
                        TaskId                   = taskId,
                        OriginalId               = child.Id == Guid.Empty ? (Guid?)null : child.Id,
                        Name                     = child.Name != null ? child.Name : null,
                        Address                  = child.Address != null ? child.Address : null,
                        InsLevel                 = child.LevelName != null?child.LevelName:null,
                        InsTier                  = child.TierName != null? child.TierName:null,
                        InsType                  = child.InstitutionType != null ? child.InstitutionType : null,
                        InsAttribute             = child.Attribute != null ? child.Attribute : null,
                        InsNature                = child.Nature != null ? child.Nature : null,
                        InsSpecializedDepartment = child.SpecializedDepartment != null ? child.SpecializedDepartment : null,
                        TelNum                   = child.TelNum != null ? child.TelNum : null,
                        Outpatients              = child.Outpatients != null ? child.Outpatients : null,
                        Beds                     = child.Beds != null ? child.Beds : null,
                        ParentId                 = model.Id,
                        DateTime                 = DateTime.Now,
                        EmpCode                  = currentUser.Code,
                        EmpName                  = currentUser.Name,
                        LocationCode             = child.LocationCode,
                        LocationName             = child.LocationName,
                        IsPrimary                = false
                    });
                }
            }
            //再添加Institution
            _correctingInsService.Insert(new CorrectingIns
            {
                Id                       = Guid.NewGuid(),
                IsPrimary                = true,
                TaskId                   = taskId,
                TaskCode                 = taskCode,
                OriginalId               = model.Id,
                Name                     = model.Name,
                Address                  = model.Address != null ? model.Address : null,
                InsLevel                 = model.LevelName != null ? model.LevelName : null,
                InsTier                  = model.TierName != null ? model.TierName : null,
                InsType                  = model.InstitutionType != null ? model.InstitutionType : null,
                InsAttribute             = model.Attribute != null ? model.Attribute : null,
                InsNature                = model.Nature != null ? model.Nature : null,
                InsSpecializedDepartment = model.SpecializedDepartment != null ? model.SpecializedDepartment : null,
                TelNum                   = model.TelNum != null ? model.TelNum : null,
                Outpatients              = model.Outpatients != null ? model.Outpatients : null,
                Beds                     = model.Beds != null ? model.Beds : null,
                ParentId                 = model.Parent != null ? model.Parent.Id : (Guid?)null,
                DateTime                 = DateTime.Now,
                EmpCode                  = currentUser.Code,
                EmpName                  = currentUser.Name,
                LocationCode             = model.LocationCode,
                LocationName             = model.LocationName,
            });

            try
            {
                _correctingInsService.Update();
            }
            catch (Exception ex)
            {
                return(new ResponseModel {
                    Error = true
                });
            }


            return(new ResponseModel {
                Error = false
            });
        }