From 757e9a10418043eb1a5c5e41975d3eb39db66a80 Mon Sep 17 00:00:00 2001
From: 移动系统liao <liaoxujun@qq.com>
Date: 星期五, 20 六月 2025 14:27:04 +0800
Subject: [PATCH] no message

---
 cylsg/cylsg.Application/CyOS/CyOsDeliverManage.cs |  213 ++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 162 insertions(+), 51 deletions(-)

diff --git a/cylsg/cylsg.Application/CyOS/CyOsDeliverManage.cs b/cylsg/cylsg.Application/CyOS/CyOsDeliverManage.cs
index 2389bff..ecaad95 100644
--- a/cylsg/cylsg.Application/CyOS/CyOsDeliverManage.cs
+++ b/cylsg/cylsg.Application/CyOS/CyOsDeliverManage.cs
@@ -13,6 +13,7 @@
 using System.Text;
 using System.Threading.Tasks;
 using TencentCloud.Iecp.V20210914.Models;
+using TencentCloud.Monitor.V20180724.Models;
 
 namespace cylsg.Application.CyOS
 {
@@ -34,32 +35,92 @@
             _oAServices = oAServices;
             _eZCoreNetRedisService = netRedisService;
         }
-        [HttpGet]
-        [AllowAnonymous]
-        public async Task<OA_DriverRecord> testc()
-        {
-            OA_DriverRecord data = null;
+        //[HttpGet]
+        //[AllowAnonymous]
+        //public async Task<bool > TestCreat()
+        //{
+        //    OaWorkPlan pram = new OaWorkPlan()
+        //    {
 
-            data = await _client.Queryable<OA_DriverRecord>().Where(x =>
-             x.Id == new Guid("BE15D584-DFE3-438D-863B-705DB1AB14ED")
-           ).Includes(x=>x.Attachments).FirstAsync();
-          
-            data.Attachments?.Add(new OA_attachment
-            {
-                PlanAttachment = "1111",
-                AttachmentType = 4,
-                Operator= "sdasd"
-            });
-            data.CarConditionAttachments = null;
-            await _client.UpdateNav(data).Include(x => x.CarConditionAttachments,new UpdateNavOptions
-            {
-                OneToManyInsertOrUpdate=true,
-                 
-            }).ExecuteCommandAsync();
+        //        EvaluationContent = "",
+        //        PlanDataType = 17,
+        //        PlanType = 3,
+        //        MemberId = _oAServices.firmId,
+        //        SentStaffId = Guid.Empty,
+        //        ReciveStaffId = Guid.Empty,
+        //        DepartId = 0,
+        //        PlanStartTime = DateTime.Now,
+        //        RewardContent = "",
+        //        LastUpdateTime = DateTime.Now,
+        //        Operator = "",
+        //        PlanTitle = "",
+        //        PlanRunTime = DateTime.Now,
+        //        PlanRemark = "",
+        //        PlanPeople = "娴嬭瘯娴嬭瘯",
+        //        PlanComplany = "",
+        //        PlanStatus = PlanStatusType.unApproval,
+        //        ApprovalStaffId = Guid.Empty,
+        //        ApprovalStatus = PlanStatusType.unApproval,
+        //        EvaluationStatus = BaoxiaoStausType.Unknown,
+        //        FirmAccountId = 0,
+        //        HoubufapiaoStatus = HoubufapiaoStatusType.Unknown,
+        //        PlanMoney = 200,
+        //        PlanContent = "娴嬭瘯鎵归噺",
+        //        RewardResult = "10",
 
-            return await _client.Queryable<OA_DriverRecord>().Where(x => x.Id == new Guid("BE15D584-DFE3-438D-863B-705DB1AB14ED")).Includes(x => x.Attachments).Includes(x => x.CarConditionAttachments).FirstAsync();
+        //        ApprovalTime = DateTime.Now,
+        //        ApprovalContent = "",
+        //        EvaluationStaffId = Guid.Empty,
+        //        EvaluationTime = DateTime.Now,
+        //        RewardMoney = 0,
+        //        RewardType = 1,
+        //        Keyid = null,
+        //        WorkPlanAttachments = new List<OaWorkPlanAttachment>()
+        //        {
+        //             new OaWorkPlanAttachment
+        //             {
+        //                  AttachmentType=1,
+        //                   CreateTime=DateTime.Now,
+        //                    Operator="123213",
+        //                     PlanAttachment="hhttp://1.jpg"
+        //             },
+        //              new OaWorkPlanAttachment
+        //             {
+        //                  AttachmentType=1,
+        //                   CreateTime=DateTime.Now,
+        //                    Operator="123213",
+        //                     PlanAttachment="hhttp://2.jpg"
+        //             }
+        //              ,
+        //              new OaWorkPlanAttachment
+        //             {
+        //                  AttachmentType=4,
+        //                   CreateTime=DateTime.Now,
+        //                    Operator="123213",
+        //                     PlanAttachment="hhttp://2.jpg"
+        //             }
+        //        }
+               
 
-        }
+        //    };
+        //    return await _client.InsertNav(pram).Include(x => x.WorkPlanAttachments).ExecuteCommandAsync();
+
+
+
+        //}
+
+        ///// <summary>
+        ///// 
+        ///// </summary>
+        ///// <returns></returns>
+        //[HttpGet]
+        //[AllowAnonymous]
+        //public async Task<OA_DriverRecord> TestUpdata()
+        //{
+
+
+
+        //}
 
         /// <summary>
         /// 鑾峰彇棰勭害閰嶉�佷俊鎭�
@@ -201,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;
@@ -226,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,
@@ -279,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))
@@ -311,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
@@ -344,24 +416,53 @@
             data.LastUpdateTime = DateTime.Now;
             data.Updater = Permissions.MemberId;
 
-            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;
+            //浠ヨ溅杈嗛�夋嫨涓轰富 锛屼笉鍦ㄥ疄鐜板徃鏈洪�昏緫
+            //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)
+            //    //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)
+            {
+               
+                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)
                 {
-                    item.DriverId = Param.DriverId;
-                    item.CarId = car == null ? 0 : car.Keyid;
-                    item.Updater = Permissions.MemberId;
-                    item.LastUpdateTime = DateTime.Now;
-                    item.DeliverTime = Param.DeliverTime;
+                    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)
+                //{
+                //    item.DriverId = Param.DriverId;
+                //    item.CarId = car == null ? 0 : car.Keyid;
+                //    item.Updater = Permissions.MemberId;
+                //    item.LastUpdateTime = DateTime.Now;
+                //    item.DeliverTime = Param.DeliverTime;
+
+                //}
             }
 
-   
             data.DeliverTime = Param.DeliverTime;
             data.Remark = Param.Remark;
 
@@ -386,13 +487,7 @@
                 }
             data.Attachments = Param.Attachments;
 
-            return await _client.UpdateNav(data).Include(x => x.Attachments, new UpdateNavOptions()
-            {
-                OneToManyInsertOrUpdate = true,
-            }).Include(x => x.DeliverPlans, new UpdateNavOptions()
-            {
-                OneToManyInsertOrUpdate = true,
-            }).ExecuteCommandAsync();
+            return await _client.UpdateNav(data).Include(x => x.Attachments).ExecuteCommandAsync();
 
 
 
@@ -432,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;
@@ -503,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();
 
         }
 
@@ -690,7 +793,10 @@
         /// 鍙告満KeyID
         /// </summary>
         public int? DeliverKeyID { get; set; }
-
+        /// <summary>
+        /// 杞﹁締鐨刱eyid
+        /// </summary>
+        public int? CarId { get; set; }
 
         /// <summary>
         /// 瀹㈡埛鍚嶇О
@@ -701,6 +807,11 @@
         /// 閰嶉�佺姸鎬�
         /// </summary>
         public DeliveredType? DeliveredState { get; set; }
+
+        /// <summary>
+        /// 闂鍙嶉鐨勬槸鍚﹀畬缁撶姸鎬�
+        /// </summary>
+        public WanjieStatusType? WanjieStatus { get; set; }
         /// <summary>
         /// 椤甸潰鍙傛暟
         /// </summary>

--
Gitblit v1.9.1