コード例 #1
0
        /// <summary>
        /// 选择中标方
        /// </summary>
        /// <param name="processQuote"></param>
        /// <param name="bidId"></param>
        /// <returns></returns>
        public virtual async Task Choose(ProcessQuote processQuote,int bidId)
        {
            var processTaskManager = Resolve<ProcessTaskManager>();
            var mesUnitManager = Resolve<MESUnitManager>();
            var remindLogManager = Resolve<RemindLogManager>();

            var bid = processQuote.ProcessQuoteBids.Where(o => o.Id == bidId).Single();
            if (bid.QuoteBidStatus != QuoteBidStatus.已投标)
            {
                throw new UserFriendlyException(L("只能选择已投标状态的投标方"));
            }
            processQuote.ChooseUserId = AbpSession.UserId;//设置选标人
            processQuote.QuoteStatus = QuoteStatus.已选标;
            bid.QuoteBidStatus = QuoteBidStatus.已中标;
            //加工任务关联的,则直接进行开单
            foreach(var quoteTask in processQuote.ProcessQuoteTasks.Where(o => o.ProcessTaskId != null))
            {
                quoteTask.ProcessTask.SupplierId = bid.UnitId;
                quoteTask.ProcessTask.JobFee = bid.BidData.Cost;//设置中标金额为初始金额
                quoteTask.ProcessTask.SetPropertyValue("SubmitFeeFromProcessorDto", new { Fee=bid.BidData.Cost, Info=bid.Remarks });//设置回单金额
                await processTaskManager.KaiDan(quoteTask.ProcessTask);
            }
            //设置其余投标为未中标,但是已放弃的投标不改变其状态
            foreach (var otherBid in processQuote.ProcessQuoteBids.Where(o => o.Id != bidId && o.QuoteBidStatus != QuoteBidStatus.已放弃))
            {
                otherBid.QuoteBidStatus = QuoteBidStatus.未中标;
            }
            //发送中标提醒
            //被提醒人微信openid
            var openId = "";
            try
            {
                openId = (await mesUnitManager.FindUnitOpenId(bid.Unit))[0];
            }
            catch (Exception ex)
            {

            }
            if (!string.IsNullOrEmpty(openId))
            {
                //进行发送提醒
                //先产生一条提醒记录
                var remindLog = new RemindLog()
                {
                    RemindType = "询价提醒",
                    Name = bid.Unit.UnitName,
                    TenantId = processQuote.TenantId
                };
                var remindLogId = await remindLogManager.InsertAndGetIdAsync(remindLog);
                var arg = new SendWeiXinMessageJobArgs()
                {
                    OpenId = openId,
                    DataId = processQuote.Id,
                    RemindLogId = remindLogId
                };

                BackgroundJobManager.Enqueue<SendProcessQuoteChooseMessageJob, SendWeiXinMessageJobArgs>(arg);
            }
        }
コード例 #2
0
        /// <summary>
        /// 对任务进行开单
        /// </summary>
        /// <param name="processTask"></param>
        /// <returns></returns>
        public virtual async Task KaiDan(ProcessTask processTask)
        {
            //更改状态至待上机
            if (processTask.ProcessTaskStatus == ProcessTaskStatus.Inputed)
            {
                processTask.ProcessTaskStatus = ProcessTaskStatus.WaitForProcess;
            }
            //add 20190429 设置审核人为当前人员
            if (string.IsNullOrEmpty(processTask.Verifier))
            {
                processTask.Verifier = AbpSession.Name();
            }
            await SaveAsync(processTask);

            await CurrentUnitOfWork.SaveChangesAsync();

            processTask.KaiDate = DateTime.Now;
            //生成加工单号
            GenerateProcessSN(processTask);
            #region 20190506 Tiansfather 如果是外协的单,则开单后提醒发送人
            if (!processTask.Inner && processTask.SupplierId != null)
            {
                //获取所有有发送权限的人
                var users = await Resolve <UserManager>().FindByPermission("Module.JGKD.Button.SendToUnit");

                //提醒接收发送提醒的人
                foreach (var user in users.Where(o => o.Id != AbpSession.UserId && o.HasStatus("ReceiveSendRemind")))
                {
                    var openId = user.GetWechatOpenId();
                    if (!string.IsNullOrEmpty(openId))
                    {
                        //先产生一条提醒记录
                        var remindLog = new RemindLog()
                        {
                            RemindType = "开单待发送提醒",
                            Name       = user.Name,
                            TenantId   = processTask.TenantId,
                            Message    = processTask.ProcessSN
                        };
                        var remindLogId = await Resolve <RemindLogManager>().InsertAndGetIdAsync(remindLog);

                        var arg = new SendWeiXinMessageJobArgs()
                        {
                            OpenId      = openId,
                            DataId      = processTask.Id,
                            RemindLogId = remindLogId
                        };
                        Resolve <IBackgroundJobManager>().Enqueue <TaskToSendMessageJob, SendWeiXinMessageJobArgs>(arg);
                    }
                }
            }
            #endregion
        }
コード例 #3
0
        /// <summary>
        /// 开单审核提醒
        /// </summary>
        /// <param name="processTask"></param>
        /// <returns></returns>
        public virtual async Task SendTaskConfirmRemind(ProcessTask processTask)
        {
            var remindLogManager = Resolve <RemindLogManager>();
            //所有有审核权限的用户
            var users = await Resolve <UserManager>().FindByPermission("Module.JGKD.Button.ConfirmProcess");

            //如果任务设定了审核人,只发送给此审核人员
            if (!string.IsNullOrEmpty(processTask.Verifier) && users.Exists(o => o.Name == processTask.Verifier))
            {
                users = users.Where(o => o.Name == processTask.Verifier).ToList();
            }
            //获取对应用户的微信登录信息
            var userLogins = await UserLoginRepository.GetAll()
                             .Where(o => users.Select(u => u.Id).Contains(o.UserId))
                             .Where(o => o.LoginProvider == WeChatAuthProviderApi.Name)
                             .Select(o => new { o.ProviderKey, o.UserId })
                             .ToListAsync();

            foreach (var userLogin in userLogins)
            {
                var openid = userLogin.ProviderKey;
                var name   = users.Where(o => o.Id == userLogin.UserId).Single().Name;
                //先产生一条提醒记录
                var remindLog = new RemindLog()
                {
                    RemindType = "开单审核提醒",
                    Name       = name,
                    TenantId   = AbpSession.TenantId,
                    Message    = processTask.Part?.Project?.ProjectSN + processTask.Part?.PartName + processTask.ProcessType?.ProcessTypeName,
                };
                var remindLogId = await remindLogManager.InsertAndGetIdAsync(remindLog);

                var arg = new SendWeiXinMessageJobArgs()
                {
                    OpenId      = openid,
                    DataId      = processTask.Id,
                    RemindLogId = remindLogId,
                };

                BackgroundJobManager.Enqueue <TaskConfirmMessageJob, SendWeiXinMessageJobArgs>(arg);
            }
        }
コード例 #4
0
ファイル: MESUnitManager.cs プロジェクト: tiansfather/JFCase
        /// <summary>
        /// 发送往来单位公告
        /// </summary>
        /// <param name="units"></param>
        /// <param name="notice"></param>
        /// <returns></returns>
        public virtual async Task SendUnitsNotice(IEnumerable <Unit> units, Notice notice)
        {
            var remindLogManager = Resolve <RemindLogManager>();

            foreach (var unit in units)
            {
                //被提醒人微信openid
                var openId = "";
                try
                {
                    openId = (await FindUnitOpenId(unit))[0];
                }
                catch (Exception ex)
                {
                }
                if (!string.IsNullOrEmpty(openId))
                {
                    //进行发送提醒
                    //先产生一条提醒记录
                    var remindLog = new RemindLog()
                    {
                        RemindType = "往来单位公告提醒",
                        Name       = unit.UnitName,
                        Message    = notice.NoticeTitle,
                        TenantId   = AbpSession.TenantId
                    };
                    var remindLogId = await remindLogManager.InsertAndGetIdAsync(remindLog);

                    var arg = new SendWeiXinMessageJobArgs()
                    {
                        OpenId      = openId,
                        DataId      = notice.Id,
                        RemindLogId = remindLogId
                    };

                    BackgroundJobManager.Enqueue <SendUnitNoticeMessageJob, SendWeiXinMessageJobArgs>(arg);
                }
            }
        }
コード例 #5
0
        public virtual void HandleEvent(EntityCreatedEventData <ProcessTaskReport> eventData)
        {
            //获取所有的被提醒人
            var remindInfos = _tacticManager.GetRemindPersonsByReport(eventData.Entity.Id).Result;

            foreach (var remindInfo in remindInfos)
            {
                var timespan     = remindInfo.GetAvailableRemindTimeSpan();
                var remindPerson = remindInfo.Person;
                var openid       = remindPerson.GetPropertyValue <string>("OpenId");
                //先产生一条提醒记录
                var remindLog = new RemindLog()
                {
                    RemindType = "报工提醒",
                    Name       = remindPerson.Name,
                    TenantId   = eventData.Entity.TenantId,
                    Message    = eventData.Entity.ReportType.ToString(),
                };
                if (timespan.TotalMinutes > 0)
                {
                    remindLog.SetPropertyValue("errMsg", $"延迟{timespan.TotalMinutes.ToString("0")}分钟后运行");
                }
                var remindLogId = RemindLogManager.InsertAndGetIdAsync(remindLog).Result;

                var arg = new SendWeiXinMessageJobArgs()
                {
                    OpenId      = openid,
                    DataId      = eventData.Entity.Id,
                    RemindLogId = remindLogId,
                };


                _backgroundJobManager.Enqueue <SendReportWeiXinMessageJob, SendWeiXinMessageJobArgs>(arg, BackgroundJobPriority.Normal, timespan);
                //_backgroundJobManager.Enqueue<SendReportWeiXinMessageJob, SendWeiXinMessageJobArgs>(arg);
                //WeiXin.WeiXinHelper.SendTemplateMessage(openid, templateId, url, message);
            }
            //_backgroundJobManager.Enqueue<SendReportWeiXinMessageJob, int>(eventData.Entity.Id);
        }
コード例 #6
0
        /// <summary>
        /// 发布一个询价
        /// </summary>
        /// <param name="processQuoteId"></param>
        /// <returns></returns>
        public virtual async Task Publish(int processQuoteId)
        {
            var mesUnitManager = Resolve<MESUnitManager>();
            var remindLogManager = Resolve<RemindLogManager>();

            var processQuote = await GetAll()
                .Include("ProcessQuoteBids.Unit")
                .Where(o => o.Id == processQuoteId)
                .SingleOrDefaultAsync();

            if (processQuote == null)
            {
                throw new UserFriendlyException(L("数据错误"));
            }
            if (processQuote.QuoteStatus != QuoteStatus.草稿 && processQuote.QuoteStatus!=QuoteStatus.询价中)
            {
                throw new UserFriendlyException(L("当前询价状态不允许发布"));
            }
            
            if (processQuote.ProcessQuoteBids.Count(o =>o.Unit==null || !o.Unit.GetTenantId().HasValue) > 0)
            {
                throw new UserFriendlyException(L("所有加工点均绑定账套后方可发布"));
            }
            if (processQuote.QuoteStatus == QuoteStatus.草稿)
            {
                //更改询价状态
                processQuote.QuoteStatus = QuoteStatus.询价中;
                processQuote.PublishDate = DateTime.Now;
                GenerateQuoteSN(processQuote);
            }

            #region 发送提醒
            //对于所有未发送的投标明细进行发送
            foreach (var bidInfo in processQuote.ProcessQuoteBids.Where(o => o.QuoteBidStatus == QuoteBidStatus.未发送))
            {
                bidInfo.QuoteBidStatus = QuoteBidStatus.待投标;
                bidInfo.ToTenantId = bidInfo.Unit.GetTenantId();
                //被提醒人微信openid
                var openId = "";
                try
                {
                    openId = (await mesUnitManager.FindUnitOpenId(bidInfo.Unit))[0];
                }
                catch (Exception ex)
                {

                }
                if (!string.IsNullOrEmpty(openId))
                {
                    //进行发送提醒
                    //先产生一条提醒记录
                    var remindLog = new RemindLog()
                    {
                        RemindType = "询价提醒",
                        Name = bidInfo.Unit.UnitName,
                        TenantId = processQuote.TenantId
                    };
                    var remindLogId = await remindLogManager.InsertAndGetIdAsync(remindLog);
                    var arg = new SendWeiXinMessageJobArgs()
                    {
                        OpenId = openId,
                        DataId = processQuote.Id,
                        RemindLogId = remindLogId
                    };

                    BackgroundJobManager.Enqueue<SendProcessQuoteMessageJob, SendWeiXinMessageJobArgs>(arg);
                }

            }
            #endregion

            #region 到截止日期自动截止
            //设定定时任务,当询价截止时改变询价单状态
            var expireArg = new CheckExpireQuotesJobsArgs()
            {
                QuoteId = processQuoteId
            };
            var jobId = await BackgroundJobManager.EnqueueAsync<CheckExpireQuotesJobs, CheckExpireQuotesJobsArgs>(expireArg, BackgroundJobPriority.Normal, processQuote.ExpireDate - DateTime.Now);
            //将任务Id保存,以便在到期日期发生变化时取消此任务
            processQuote.SetPropertyValue("ExpireJobId", jobId);
            #endregion


        }