移动系统liao
2025-03-19 16b063870156db78148440971ab46c649e3e6018
cylsg/cylsg.Application/CyOS/CyOSStaffController.cs
@@ -7,6 +7,8 @@
using ECTESTOA;
using EzCoreNet.Redis;
using Furion.LinqBuilder;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -22,6 +24,7 @@
    /// 川印普通员工控制器
    /// </summary>
    [Authorize]
    [ApiDescriptionSettings("CYOA")]
    public class CyOSStaffController : IDynamicApiController
    {
        private readonly IOAServices _OAServices;
@@ -42,6 +45,7 @@
        [HttpPost]
        public async Task<WorekPlandto> getplanelist(SearchOaWorekPlan param)
        {
            if(! await CheckRols())
            {
                throw Oops.Oh("没有权限");
@@ -195,13 +199,7 @@
            pram.EvaluationTime = DateTime.Now;     
            pram.RewardMoney = 0;
            pram.RewardType = 1;
            pram.Keyid = null;
            await  _SugarClient.InsertNav(pram).Include(x=>x.WorkPlanAttachments).ExecuteCommandAsync();
            return true;
            
@@ -307,7 +305,7 @@
        }
        /// <summary>
        /// 获取详情
        /// 获取财务申请单详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
@@ -318,12 +316,11 @@
            {
                throw Oops.Oh("没有权限");
            }
            return await _SugarClient.Queryable<OaWorkPlan>().Includes(x=>x.SentStaff).Includes(x=>x.Depart).Includes(x=>x.WorkPlanAttachments).Where(x => x.Keyid == id).FirstAsync();
            return await _SugarClient.Queryable<OaWorkPlan>().Includes(x=>x.SentStaff).Includes(x => x.OaWorkPlanShenpis,y=>y.ApprovalStaff).Includes(x=>x.Depart).Includes(x=>x.WorkPlanAttachments).Where(x => x.Keyid == id).FirstAsync();
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="pram"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<bool> DelOderAsync(int id )
@@ -349,6 +346,228 @@
            return true;
        }
        /// <summary>
        /// 获取预约配送信息
        /// </summary>
        /// <param name="Param"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<AppointmentDeliverRet> GetListAppointmentDeliverList(ApoointmentDeliverSearchParam Param)
        {
            if (!await CheckRols())
            {
                throw Oops.Oh("没有权限");
            }
            Expression<Func<OA_DeliverTixing, bool>> SearchList = (x) => true;
            SearchList = SearchList.And(x => x.FirmId == _OAServices.firmId);
            SearchList = SearchList.And(x => x.Creater == Permissions.MemberId);
            if (!string.IsNullOrEmpty(Param.Content))
            {
                SearchList = SearchList.And(x => x.Remark.Contains(Param.Content));
            }
            if (Param.MemberId != null)
            {
                SearchList = SearchList.And(x => x.FirmId == Param.MemberId);
            }
            if (Param.TimeStart !=null)
            {
                SearchList = SearchList.And(x => x.CreateTime> Param.TimeStart);
            }
            if (Param.TimeEnd != null)
            {
                SearchList = SearchList.And(x => x.CreateTime < Param.TimeEnd.Value.AddDays(1));
            }
            if (Param.DeliverState != null)
            {
                SearchList = SearchList.And(x => x.Chulistatus == Param.DeliverState);
            }
            //强制增加员工过滤
            RefAsync<int> totle = 0;
            var data = await _SugarClient.Queryable<OA_DeliverTixing>()
                .Where(SearchList).OrderByDescending(x => x.ChuliTime).ToPageListAsync(Param.page.PageIndex, Param.page.PageSize, totle);
            Param.page.TotalCount = totle;
            return new AppointmentDeliverRet
            {
                Data = data,
                page= Param.page,
            };
        }
        /// <summary>
        /// 创建一个预约配送
        /// </summary>
        /// <param name="Param"></param>
        /// <returns></returns>
        [LimitFilter(LimiType = Limttype.User,timespan =5,ResponseMeg ="请勿在5内重复请求",InCount =1)]
        public async Task<int> CreatAppointmentDeliver(OA_DeliverTixing Param)
        {
           if(  string.IsNullOrEmpty(Param.Remark))
                 throw Oops.Oh("内容必填");
            if (!await CheckRols())
            {
                throw Oops.Oh("没有权限");
            }
            Param.FirmId = _OAServices.firmId;
            Param.CreateTime = DateTime.Now;
            Param.Creater = Permissions.MemberId;
            Param.Chulistatus = AppointmentDeliverState.unAccept;
         return  await   _SugarClient.Insertable(Param).ExecuteCommandAsync();
        }
        /// <summary>
        /// 修改预约提醒
        /// </summary>
        /// <param name="Param"></param>
        /// <returns></returns>
        public async Task<int> UpDataAppointmentDeliver(OA_DeliverTixing Param)
        {
          if(  Param.Chulistatus== AppointmentDeliverState.Accept)
                throw Oops.Oh("状态不可修改为受理状态");
            if (!(Param.Keyid>0))
                throw Oops.Oh("Keyid不能为空");
            if (string.IsNullOrEmpty(Param.Remark))
                throw Oops.Oh("内容必填");
            if (!await CheckRols())
            {
                throw Oops.Oh("没有权限");
            }
            var data= await   _SugarClient.Queryable<OA_DeliverTixing>().Where(x => x.Keyid == Param.Keyid&&x.FirmId==_OAServices.firmId&&x.Creater==Permissions.MemberId).FirstAsync();
            if (data == null)
                throw Oops.Oh("没找到数据");
            if(data.Chulistatus == AppointmentDeliverState.Accept)
                throw Oops.Oh("已受理状态不可修改");
            if (data.Remark!=Param.Remark)
            {
                data.Remark = Param.Remark;
                data.LastUpdateTime = DateTime.Now;
                data.Updater = Permissions.MemberId;
                return await _SugarClient.Updateable(data).ExecuteCommandAsync();
            }
            return 1;
        }
        /// <summary>
        /// 删除预约提醒
        /// </summary>
        /// <param name="Param"></param>
        /// <returns></returns>
        public async Task<int> DelAppointmentDeliver(OA_DeliverTixing Param)
        {
            if (!(Param.Keyid > 0))
                throw Oops.Oh("Keyid不能为空");
            if (!await CheckRols())
            {
                throw Oops.Oh("没有权限");
            }
            var data = await _SugarClient.Queryable<OA_DeliverTixing>().Where(x => x.Keyid == Param.Keyid && x.Creater == Permissions.MemberId&&x.FirmId==_OAServices.firmId).FirstAsync();
            if (data == null)
                throw Oops.Oh("没找到数据或者没有权限");
          if(  data.Chulistatus!= AppointmentDeliverState.unAccept)
               throw Oops.Oh("已受理状态不可删除");
            return await _SugarClient.Deleteable(data).ExecuteCommandAsync();
        }
        /// <summary>
        /// 获取送货单
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<DeliverOderPageRet>  GetDeliverPlans(DeliverPlanSearchParam Param)
        {
            if (!await CheckRols())
            {
                throw Oops.Oh("没有权限");
            }
            Expression<Func<OA_DeliverPlanPaiche, bool>> SearchList = (x) => true;
            SearchList = SearchList.And(x => x.FirmId == _OAServices.firmId);
            SearchList = SearchList.And(x => x.BusinessManagerId == Permissions.KeyId);//只看自己 客户经理是自己
            SearchList = SearchList.And(x => x.ShifouDelivery !=2);//过滤有效
            if (Param.DeliverKeyID!=null)
            {
                SearchList = SearchList.And(x => x.DriverId == Param.DeliverKeyID);
            }
            //客户名称
            if (!string.IsNullOrEmpty(Param.CorporateClient))
            {
                SearchList = SearchList.And(x => x.CompanyName.Contains(Param.CorporateClient));
            }
            if (Param.TimeStart != null)
            {
                SearchList = SearchList.And(x => x.DeliverTime >= Param.TimeStart.Value.Date);
            }
            if (Param.TimeEnd != null)
            {
                SearchList = SearchList.And(x => x.DeliverTime < Param.TimeEnd.Value.Date.AddDays(1));
            }
            if (Param.DeliveredState != null)
            {
                if (Param.DeliveredState != DeliveredType.Delivered)
                {
                    SearchList = SearchList.And(x => x.Deliveredstatus != DeliveredType.Delivered);
                }
                else
                {
                    SearchList = SearchList.And(x => x.Deliveredstatus == DeliveredType.Delivered);
                }
            }
            //强制增加员工过滤
            RefAsync<int> totle = 0;
            var data = await _SugarClient.Queryable<OA_DeliverPlanPaiche>().Includes(x => x.Driver).Includes(x=>x.DeliverPlans)
                .Where(SearchList).OrderByDescending(x => x.CreateTime.Value.Date).OrderBy(x=>SqlFunc.Asc(x.Sort)).ToPageListAsync(Param.page.PageIndex, Param.page.PageSize, totle);
            Param.page.TotalCount = totle;
            return new DeliverOderPageRet
            {
                Data = data,
                page = Param.page,
            };
        }
        /// <summary>
        /// 获取送货单详情
        /// </summary>
        /// <param name="KeyId"></param>
        /// <returns></returns>
        public async Task<OA_DeliverPlanPaiche> GetDeliverPlanInfo(Guid KeyId)
        {
            if (!await CheckRols())
            {
                throw Oops.Oh("没有权限");
            }
            return await _SugarClient.Queryable<OA_DeliverPlanPaiche>().Includes(x => x.Attachments).Includes(x=>x.Driver).Includes(x=>x.DeliverPlans)
                .Where(x => x.BusinessManagerId == Permissions.KeyId && x.Keyid == KeyId && x.ShifouDelivery != 2).FirstAsync();
        }
        /// <summary>
        /// 判断是否具有权限
@@ -433,4 +652,38 @@
        public decimal TotalMoney { get; set; } = 0;
    }
    /// <summary>
    /// 配送预约
    /// </summary>
    public class AppointmentDeliverRet
    {
        /// <summary>
        /// 数据列表
        /// </summary>
        public List<OA_DeliverTixing> Data { get; set; }
        /// <summary>
        /// 页面参数
        /// </summary>
        public PageModel page { get; set; }
    }
    /// <summary>
    /// 配送单数据返回
    /// </summary>
    public class DeliverOderPageRet
    {
        /// <summary>
        /// 数据列表
        /// </summary>
        public List<OA_DeliverPlanPaiche> Data { get; set; }
        /// <summary>
        /// 页面参数
        /// </summary>
        public PageModel page { get; set; }
    }
}