Exemple #1
0
        /// <summary>
        /// 通过加工任务获取延期提醒策略
        /// </summary>
        /// <param name="processTask"></param>
        /// <param name="delayType"></param>
        /// <returns></returns>
        public virtual async Task <List <Tactic> > GetActiveTacticsByDelayProcessTask(ProcessTask processTask, DelayType delayType)
        {
            using (CurrentUnitOfWork.SetTenantId(processTask.TenantId))
            {
                var projectSN = processTask.Part.Project.ProjectSN;
                //使用缓存优化性能
                var allTactics = await GetAllActiveTactics();

                //限制模具编号
                if (!string.IsNullOrEmpty(projectSN))
                {
                    allTactics = allTactics.Where(o => o.RemindTacticInfo == null || o.RemindTacticInfo.RemindProjectSNs.Count == 0 || o.RemindTacticInfo.RemindProjectSNs.Contains(projectSN)).ToList();
                }
                switch (delayType)
                {
                //延期上机
                case DelayType.DelayStart:
                    allTactics = allTactics.Where(o => o.RemindTacticInfo.EnableStartDelayRemind && processTask.AppointDate != null && processTask.StartDate == null && (DateTime.Now - processTask.AppointDate.Value).TotalDays >= o.RemindTacticInfo.StartDelayOffsetDay).ToList();
                    break;

                //延期下机
                case DelayType.DelayEnd:
                    allTactics = allTactics.Where(o => o.RemindTacticInfo.EnableEndDelayRemind && processTask.RequireDate != null && processTask.EndDate == null && (DateTime.Now - processTask.RequireDate.Value).TotalDays >= o.RemindTacticInfo.EndDelayOffsetDay).ToList();
                    break;

                //到料未上机
                case DelayType.ReceiveNotStart:
                    allTactics = allTactics.Where(o => o.RemindTacticInfo.EnableReceiveNotStartRemind && processTask.ReceiveDate != null && processTask.StartDate == null && (DateTime.Now - processTask.ReceiveDate.Value).TotalDays >= o.RemindTacticInfo.ReceiveNotStartOffsetDay).ToList();
                    break;

                //工时超预计
                case DelayType.ExceedHour:
                    allTactics = allTactics.Where(o => o.RemindTacticInfo.EnableExceedHourRemind && processTask.StartDate != null && processTask.EndDate == null && processTask.EstimateHours != null && o.RemindTacticInfo.ExceedHourOffsetHour > 0 && (DateTime.Now - processTask.StartDate.Value).TotalHours >= o.RemindTacticInfo.ExceedHourOffsetHour).ToList();
                    break;
                }

                return(allTactics);
            }
        }
Exemple #2
0
        /// <summary>
        /// 获取加工任务的动态提醒人
        /// </summary>
        /// <param name="tactic"></param>
        /// <param name="processTask"></param>
        /// <returns></returns>
        public virtual async Task <List <Person> > GetTacticDynamicReminders(Tactic tactic, ProcessTask processTask)
        {
            var personManager = Resolve <PersonManager>();
            var remindPersons = new List <Person>();
            var remindInfo    = tactic.RemindTacticInfo;

            if (remindInfo.DynamicRemindPoster && !string.IsNullOrEmpty(processTask.Poster))
            {
                remindPersons.Add(await personManager.FindByName(processTask.Poster));
            }
            if (remindInfo.DynamicRemindProjectCharger && !string.IsNullOrEmpty(processTask.Part.Project.GetPropertyValue <string>("ProjectCharger")))
            {
                remindPersons.Add(await personManager.FindByName(processTask.Part.Project.GetPropertyValue <string>("ProjectCharger")));
            }
            if (remindInfo.DynamicRemindProjectTracker && !string.IsNullOrEmpty(processTask.Part.Project.GetPropertyValue <string>("ProjectTracker")))
            {
                remindPersons.Add(await personManager.FindByName(processTask.Part.Project.GetPropertyValue <string>("ProjectTracker")));
            }
            if (remindInfo.DynamicRemindCraftsMan && !string.IsNullOrEmpty(processTask.CraftsMan))
            {
                remindPersons.Add(await personManager.FindByName(processTask.CraftsMan));
            }
            if (remindInfo.DynamicRemindVerifier && !string.IsNullOrEmpty(processTask.Verifier))
            {
                remindPersons.Add(await personManager.FindByName(processTask.Verifier));
            }
            if (remindInfo.DynamicRemindChecker && !string.IsNullOrEmpty(processTask.Checker))
            {
                remindPersons.Add(await personManager.FindByName(processTask.Checker));
            }
            if (remindInfo.DynamicRemindCustomer && processTask.Part?.Project?.Unit != null)
            {
                try
                {
                    //提醒客户
                    var openids = await Resolve <MESUnitManager>().FindUnitOpenId(processTask.Part.Project.Unit, MESStatusNames.ReceiveOuterTask);

                    foreach (var openid in openids)
                    {
                        var person = await personManager.GetPersonByWeUserOrInsert(new Senparc.Weixin.MP.AdvancedAPIs.OAuth.OAuthUserInfo()
                        {
                            openid = openid
                        });

                        remindPersons.Add(person);
                    }
                }
                catch (Exception ex)
                {
                }

                //var customerTenantId = processTask.Part.Project.Unit?.GetPropertyValue<int?>("TenantId");
                //if(remindPersonIds!=null && remindPersonIds.Count > 0)
                //{
                //    remindPersons.AddRange(await personManager.GetListByIdsAsync(remindPersonIds));
                //}
            }
            return(remindPersons.Where(o => o != null).Distinct().ToList());
        }
Exemple #3
0
        /// <summary>
        /// 获取延期任务的提醒人
        /// </summary>
        /// <param name="processTask"></param>
        /// <param name="delayType"></param>
        /// <returns></returns>
        public virtual async Task <List <PersonTacticInfo> > GetRemindPersonByDelayTask(ProcessTask processTask, DelayType delayType)
        {
            var remindPersons = new List <PersonTacticInfo>();//待提醒人

            using (CurrentUnitOfWork.SetTenantId(processTask.TenantId))
            {
                var tactics = await GetActiveTacticsByDelayProcessTask(processTask, delayType);

                foreach (var tactic in tactics)
                {
                    remindPersons.AddRange((await GetTacticReminders(tactic.Id)).Select(o => new PersonTacticInfo()
                    {
                        Person  = o,
                        Tactics = new List <Tactic>()
                        {
                            tactic
                        }
                    }));
                    //添加动态提醒人,客户,开单人,模具组长,工艺师,审核,检验
                    remindPersons.AddRange((await GetTacticDynamicReminders(tactic, processTask)).Select(o => new PersonTacticInfo()
                    {
                        Person  = o,
                        Tactics = new List <Tactic>()
                        {
                            tactic
                        }
                    }));
                }
            }

            return(MergePersonTacticInfo(remindPersons));

            //remindPersons = remindPersons.Distinct().Where(o => o != null).ToList();
            //return remindPersons;
        }