Пример #1
0
        public Task <int> SubmitForm <TDto>(ProcessFlowEntity entity, TDto dto) where TDto : class
        {
            if (!string.IsNullOrEmpty(entity.F_Id))
            {
                entity.Modify(entity.F_Id);
                entity.F_LastModifyUserId = _usersService.GetCurrentUserId();
                if (entity.F_PreWeight != null && entity.F_PostWeight != null && entity.F_PreUrea != null && entity.F_PostUrea != null)
                {
                    var preWeight  = entity.F_PreWeight.ToFloat(2);
                    var postWeight = entity.F_PostWeight.ToFloat(2);
                    if (preWeight > postWeight)
                    {
                        var preUrea  = entity.F_PreUrea.ToFloat(2);
                        var postUrea = entity.F_PostUrea.ToFloat(2);
                        if (preUrea > postUrea)
                        {
                            var duration = entity.F_TotalHours.ToFloat(1);
                            if (duration > 0)
                            {
                                //计算Kt/V
                                entity.F_Result = (-Math.Log(postUrea / preUrea - 0.008 * duration) + (4 - 3.5 * postUrea / preUrea) * (preWeight - postWeight) / postWeight).ToFloat(2);
                            }
                        }
                    }
                }

                return(_service.UpdateAsync(entity, dto));
            }
            else
            {
                entity.Create();
                entity.F_CreatorUserId = _usersService.GetCurrentUserId();
                return(_service.InsertAsync(entity));
            }
        }