public Business_RideCheckFeedback AddBusiness_RideCheckFeedback(string user)
        {
            Business_RideCheckFeedback rideCheckFeedback = new Business_RideCheckFeedback();

            rideCheckFeedback.FeedbackCode = DateTime.Now.ToString("yyyyMMddHHmmss");
            rideCheckFeedback.ChangeUser   = rideCheckFeedback.CreateUser = user;
            rideCheckFeedback.ChangeDate   = rideCheckFeedback.CreateDate = DateTime.Now;
            rideCheckFeedback.VGUID        = Guid.NewGuid();
            rideCheckFeedback.Status       = "1";
            using (SqlSugarClient _dbMsSql = SugarDao_MsSql.GetInstance())
            {
                _dbMsSql.DisableInsertColumns = new string[] { "RideCheckFeedback_Items", "RideCheckFeedback_Attachments" };
                _dbMsSql.Insert(rideCheckFeedback);
                SaveBusiness_RideCheckFeedbackItem(user, rideCheckFeedback.VGUID, 1, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("HH:mm"), "", "", "", "", "");
                SaveBusiness_RideCheckFeedbackItem(user, rideCheckFeedback.VGUID, 2, "", "", "", "", "", "", "");
                SaveBusiness_RideCheckFeedbackItem(user, rideCheckFeedback.VGUID, 3, "", "", "", "", "", "", "");
                SaveBusiness_RideCheckFeedbackItem(user, rideCheckFeedback.VGUID, 4, "", "", "", "", "", "", "");
                SaveBusiness_RideCheckFeedbackItem(user, rideCheckFeedback.VGUID, 5, "", "", "", "", "", "", "");
                SaveBusiness_RideCheckFeedbackItem(user, rideCheckFeedback.VGUID, 6, "", "", "", "", "", "", "");
                SaveBusiness_RideCheckFeedbackItem(user, rideCheckFeedback.VGUID, 7, "", "", "", "", "", "", "");
                rideCheckFeedback.RideCheckFeedback_Items = _dbMsSql.Queryable <Business_RideCheckFeedback_Item>().Where(c => c.RideCheckFeedbackVGUID == rideCheckFeedback.VGUID).OrderBy(c => c.FeedbackNumber).ToList();
            }

            return(rideCheckFeedback);
        }
        public Business_RideCheckFeedback GetUserNewRideCheckFeedback(string user)
        {
            Business_RideCheckFeedback rideCheckFeedback = null;

            using (SqlSugarClient _dbMsSql = SugarDao_MsSql.GetInstance())
            {
                rideCheckFeedback = _dbMsSql.Queryable <Business_RideCheckFeedback>().Where(c => c.Status == "1" && c.CreateUser == user).OrderBy(c => c.CreateDate, OrderByType.Desc).FirstOrDefault();
                if (rideCheckFeedback != null)
                {
                    rideCheckFeedback.RideCheckFeedback_Items = _dbMsSql.Queryable <Business_RideCheckFeedback_Item>().Where(i => i.RideCheckFeedbackVGUID == rideCheckFeedback.VGUID).OrderBy(c => c.FeedbackNumber).ToList();
                    if (rideCheckFeedback.RideCheckFeedback_Items == null)
                    {
                        rideCheckFeedback.RideCheckFeedback_Items = new List <Business_RideCheckFeedback_Item>();
                    }
                    rideCheckFeedback.RideCheckFeedback_Attachments = _dbMsSql.Queryable <Business_RideCheckFeedback_Attachment>().Where(c => c.RideCheckFeedbackVGUID == rideCheckFeedback.VGUID).OrderBy(c => c.CreateDate).ToList();
                    if (rideCheckFeedback.RideCheckFeedback_Attachments == null)
                    {
                        rideCheckFeedback.RideCheckFeedback_Attachments = new List <Business_RideCheckFeedback_Attachment>();
                    }
                }
            }
            return(rideCheckFeedback);
        }
        public ActionResult Index(string code)
        {
            bool           isOpen      = false;
            string         isOpenType  = "unuriver";
            int            count       = _logic.GetMonthCountConfig();
            string         accessToken = Common.WeChatPush.WeChatTools.GetAccessoken();
            U_WeChatUserID userInfo    = new U_WeChatUserID();
            string         userInfoStr = Common.WeChatPush.WeChatTools.GetUserInfoByCode(accessToken, code);

            userInfo = Common.JsonHelper.JsonToModel <U_WeChatUserID>(userInfoStr);        //用户ID
            //userInfo.UserId = "13671595340";
            Business_Personnel_Information personInfoModel = GetUserInfo(userInfo.UserId); //获取人员表信息
            //Business_Personnel_Information personInfoModel = GetUserInfo("WangCunBiao");//获取人员表信息
            Business_RideCheckFeedback rideCheckFeedback = new Business_RideCheckFeedback();

            if (personInfoModel != null && personInfoModel.DepartmenManager != 1)
            {
                isOpenType = "";
                DateTime startDate = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date;
                int      maxCount  = _logic.GetRideCheckFeedbackCount(startDate, startDate.AddMonths(1), personInfoModel.Vguid.ToString());
                if (maxCount < count)
                {
                    rideCheckFeedback = _logic.GetUserNewRideCheckFeedback(personInfoModel.Vguid.ToString());
                    if (rideCheckFeedback == null)
                    {
                        rideCheckFeedback = _logic.AddBusiness_RideCheckFeedback(personInfoModel.Vguid.ToString());
                    }
                    isOpen = true;
                }
            }

            ViewBag.RideCheckFeedback = rideCheckFeedback;
            ViewBag.IsOpen            = isOpen;
            ViewBag.IsOpenType        = isOpenType;
            ViewBag.User = personInfoModel;
            return(View());
        }