Beispiel #1
0
        public int Add(AddMonthlyPlanInput input)
        {
            var userId = _authInfoProvider.GetCurrent().User.Id;

            if (!_projectHelper.HasPermission("项目计划负责人", input.ProjectId))//权限设置
            {
                throw new AppCoreException("月计划发布没有权限");
            }
            var plan = input.MapTo <MonthlyPlan>();

            if (plan.RecordDate == null)
            {
                throw new AppCoreException("传入数据的RecordTime不能为空");
            }
            if (plan.ProjectId == 0)
            {
                throw new AppCoreException("传入数据的ProjectId不能为空");
            }
            if (_planRepository.Count(u => u.ProjectId == plan.ProjectId && u.RecordDate == plan.RecordDate) > 0)
            {
                throw new EntityException("RecordDate", plan.RecordDate.ToString("y"), "InvestmentMonthlyPlan", "已存在");
            }
            _planRepository.Add(plan);
            return(plan.Id);
        }
Beispiel #2
0
 public int Count(string name, int?id)
 {
     name = name.Trim();
     if (!string.IsNullOrEmpty(id.ToString()))
     {
         return(_problemRepository.Count(u => u.Source == name && u.Id != id && u.State == DataState.Stable));
     }
     else
     {
         return(_problemRepository.Count(u => u.Source == name && u.State == DataState.Stable));
     }
 }
Beispiel #3
0
 public int Count(string name, int?id)
 {
     name = name.Trim();
     if (!string.IsNullOrEmpty(id.ToString()))
     {
         return(_earlyStageRepository.Count(u => u.ReplyNumber == name && u.Id != id && u.State == DataState.Stable));
     }
     else
     {
         return(_earlyStageRepository.Count(u => u.ReplyNumber == name && u.State == DataState.Stable));
     }
 }
Beispiel #4
0
        public int Add(StartProcessInput <AddProjectInput> input)
        {
            NullableHelper.SetNull(input.Data);
            var variables = new Dictionary <string, object>();
            var userId    = _authInfoProvider.GetCurrent().User.Id;

            variables.Add("starter", userId.ToString());
            int processInstanceId = _runtimeProvider.StartProcessInstanceByName(
                input.ProcessDefinitionName,
                $"{input.ProcessDefinitionName}-{input.Data.Name}",
                variables);
            var tasks = _taskProvider.GetByProcessInstance(processInstanceId);

            if (tasks.Count == 0)
            {
                throw new AppCoreException("任务未创建成功!");
            }
            var project = input.Data.MapTo <Project>();
            var count   = ProjectContext.Instance.GetProjectBaseInfoNoCount(() => _projectRepository.Count(u => u.CreateTime.Value.Year == DateTime.Now.Year && (u.DataState == DataState.Stable || u.DataState == DataState.Creating)));

            project.ProcessInstanceId = processInstanceId;
            project.DataState         = DataState.Creating;
            project.No  = $"{DateTime.Now.Year}{count.ToString("0000")}";
            project.Mid = null;
            _projectRepository.Add(project);
            var task = tasks[0];

            if (!input.PreventCommit)
            {
                _taskProvider.Complete(task.Id);
            }
            return(project.Id);
        }
Beispiel #5
0
        public int Add(StartProcessInput <AddMonthlyProgressInput> input)
        {
            NullableHelper.SetNull(input.Data);
            var variables = new Dictionary <string, object>();
            var userId    = _authInfoProvider.GetCurrent().User.Id;

            if (!_projectHelper.HasPermission("投资信息负责人", input.Data.ProjectId))
            {
                throw new AppCoreException("月投资填报没有权限");
            }

            variables.Add("starter", userId.ToString());
            int processInstanceId = _runtimeProvider.StartProcessInstanceByName(
                input.ProcessDefinitionName,
                $"{input.ProcessDefinitionName}-{input.Data.Year}-{input.Data.Month}",
                variables);
            var tasks = _taskProvider.GetByProcessInstance(processInstanceId);

            if (tasks.Count == 0)
            {
                throw new AppCoreException("任务未创建成功!");
            }
            var progress = input.Data.MapTo <MonthlyProgress>();

            if (progress.ProjectId == 0)
            {
                throw new AppCoreException("传入数据的ProjectId不能为空");
            }
            if (_progressRepository.Count(u => u.ProjectId == progress.ProjectId && u.RecordDate == progress.RecordDate && u.DataState == DataState.Stable) > 0)
            {
                throw new EntityException("Date", progress.RecordDate, "PmMonthlyReport", "已存在");
            }
            progress.ProcessInstanceId = processInstanceId;
            progress.DataState         = DataState.Creating;
            progress.Mid = null;
            _progressRepository.Add(progress);
            var task = tasks[0];

            if (!input.PreventCommit)
            {
                _taskProvider.Complete(task.Id);
            }
            return(progress.Id);
        }
Beispiel #6
0
        public int Add(StartProcessInput <AddContractPaymentInput> input)
        {
            if (input.Data.ContractId == 0)
            {
                throw new AppCoreException("合同id不能为0");
            }
            var variables = new Dictionary <string, object>();
            var userId    = _authInfoProvider.GetCurrent().User.Id;

            variables.Add("starter", userId.ToString());
            int processInstanceId = _runtimeProvider.StartProcessInstanceByName(
                input.ProcessDefinitionName,
                $"{input.ProcessDefinitionName}",//-{input.Data.Title}
                variables);
            var tasks = _taskProvider.GetByProcessInstance(processInstanceId);

            if (tasks.Count == 0)
            {
                throw new AppCoreException("任务未创建成功!");
            }

            var contractPayment = input.Data.MapTo <ContractPayment>();

            // var count = AppSampleContext.Instance.GetSupplierNoCount(() => _supplierRepository.Count(u => u.CreateTime.Value.Year == DateTime.Now.Year && (u.State == DataState.Stable || u.State == DataState.Creating)));
            contractPayment.ProcessInstanceId = processInstanceId;
            contractPayment.State             = DataState.Creating;
            // memorabiliaRecord.SupplierNo = $"{DateTime.Now.Year}{count.ToString("000000")}";
            var paymentNumberPrefix = $"CP{DateTime.Now.ToString("yyyyMMdd")}";
            var count = _contractPaymentRepository.Count(u => u.PaymentNumber.Contains(paymentNumberPrefix) && (u.State == DataState.Stable || u.State == DataState.Creating));

            contractPayment.PaymentNumber = $"{paymentNumberPrefix}{count.ToString("00")}";
            contractPayment.Mid           = null;
            _contractPaymentRepository.Add(contractPayment);
            var task = tasks[0];

            if (!input.PreventCommit)
            {
                _taskProvider.Complete(task.Id);
            }
            return(contractPayment.Id);
        }
Beispiel #7
0
        public int AddNew(int tenantId, int projectId)
        {
            if (projectId == 0)
            {
                throw new EntityException("Id", projectId, "Project", "不存在");
            }
            var             count          = _briefingRepository.Count(u => u.ProjectId == projectId);
            ProjectBriefing briefing       = new ProjectBriefing();
            var             weeklyProgress = _progressRepository.Get().Where(u => u.ProjectId == projectId && u.DataState == DataState.Stable).OrderByDescending(u => u.CreateTime).FirstOrDefault();

            if (weeklyProgress != null)
            {
                briefing.CumulativeImageProgress = weeklyProgress.AccumulatedImageProgress;
                briefing.NextWeekProgressPlan    = weeklyProgress.NextMonthPlannedImageProgress;
                briefing.Supervision             = weeklyProgress.Supervision;
                briefing.ThisWeekProgress        = weeklyProgress.ImageProgress;
                briefing.Information             = weeklyProgress.Information;
                briefing.ProgressLimitDate       = $"{weeklyProgress.AddDate}";
            }
            //存在问题统计
            var problems = _problemRepository.Get()
                           .Where(u => u.ProjectId == projectId && u.State == DataState.Stable && u.CoordinationState != CoordinationState.Completed)
                           .OrderBy(u => u.CreateTime).ToList();
            var list = problems.Select(u => new { problem = u.Content, Solution = u.ProposalSolution }).ToList();

            briefing.ProblemAndSolution = JsonConvert.SerializeObject(list);
            //质量问题统计
            var qualityProblem = _qualityProblemRepository.Get()
                                 .Include(u => u.Rectifications)
                                 .Where(u => u.ProjectId == projectId && u.State == DataState.Stable)// && u.RectificationState != RectificationState.Completed
                                 .OrderBy(u => u.CreateTime).ToList();
            var listProblem = qualityProblem.Select(u => new { QualityId = u.Id, Source = u.Source, RectificationState = u.RectificationState.GetDesc(), Description = u.Description, Scheme = u.Rectifications.Count == 0?null: u.Rectifications.Select(s => s.Description).ToList() }).ToList();

            briefing.QualitySourceAndDescription = JsonConvert.SerializeObject(listProblem);
            //质量事故统计
            var qualityAccident = _qualityAccidentRepository.Get()
                                  .Include(u => u.Disposals)
                                  .Where(u => u.ProjectId == projectId && u.State == DataState.Stable)// && u.RectificationState != RectificationState.Completed
                                  .OrderBy(u => u.CreateTime).ToList();
            var listAccident = qualityAccident.Select(u => new { AccidentId = u.Id, Title = u.Title, DisposalState = u.DisposalState.GetDesc(), Content = u.Content, Scheme = u.Disposals.Count == 0 ? null : u.Disposals.Select(s => s.Plan).ToList() }).ToList();

            briefing.QualityAccidentAndDescription = JsonConvert.SerializeObject(listAccident);
            //安全问题统计
            var safetyProblem = _safetyProblemRepository.Get()
                                .Include(u => u.Source)
                                .Include(u => u.Rectifications)
                                .Where(u => u.ProjectId == projectId && u.State == DataState.Stable)// && u.RectificationState != Safety.SafetyProblemRectifications.RectificationState.Completed
                                .OrderBy(u => u.CreateTime).ToList();
            var listSafety = safetyProblem.Select(u => new { SafetyId = u.Id, Sources = u.Source?.Name, RectificationStates = u.RectificationState.GetDesc(), Descriptions = u.Description, Scheme = u.Rectifications.Count == 0 ? null : u.Rectifications.Select(s => s.Description).ToList() }).ToList();

            briefing.SafetySourceAndDescription = JsonConvert.SerializeObject(listSafety);
            //安全事故统计
            var safetyAccident = _safetyAccidentRepository.Get()
                                 .Include(u => u.Source)
                                 .Include(u => u.Disposals)
                                 .Where(u => u.ProjectId == projectId && u.State == DataState.Stable)// && u.RectificationState != Safety.SafetyProblemRectifications.RectificationState.Completed
                                 .OrderBy(u => u.CreateTime).ToList();
            var listSafetyAccident = safetyAccident.Select(u => new { SafetyAccidentId = u.Id, Titles = u.Title, DisposalStates = u.DisposalState.GetDesc(), Contents = u.Content, Scheme = u.Disposals.Count == 0 ? null : u.Disposals.Select(s => s.Solution).ToList() }).ToList();

            briefing.SafetyAccidentAndDescription = JsonConvert.SerializeObject(listSafetyAccident);
            //文明施工问题统计

            var housekeeping = _housekeepingRepository.Get()
                               .Where(u => u.ProjectId == projectId && u.State == DataState.Stable && u.RectificationState != Housekeeping.HousekeepingProblemRectifications.RectificationState.Completed)
                               .OrderBy(u => u.CreateTime).ToList();
            var listHousekeeping = housekeeping.Select(u => new { Content = u.Content }).ToList();

            briefing.HousekeepingConetent = JsonConvert.SerializeObject(listHousekeeping);
            briefing.Version   = ++count;
            briefing.ProjectId = projectId;
            briefing.TenantId  = tenantId;
            _briefingRepository.Add(briefing);
            return(briefing.Id);
        }