Beispiel #1
0
        public ActionResult Detail(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(Redirect("/Task/MyTask"));
            }

            TaskModel taskModel = new Models.TaskModel();
            //任务详情
            var task = TaskBusiness.GetTaskDetail(id);

            if (task == null)
            {
                Response.Write("<script>alert('任务不存在');location.href='/Task/MyTask';</script>");
                Response.End();
            }
            taskModel.Task = task;

            //任务对应的订单详情
            var order = task.Order;
            ProcessCategoryEntity      item           = SystemBusiness.BaseBusiness.GetProcessCategoryByID(order.BigCategoryID);
            List <CategoryItemsEntity> categoryItems  = new List <CategoryItemsEntity>();
            List <CategoryItemsEntity> categoryItems2 = new List <CategoryItemsEntity>();

            if (item.CategoryItems != null)
            {
                categoryItems  = item.CategoryItems.FindAll(m => m.Type == 4).ToList();
                categoryItems2 = item.CategoryItems.FindAll(m => m.Type == 3);
            }
            ViewBag.plateMarkItems = categoryItems;
            ViewBag.Modules        = categoryItems2;
            if (task.Mark == 11)
            {
                order.Details = OrdersBusiness.BaseBusiness.GetOrderDetailsByOrderID(task.OrderID);
                if (order.Details == null)
                {
                    order.Details = new List <IntFactoryEntity.OrderDetail>();
                }
                if (order.OrderType == 1)
                {
                    order.OrderAttrs = OrdersBusiness.BaseBusiness.GetOrderArrrsByOrderID(task.OrderID);
                }
            }
            taskModel.Order = order;

            //判断查看权限
            if (!IsSeeRoot(task, order))
            {
                Response.Write("<script>alert('您无查看任务权限');location.href='/Task/MyTask';</script>");
                Response.End();
            }

            //任务剩余时间警告
            var isWarn = false;

            if (task.FinishStatus == 1)
            {
                if (task.EndTime > DateTime.Now)
                {
                    var totalHour   = (task.EndTime - task.AcceptTime).TotalHours;
                    var residueHour = (task.EndTime - DateTime.Now).TotalHours;

                    var residue = residueHour / totalHour;
                    if (residue < 0.333)
                    {
                        isWarn = true;
                    }
                }
            }
            taskModel.IsWarn = isWarn;

            //当前用户是否为任务负责人
            taskModel.IsTaskOwner = task.OwnerID.Equals(CurrentUser.UserID, StringComparison.OrdinalIgnoreCase) ? true : false;

            //当前用户是否有编辑权限
            var        isEditTask = false;
            TaskMember member     = task.TaskMembers.Find(a => a.MemberID.ToLower() == CurrentUser.UserID.ToLower());

            if (member != null)
            {
                if (member.PermissionType == 2)
                {
                    isEditTask = true;
                }
            }
            taskModel.IsEditTask = isEditTask;

            //订单的品类属性
            taskModel.ProductAttr = new IntFactoryEntity.ProductAttr();
            //制版任务
            if (task.Mark == 12 || task.Mark == 22)
            {
                taskModel.ProductAttr = new ProductsBusiness().GetTaskPlateAttrByCategoryID(order.CategoryID);
            }

            //任务完成周期
            if (task.FinishStatus == 2)
            {
                taskModel.FinishDay = (int)Math.Ceiling((task.CompleteTime - task.AcceptTime).TotalDays);
            }
            //操作权限
            taskModel.IsRoot  = (task.Status != 8 && (task.FinishStatus == 1 || task.LockStatus == 2) && (taskModel.IsEditTask || taskModel.IsTaskOwner));
            ViewBag.TaskModel = taskModel;

            return(View());
        }
Beispiel #2
0
        public JsonResult GetTaskDetail(string taskID, string userID, string clientID)
        {
            if (!string.IsNullOrEmpty(taskID))
            {
                var item = TaskBusiness.GetTaskDetail(taskID);
                Dictionary <string, object>         task    = new Dictionary <string, object>();
                List <Dictionary <string, object> > details = new List <Dictionary <string, object> >();
                string domainUrl = Request.Url.Scheme + "://" + Request.Url.Host;
                if (item != null)
                {
                    task.Add("taskID", item.TaskID);
                    task.Add("taskCode", item.TaskCode);
                    task.Add("orderID", item.OrderID);
                    task.Add("processID", item.ProcessID);
                    task.Add("stageID", item.StageID);
                    task.Add("title", item.Title);
                    task.Add("mark", item.Mark);
                    task.Add("colorMark", item.ColorMark);
                    task.Add("finishStatus", item.FinishStatus);
                    task.Add("orderType", item.OrderType);
                    task.Add("taskMembers", item.TaskMembers);
                    task.Add("lockStatus", item.LockStatus);
                    string orderImg = string.Empty;
                    if (!string.IsNullOrEmpty(item.OrderImg) && !item.OrderImg.Contains("bkt.clouddn.com"))
                    {
                        orderImg = domainUrl + item.OrderImg;
                    }
                    else
                    {
                        orderImg = item.OrderImg;
                    }
                    task.Add("orderImg", orderImg);
                    task.Add("acceptTime", item.AcceptTime.ToString("yyyy-MM-dd") != "0001-01-01" ? item.AcceptTime.ToString("yyyy-MM-dd") : "");
                    task.Add("endTime", item.EndTime.ToString("yyyy-MM-dd") != "0001-01-01" ? item.EndTime.ToString("yyyy-MM-dd") : "");
                    task.Add("completeTime", item.CompleteTime.ToString("yyyy-MM-dd") != "0001-01-01" ? item.CompleteTime.ToString("yyyy-MM-dd") : "");
                    task.Add("createTime", item.CreateTime.ToString("yyyy-MM-dd hh:mm:ss"));
                    task.Add("ownerUser", GetUserBaseObj(item.Owner));

                    var orderDetail = OrdersBusiness.BaseBusiness.GetOrderByID(item.OrderID);
                    Dictionary <string, object> order = new Dictionary <string, object>();
                    if (orderDetail != null)
                    {
                        order.Add("orderID", orderDetail.OrderID);
                        order.Add("originalID", orderDetail.OriginalID);
                        order.Add("orderType", orderDetail.OrderType);
                        order.Add("goodsName", orderDetail.GoodsName);
                        order.Add("goodsCode", orderDetail.IntGoodsCode);
                        order.Add("planTime", orderDetail.PlanTime.ToString("yyyy-MM-dd") != "0001-01-01" ? orderDetail.PlanTime.ToString("yyyy-MM-dd") : "");
                        order.Add("orderCode", orderDetail.OrderCode);
                        string orderdetailImg = string.Empty;
                        if (!string.IsNullOrEmpty(orderDetail.OrderImage) && !item.OrderImg.Contains("bkt.clouddn.com"))
                        {
                            orderdetailImg = domainUrl + orderDetail.OrderImage;
                        }
                        else
                        {
                            orderdetailImg = orderDetail.OrderImage;
                        }
                        order.Add("orderImage", orderdetailImg);
                        order.Add("orderImages", orderDetail.OrderImages);
                        order.Add("platemaking", orderDetail.Platemaking);
                        order.Add("remark", orderDetail.Remark);
                        task.Add("order", order);
                    }
                    var moduleName = string.Empty;
                    if (item.Mark > 0)
                    {
                        ProcessCategoryEntity processCategory = SystemBusiness.BaseBusiness.GetProcessCategoryByID(orderDetail.BigCategoryID);
                        var categoryItems = processCategory.CategoryItems.FindAll(m => m.Type == 3);
                        var categoryItem  = categoryItems.Find(m => m.Mark == item.Mark);
                        moduleName = categoryItem != null ? categoryItem.Name : string.Empty;
                    }
                    JsonDictionary.Add("moduleName", moduleName);
                    JsonDictionary.Add("task", task);
                    JsonDictionary.Add("domainUrl", domainUrl);
                }
            }

            return(new JsonResult
            {
                Data = JsonDictionary,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }