From a247547df86f0fad8f03aebb91de68d3f2bc7918 Mon Sep 17 00:00:00 2001 From: 移动系统liao <liaoxujun@qq.com> Date: 星期四, 01 五月 2025 10:16:52 +0800 Subject: [PATCH] 修正sugsql导航更新加配置的bug --- cylsg/cylsg.Application/CyOS/CyOsDeliverManage.cs | 345 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 313 insertions(+), 32 deletions(-) diff --git a/cylsg/cylsg.Application/CyOS/CyOsDeliverManage.cs b/cylsg/cylsg.Application/CyOS/CyOsDeliverManage.cs index b330891..deda07e 100644 --- a/cylsg/cylsg.Application/CyOS/CyOsDeliverManage.cs +++ b/cylsg/cylsg.Application/CyOS/CyOsDeliverManage.cs @@ -5,12 +5,15 @@ using EzCoreNet.Redis; using Furion.LinqBuilder; using Models; +using StackExchange.Profiling; using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; +using TencentCloud.Iecp.V20210914.Models; +using TencentCloud.Monitor.V20180724.Models; namespace cylsg.Application.CyOS { @@ -32,12 +35,92 @@ _oAServices = oAServices; _eZCoreNetRedisService = netRedisService; } - [HttpGet] - [AllowAnonymous] - public async Task<string> testc() - { - return await CreatDeliverPlanSn(); - } + //[HttpGet] + //[AllowAnonymous] + //public async Task<bool > TestCreat() + //{ + // OaWorkPlan pram = new OaWorkPlan() + // { + + // 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", + + // 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> /// 鑾峰彇棰勭害閰嶉�佷俊鎭� @@ -114,12 +197,14 @@ } /// <summary> - /// 鍙楃悊 + /// 鍙楃悊 寮冪敤锛岀敤 CreatDeliverPlan 浠f浛 /// </summary> /// <param name="Param"></param> /// <returns></returns> + [Obsolete] public async Task<int> AcceptAppointmentDeliver(int KeiId) { + throw Oops.Oh("宸茬粡鍚敤"); if (!(KeiId > 0)) throw Oops.Oh("Keyid涓嶈兘涓虹┖"); @@ -150,20 +235,41 @@ /// <param name="Param"> 鍙渶瑕佷紶閫�</param> /// <returns></returns> [HttpPost] - public async Task<int> CreatDeliverPlan(OA_DeliverPlan Param) + public async Task<int> CreatDeliverPlan(OA_DeliverPlanPaiche Param) { - 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 (!await CheckRols()) { throw Oops.Oh("娌℃湁鏉冮檺"); } + OA_DeliverTixing? tixing=null; + if(Param.DeliverTixingId>0) + { + //鏄彁閱掕鍗曪紝闇�瑕佹墽琛屾彁閱掑崟 鐘舵�佸共鐓� + tixing = await _client.Queryable<OA_DeliverTixing>().Where(x => x.Keyid == Param.DeliverTixingId).FirstAsync(); + if(tixing == null) + { + throw Oops.Oh("鎻愰啋鍗曚笉瀛樺湪浜�"); + } + if(tixing.Chulistatus != AppointmentDeliverState.unAccept) + throw Oops.Oh("鎻愰啋鍗曞凡缁忓鐞嗕簡"); + tixing.Chulistatus= AppointmentDeliverState.Accept; + tixing.ChuliTime = DateTime.Now; + tixing.ChuliRen=Permissions.MemberId; + tixing.LastUpdateTime = DateTime.Now; + tixing.Updater = Permissions.MemberId; + + } + 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(); + + OA_CorporateClients cor = null; if (Param.BuyerId != null) cor = await _client.Queryable<OA_CorporateClients>().Where(x => x.Keyid == Param.BuyerId).FirstAsync(); - OA_DeliverPlan DeliverPlan = new OA_DeliverPlan() + OA_DeliverPlanPaiche DeliverPlan = new OA_DeliverPlanPaiche() { Keyid = Guid.NewGuid(), FirmId = _oAServices.firmId, @@ -178,7 +284,7 @@ Transferstatus = 1, - Sort = 1, + Sort = Param.Sort, Creater = Param.Creater ?? Permissions.MemberId, CreateTime = DateTime.Now, DriverId = Param.DriverId, @@ -192,7 +298,28 @@ Lianxiren = Param.Lianxiren, Deliveredstatus = (int)DeliveredType.Undeliver, CompanyName = Param.CompanyName, - }; return await _client.Insertable(DeliverPlan).ExecuteCommandAsync(); + + + }; + try + { + + if (tixing!=null) + { + tixing.DeliverPlanPaicheId = DeliverPlan.Keyid; + await _client.Updateable(tixing).ExecuteCommandAsync(); + } + + return await _client.Insertable(DeliverPlan).ExecuteCommandAsync(); + + } + catch (Exception) + { + + throw; + } + + } @@ -210,7 +337,7 @@ throw Oops.Oh("娌℃湁鏉冮檺"); } - Expression<Func<OA_DeliverPlan, bool>> SearchList = (x) => true; + 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);//杩囨护鏈夋晥 @@ -225,11 +352,11 @@ } if (Param.TimeStart != null) { - SearchList = SearchList.And(x => x.DeliverTime > Param.TimeStart); + SearchList = SearchList.And(x => x.DeliverTime >= Param.TimeStart.Value.Date); } if (Param.TimeEnd != null) { - SearchList = SearchList.And(x => x.DeliverTime < Param.TimeEnd.Value.AddDays(1)); + SearchList = SearchList.And(x => x.DeliverTime < Param.TimeEnd.Value.Date.AddDays(1)); } if (Param.DeliveredState != null) { @@ -245,8 +372,8 @@ //寮哄埗澧炲姞鍛樺伐杩囨护 RefAsync<int> totle = 0; - var data = await _client.Queryable<OA_DeliverPlan>().Includes(x => x.Driver).Includes(x => x.SentStaff) - .Where(SearchList).OrderBy(x => x.Dizhi).OrderBy(x => x.Sort).ToPageListAsync(Param.page.PageIndex, Param.page.PageSize, totle); + 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); Param.page.TotalCount = totle; return new DeliverOderPageRet @@ -265,7 +392,7 @@ /// </summary> /// <param name="Param"></param> /// <returns></returns> - public async Task<bool> UpDataDeliverPlans(OA_DeliverPlan Param) + public async Task<bool> UpDataDeliverPlans(OA_DeliverPlanPaiche Param) { if (Param.Keyid == null) @@ -274,16 +401,28 @@ { throw Oops.Oh("娌℃湁鏉冮檺"); } - var data = await _client.Queryable<OA_DeliverPlan>().Where(x => x.ShifouDelivery != 2 && x.Keyid == Param.Keyid).FirstAsync(); + var data = await _client.Queryable<OA_DeliverPlanPaiche>().Includes(x=>x.DeliverPlans).Where(x => x.ShifouDelivery != 2 && x.Keyid == Param.Keyid).FirstAsync(); 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; + + //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; @@ -308,25 +447,88 @@ } data.Attachments = Param.Attachments; - return await _client.UpdateNav(data).Include(x => x.Attachments, new UpdateNavOptions() - { - OneToManyInsertOrUpdate = true, - }).ExecuteCommandAsync(); + return await _client.UpdateNav(data).Include(x => x.Attachments).ExecuteCommandAsync(); } - /// <summary> - /// 淇敼璁㈠崟 + /// 鎾ら攢璁㈠崟 + /// </summary> + /// <param name="KeyId"></param> + /// <returns></returns> + public async Task<int > UndoDeliverPlans(Guid KeyId) + { + if (!await CheckRols()) + { + throw Oops.Oh("娌℃湁鏉冮檺"); + } + var data= await _client.Queryable<OA_DeliverPlanPaiche>().Includes(x=>x.DeliverPlans).Includes(x=>x.DelvceTiXing).Where(x=>x.Keyid == KeyId).FirstAsync(); + + if (data != null) + { + if (data.Deliveredstatus != DeliveredType.Delivered) + { + await _client.AsTenant().BeginTranAsync(); + try + { + if (data.DelvceTiXing != null) + { + data.DelvceTiXing.Chulistatus = AppointmentDeliverState.unAccept; + data.DelvceTiXing.LastUpdateTime = DateTime.Now; + data.DelvceTiXing.Updater = Permissions.MemberId; + data.DelvceTiXing.ChuliTime = DateTime.Now; + data.DelvceTiXing.ChuliRen = Permissions.MemberId; + await _client.Updateable(data.DelvceTiXing).ExecuteCommandAsync(); + } + if (data.DeliverPlans != null) + { + foreach (var item in data.DeliverPlans) + { + item.DriverId = 0; + item.DeliverPlanPaicheid = Guid.Empty; + item.Deliveredstatus = DeliveredType.Undeliver; + item.Updater = Permissions.MemberId; + item.LastUpdateTime = DateTime.Now; + } + await _client.Updateable(data.DeliverPlans).ExecuteCommandAsync(); + } + + + var a = await _client.Deleteable(data).ExecuteCommandAsync(); + + await _client.AsTenant().CommitTranAsync(); + return a; + } + + + catch (Exception) + { + await _client.AsTenant().RollbackTranAsync(); + throw; + } + } + else + + { + throw Oops.Oh("閰嶉�佸凡瀹屾垚锛屾棤娉曟挙閿�"); + } + + } + else + throw Oops.Oh("娌℃湁鎵惧埌璁㈠崟"); + } + /// <summary> + /// 淇敼璁㈠崟 寮冪敤 /// </summary> /// <param name="Param"></param> /// <returns></returns> + [Obsolete] public async Task<bool> SortDeliverPlans(SortPlanIn Param) { - - + throw Oops.Oh("宸茬粡寮冪敤"); + if (!await CheckRols()) { @@ -349,15 +551,92 @@ /// </summary> /// <param name="KeyId"></param> /// <returns></returns> - public async Task<OA_DeliverPlan> GetDeliverPlanInfo(Guid KeyId) + public async Task<OA_DeliverPlanPaiche> GetDeliverPlanInfo(Guid KeyId) { if (!await CheckRols()) { throw Oops.Oh("娌℃湁鏉冮檺"); } - return await _client.Queryable<OA_DeliverPlan>().Includes(x => x.SentStaff).Includes(x => x.Attachments).Includes(x => x.Driver).Includes(x => x.Manager) + 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(); + + } + + + /// <summary> + /// 鎵撳崱璁板綍璇︽儏 + /// </summary> + public async Task<OA_DriverRecord> GetDriverRecordInfo(Guid Id) + { + + if (!await CheckRols()) + { + throw Oops.Oh("娌℃湁鏉冮檺"); + } + + var data = await _client.Queryable<OA_DriverRecord>() + .Includes(x=>x.Car) + .Includes(x => x.Attachments) + .Includes(x => x.CarConditionAttachments) + .Where(x => x.Id == Id).FirstAsync(); + if (data == null) + throw Oops.Oh("娌℃湁鏉冮檺"); + return data; + + } + /// <summary> + /// 鑾峰彇杞﹁締鎵撳崱璁板綍 + /// </summary> + /// <param name="Param"></param> + /// <returns></returns> + [HttpPost] + public async Task<DeliverRecordPageRet> GetDriverRecords(DeliverRecordSearchParam Param) + { + if (!await CheckRols()) + { + throw Oops.Oh("娌℃湁鏉冮檺"); + } + + Expression<Func<OA_DriverRecord, bool>> SearchList = (x) => true; + SearchList = SearchList.And(x => x.ClockType != DriverClockType.RoughDraft);//涓嶇湅鑽夌 + if (Param.CarID != null) + { + SearchList = SearchList.And(x => x.CarID == Param.CarID); + } + + if (Param.TimeStart != null) + { + SearchList = SearchList.And(x => x.CreatTime >= Param.TimeStart.Value.Date); + } + if (Param.TimeEnd != null) + { + SearchList = SearchList.And(x => x.CreatTime < Param.TimeEnd.Value.Date.AddDays(1)); + } + if (Param.ClockType != null) + { + + SearchList = SearchList.And(x => x.ClockType == Param.ClockType); + + } + + //寮哄埗澧炲姞鍛樺伐杩囨护 + RefAsync<int> totle = 0; + var data = await _client.Queryable<OA_DriverRecord>().Includes(x=>x.Car) + .Where(SearchList).OrderByDescending(x => x.CreatTime.Date).ToPageListAsync(Param.page.PageIndex, Param.page.PageSize, totle); + + Param.page.TotalCount = totle; + // var count = await _client.Queryable<OA_DriverRecord>().Where(x => x.CreatTime.Date == DateTime.Now.Date).CountAsync(); + + return new DeliverRecordPageRet + + { + Data = data, + page = Param.page + + + }; + } /// <summary> @@ -382,6 +661,8 @@ return false; } + + /// <summary> /// 鐢熸垚sn鍙� /// </summary> @@ -390,7 +671,7 @@ { // var sn = await _client.Queryable<OA_DeliverPlan>().Where(x => x.CreateTime >= DateTime.Now.Date && x.CreateTime < DateTime.Now.AddDays(1).Date).OrderByDescending(x => x.SellerOrderId).Select(x => x.SellerOrderId).FirstAsync(); - var sn = await _client.Queryable<OA_DeliverPlan>().Where(x => x.CreateTime.Value.Date == DateTime.Now.Date).OrderByDescending(x => x.SellerOrderId).Select(x => x.SellerOrderId).FirstAsync(); + var sn = await _client.Queryable<OA_DeliverPlanPaiche>().Where(x => x.CreateTime.Value.Date == DateTime.Now.Date).OrderByDescending(x => x.SellerOrderId).Select(x => x.SellerOrderId).FirstAsync(); if (sn != null) { try -- Gitblit v1.9.1