移动系统liao
15 小时以前 757e9a10418043eb1a5c5e41975d3eb39db66a80
cylsg/cylsg.Application/CyOS/CyOsDeliverManage.cs
@@ -262,8 +262,8 @@
            }
            OA_CarManage car = null;
            if (Param.DriverId != null)
                car = await _client.Queryable<OA_CarManage>().Where(x => x.StaffID == Param.DriverId && x.MemberID == _oAServices.firmId).FirstAsync();
            if (Param.CarId != null)
                car = await _client.Queryable<OA_CarManage>().Where(x => x.Keyid == Param.CarId && x.MemberID == _oAServices.firmId).Includes(x=>x.Staff).FirstAsync();
         
            OA_CorporateClients cor = null;
@@ -287,7 +287,7 @@
                Sort = Param.Sort,
                Creater = Param.Creater ?? Permissions.MemberId,
                CreateTime = DateTime.Now,
                DriverId = Param.DriverId,
                DriverId = car?.Staff?.Keyid??0,
                SellerOrderId = await CreatDeliverPlanSn(),
                Dianhua = Param.Dianhua,
                Dizhi = Param.Dizhi,
@@ -340,10 +340,14 @@
            Expression<Func<OA_DeliverPlanPaiche, bool>> SearchList = (x) => true;
            SearchList = SearchList.And(x => x.FirmId == _oAServices.firmId);
            //SearchList = SearchList.And(x => x.Creater == Permissions.MemberId);//只看自己
            SearchList = SearchList.And(x => x.ShifouDelivery != 2);//过滤有效
            SearchList = SearchList.And(x => x.ShifouDelivery != 2&&x.ShifouDelivery!=0);//过滤有效
            if (Param.DeliverKeyID != null)
            {
                SearchList = SearchList.And(x => x.DriverId == Param.DeliverKeyID);
            }
            if (Param.CarId != null)
            {
                SearchList = SearchList.And(x => x.CarId == Param.CarId);
            }
            //客户名称
            if (!string.IsNullOrEmpty(Param.CorporateClient))
@@ -372,8 +376,15 @@
            //强制增加员工过滤
            RefAsync<int> totle = 0;
            var data = await _client.Queryable<OA_DeliverPlanPaiche>().Includes(x => x.Driver).Includes(x => x.SentStaff).Includes(x=>x.DeliverPlans)
                .Where(SearchList).OrderBy(x => x.DeliverTime).OrderBy(x => x.Sort).ToPageListAsync(Param.page.PageIndex, Param.page.PageSize, totle);
            var data = await _client.Queryable<OA_DeliverPlanPaiche>().Includes(x => x.Car,car=>car.Staff).Includes(x => x.SentStaff).Includes(x=>x.DeliverPlans)
                .Where(SearchList).OrderBy(x => x.DeliverTime).OrderBy(x => x.Sort).Mapper(x =>
                {
                    if (x.Car?.Staff != null)
                    {
                        x.Car.CarNumber = x.Car.CarNumber + "(" + x.Car.Staff.Name + ")";
                        x.Car.Staff = null;
                    }
                }).ToPageListAsync(Param.page.PageIndex, Param.page.PageSize, totle);
            Param.page.TotalCount = totle;
            return new DeliverOderPageRet
@@ -405,11 +416,41 @@
            data.LastUpdateTime = DateTime.Now;
            data.Updater = Permissions.MemberId;
            if (data.DriverId != Param.DriverId)
            //以车辆选择为主 ,不在实现司机逻辑
            //if (data.DriverId != Param.DriverId)
            //{
            //    data.DriverId = Param.DriverId;
            //    var car = await _client.Queryable<OA_CarManage>().Where(x => x.StaffID == Param.DriverId && x.MemberID == _oAServices.firmId).FirstAsync();
            //    data.CarId = car == null ? 0 : car.Keyid;
            //    //foreach (var item in data.DeliverPlans)
            //    //{
            //    //    item.DriverId = Param.DriverId;
            //    //    item.CarId = car == null ? 0 : car.Keyid;
            //    //    item.Updater = Permissions.MemberId;
            //    //    item.LastUpdateTime = DateTime.Now;
            //    //    item.DeliverTime = Param.DeliverTime;
            //    //}
            //}
            if (data.CarId != Param.CarId)
            {
                data.DriverId = Param.DriverId;
                var car = await _client.Queryable<OA_CarManage>().Where(x => x.StaffID == Param.DriverId && x.MemberID == _oAServices.firmId).FirstAsync();
                data.CarId = car == null ? 0 : car.Keyid;
                var car = await _client.Queryable<OA_CarManage>().Where(x => x.Keyid == Param.CarId && x.MemberID == _oAServices.firmId).Includes(x=>x.Staff).FirstAsync();
                if(car == null)
                {
                    throw Oops.Oh("没有找到有效车辆信息");
                }
                data.CarId = Param.CarId;
                if (car.Staff != null)
                {
                    data.DriverId = car.Staff.Keyid;
                }
                else
                    data.DriverId = 0;
                //data.CarId = car == null ? 0 : car.Keyid;
                //foreach (var item in data.DeliverPlans)
                //{
@@ -422,7 +463,6 @@
                //}
            }
            data.DeliverTime = Param.DeliverTime;
            data.Remark = Param.Remark;
@@ -487,6 +527,7 @@
                            foreach (var item in data.DeliverPlans)
                            {
                                item.DriverId = 0;
                                item.CarId = 0;
                                item.DeliverPlanPaicheid = Guid.Empty;
                                item.Deliveredstatus = DeliveredType.Undeliver;                                
                                item.Updater = Permissions.MemberId;
@@ -558,8 +599,15 @@
            {
                throw Oops.Oh("没有权限");
            }
            return await _client.Queryable<OA_DeliverPlanPaiche>().Includes(x => x.Attachments).Includes(x => x.Driver).Includes(x => x.Manager).Includes(x=>x.DeliverPlans)
                .Where(x => x.Keyid == KeyId && x.ShifouDelivery != 2).FirstAsync();
            return await _client.Queryable<OA_DeliverPlanPaiche>().Includes(x => x.Attachments).Includes(x => x.Car, car => car.Staff).Includes(x => x.Manager).Includes(x=>x.DeliverPlans)
                .Where(x => x.Keyid == KeyId && x.ShifouDelivery != 2).Mapper(x=>
                {
                     if(x.Car?.Staff!=null)
                    {
                        x.Car.CarNumber = x.Car.CarNumber + "(" + x.Car.Staff.Name + ")";
                        x.Car.Staff = null;
                    }
                }).FirstAsync();
        }
@@ -745,7 +793,10 @@
        /// 司机KeyID
        /// </summary>
        public int? DeliverKeyID { get; set; }
        /// <summary>
        /// 车辆的keyid
        /// </summary>
        public int? CarId { get; set; }
        /// <summary>
        /// 客户名称
@@ -756,6 +807,11 @@
        /// 配送状态
        /// </summary>
        public DeliveredType? DeliveredState { get; set; }
        /// <summary>
        /// 问题反馈的是否完结状态
        /// </summary>
        public WanjieStatusType? WanjieStatus { get; set; }
        /// <summary>
        /// 页面参数
        /// </summary>