Esempio n. 1
0
        //
        // GET: /Employee/Create

        public ActionResult Create()
        {
            var shifts = _shiftRepository.Get();

            ViewBag.Dept   = _deptRepository.Get();
            ViewBag.Branch = _branchRepository.Get();
            return(View(shifts));
        }
        /// <summary>
        /// 同步排班(新增或修改)
        /// </summary>
        /// <param name="sync"></param>
        /// <returns></returns>
        public async Task <OutputBase> AddOrUpdate(AddShiftSync sync)
        {
            var shift = await _repository.Get(sync.DialysisShiftId, sync.HospitalId);

            if (shift == null)
            {
                _repository.Add(Mapper.Map <AddShiftSync, Shift>(sync));
            }
            else
            {
                Mapper.Map(sync, shift);
            }

            return(_unitWork.Commit() ? OutputBase.Success("保存成功") : OutputBase.Fail("保存失败"));
        }
Esempio n. 3
0
        private void GetData()
        {
            //Get Data Table Shift
            Shift shift = _shiftRepository.Get(_id);

            txtShiftNo.Text  = shift.ShiftNo;
            txtNote.Text     = shift.Note;
            chkUsing.Checked = (shift.Status == GlobalConstants.StatusValue.Using);
        }
        public ActionResult Index()
        {
            List <Shift> shifts = _shiftRepository.Get();

            return(View(shifts));
        }
Esempio n. 5
0
        /// <summary>
        /// 同步透析上机(新增或修改)
        /// </summary>
        /// <param name="sync"></param>
        /// <returns></returns>
        public async Task <OutputBase> AddDialysisOn(AddDialysisOnSync sync)
        {
            var patient = await _patientRepository.Get(sync.DialysisPatientId, sync.HospitalId);

            if (patient == null)
            {
                return(OutputBase.Fail("患者不存在"));
            }

            var shift = await _shiftRepository.Get(sync.DialysisShiftId, sync.HospitalId);

            if (shift == null)
            {
                return(OutputBase.Fail("排班信息不存在"));
            }

            var dialysis = await _repository.Get(sync.DialysisRecordId, sync.HospitalId);

            if (dialysis == null)
            {
                dialysis           = Mapper.Map <AddDialysisOnSync, Domain.Models.Dialysis>(sync);
                dialysis.PatientId = patient.Id;
                dialysis.ShiftId   = shift.Id;
                _repository.Add(dialysis);
            }
            else
            {
                dialysis.BedNo               = sync.BedNo;
                dialysis.ConfirmedUFV        = sync.ConfirmedUFV;
                dialysis.DialysisDate        = sync.DialysisDate;
                dialysis.DialysisDuration    = sync.DialysisDuration;
                dialysis.PatientId           = patient.Id;
                dialysis.ShiftId             = shift.Id;
                dialysis.DialysisWay         = sync.DialysisWay;
                dialysis.Doctor              = sync.Doctor;
                dialysis.DryWeight           = sync.DryWeight;
                dialysis.OnBreath            = sync.OnBreath;
                dialysis.OnDiastolicPressure = sync.OnDiastolicPressure;
                dialysis.OnNurse             = sync.OnNurse;
                dialysis.OnPulseRate         = sync.OnPulseRate;
                dialysis.OnSystolicPressure  = sync.OnSystolicPressure;
                dialysis.PatientName         = sync.PatientName;
                dialysis.PlannedUFV          = sync.PlannedUFV;
                dialysis.PreWeight           = sync.PreWeight;
                dialysis.StartTime           = sync.StartTime;
                dialysis.TreatmentComment    = sync.TreatmentComment;
            }

            #region 添加上机Message
            var startTime = sync.StartTime.GetValueOrDefault();
            var content   = string.Format("上机时间:{0} 预计下机时间:{1}", startTime.ToString(CommConstant.TimeFormatString),
                                          startTime.AddMinutes(sync.DialysisDuration.GetValueOrDefault()).ToString(CommConstant.TimeFormatString));
            var message = new Domain.Models.Message
            {
                AppType   = (int)AppTypeEnum.Patient,
                Content   = content,
                IsRead    = false,
                ReceiveId = patient.Id,
                SendId    = 0,
                SendName  = "系统",
                Title     = "透析前上机测量",
                Type      = (int)MessageTypeEnum.透析上机,
                OuterId   = dialysis.Id.ToString()
            };
            _messageRepository.Add(message);
            #endregion

            if (!_unitWork.Commit())
            {
                OutputBase.Fail("保存失败");
            }

            #region 向患者端异步发送上机JPush
            ThreadPool.QueueUserWorkItem(delegate
            {
                new JPushMessage(AppTypeEnum.Patient, (int)JPushKeyEnum.DialysisOn, patient.Id.ToString(), content, dialysis.Id.ToString(), _optionsAccessor.IsDevModel).SendPush();
                new JPushNotification(AppTypeEnum.Patient, (int)JPushKeyEnum.DialysisOn, patient.Id.ToString(), content, dialysis.Id.ToString(), _optionsAccessor.IsDevModel).SendPush();
            });
            #endregion

            return(OutputBase.Success("保存成功"));
        }
        public ActionResult Index(string from, string to, int shiftId = 0, int deptId = 0, int branchId = 0)
        {
            var events    = _eventLogRepository.Get();
            var employees = _employeeRepository.Get();
            var shifts    = _shiftRepository.Get();
            var depts     = _deptRepository.Get();
            var branches  = _branchRepository.Get();

            ViewBag.Shifts      = shifts;
            ViewBag.Departments = depts;
            ViewBag.Branches    = branches;

            var query = _attendanceService.GetUserAttendance(events, employees);
            List <Attendance> result;

            query = shiftId != 0 ? query.Where(_ => _.Shift.Id == shiftId) : query;
            query = deptId != 0 ? query.Where(_ => _.Department.Id == deptId) : query;
            query = branchId != 0 ? query.Where(_ => _.Branch.Id == branchId) : query;
            DateTime fromDate, toDate;

            if (from != null && DateTime.TryParse(from, out fromDate))
            {
                query = query.Where(_ => _.Date >= fromDate);
            }
            if (to != null && DateTime.TryParse(to, out toDate))
            {
                query = query.Where(_ => _.Date <= toDate);
            }

            var filterResult = query.ToList();
            var numberOfLeavesTakenByEmployee = _leaveCountRepository.GetLeaveCount(query);
            var leaveCountDictionary          = numberOfLeavesTakenByEmployee.ToDictionary(l => l.EmployeeId);
            var groupByUser         = filterResult.GroupBy(_ => _.UserId);
            var attendanceSummaries = new List <AttendanceSummary>();

            foreach (var g in groupByUser)
            {
                var totalPresents = g.Count();
                var totalLates    = g.Count(day => TimeSpan.Compare(day.FirstEntryTime.TimeOfDay,
                                                                    TimeSpan.Parse(day.Shift.GraceEntryTime).Add(TimeSpan.FromMinutes(1))) == 1);
                totalPresents -= totalLates;
                var totalDays = totalPresents + totalLates;
                if (leaveCountDictionary.Count > 0 && leaveCountDictionary.ContainsKey(g.FirstOrDefault().Employee.Id))
                {
                    attendanceSummaries.Add(new AttendanceSummary
                    {
                        Name                  = g.FirstOrDefault().Name,
                        TotalDays             = (int)totalDays,
                        TotalPresents         = totalPresents,
                        TotalLates            = totalLates,
                        ReamainingCasualLeave = leaveCountDictionary[g.FirstOrDefault().Employee.Id].CasualLeave,
                        ReamainingEarnLeave   = leaveCountDictionary[g.FirstOrDefault().Employee.Id].EarnLeave,
                        ReamainingSickLeave   = leaveCountDictionary[g.FirstOrDefault().Employee.Id].SickLeave
                    });
                }
                else
                {
                    attendanceSummaries.Add(new AttendanceSummary
                    {
                        Name                  = g.FirstOrDefault().Name,
                        TotalDays             = (int)totalDays,
                        TotalPresents         = totalPresents,
                        TotalLates            = totalLates,
                        ReamainingCasualLeave = 0,
                        ReamainingEarnLeave   = 0,
                        ReamainingSickLeave   = 0
                    });
                }
            }

            return(View(attendanceSummaries.OrderBy(_ => _.Name).ToList()));
        }