| | |
| | | /// 报销主管相关控制器 |
| | | /// </summary> |
| | | [Authorize] |
| | | [ApiDescriptionSettings("CYOA")] |
| | | public class CyOSBaoXiaoZHuGuanController: IDynamicApiController |
| | | { |
| | | private readonly IOAServices _OAServices; |
| | |
| | | _OAServices = oaservices; |
| | | _SugarClient = sugarClient.AsTenant().GetConnection("ECTESTOADB"); |
| | | } |
| | | /// <summary> |
| | | /// 查询 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | [AllowAnonymous] |
| | | public async Task<List<OaWorkPlan>> gettest() |
| | | { |
| | | var datal = await _SugarClient.Queryable<OaWorkPlan>().Where(x=>x.PlanType==3&&x.PlanDataType==17) |
| | | .Select(x => new OaWorkPlan |
| | | { |
| | | OaWorkPlanShenpi = SqlFunc.Subqueryable<OaWorkPlanShenpi>().Where(y => y.OA_WorkPlanId == x.Keyid).First() |
| | | }, true).MergeTable() |
| | | .OrderBy(z => z.OaWorkPlanShenpi.ApprovalTime).ToListAsync(); |
| | | return datal; |
| | | var data2 = await _SugarClient.Queryable<OaWorkPlan>() |
| | | .Select(x => new OaWorkPlan |
| | | { |
| | | SentStaff = SqlFunc.Subqueryable<OaStaff>().Where(y => y.MemberId == x.SentStaffId).First() |
| | | }, true).MergeTable() |
| | | .OrderBy(y => y.SentStaff.MemberId).ToListAsync(); |
| | | |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 查询 |
| | | /// </summary> |
| | |
| | | Expression<Func<OaWorkPlan, bool>> SearchList = (x) => true; |
| | | |
| | | //川印工作单 |
| | | SearchList = SearchList.And(x => x.ApprovalStatus != PlanStatusType.Uncommitted); |
| | | SearchList = SearchList.And(x => x.MemberId == _OAServices.firmId); |
| | | SearchList = SearchList.And(x => x.PlanType == 3); |
| | | SearchList = SearchList.And(x => x.PlanDataType == 17); |
| | | //SearchList = SearchList.And(x => x.ApprovalStatus == PlanStatusType.unApproval); |
| | | //SearchList = SearchList.And(x => x.OaWorkPlanShenpis.Where(y => y.Buzhou == 1 && y.ApprovalStaffId == Permissions.MemberId).Count()<=0); |
| | | SearchList = SearchList.And(x => x.DepartId == Permissions.DepartId); |
| | | //SearchList = SearchList.And(x => x.DepartId == Permissions.DepartId); 部门筛选 |
| | | if (!string.IsNullOrEmpty(param.StaffName)) |
| | | { |
| | | SearchList = SearchList.And(x => x.SentStaff.Name.Contains(param.StaffName)); |
| | |
| | | RefAsync<int> totle = 0; |
| | | |
| | | //强制增加员工过滤 |
| | | |
| | | |
| | | var data = await _SugarClient.Queryable<OaWorkPlan>().Includes(x=>x.Depart) |
| | | .Includes(x=>x.OaWorkPlanShenpis.Where(y=>y.ApprovalStaffId==Permissions.MemberId&&y.Buzhou==1).ToList()) |
| | | .Where(SearchList).OrderByDescending(x => x.PlanStartTime).Mapper( |
| | |
| | | { |
| | | throw Oops.Oh("没有权限"); |
| | | } |
| | | return await _SugarClient.Queryable<OaWorkPlan>().Includes(x => x.OaWorkPlanShenpis.Where(y => y.Buzhou == 1).ToList(), y => y.ApprovalStaff).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.OaWorkPlanShenpis.Where(y => y.Buzhou == 1).ToList(), y => y.ApprovalStaff).Includes(x => x.SentStaff).Includes(x => x.Depart).Includes(x => x.WorkPlanAttachments).Where(x=>x.Keyid==id).Mapper(x=> |
| | | { |
| | | if (x.ApprovalStatus == PlanStatusType.unApproval) |
| | | { |
| | | var oashenpi = x.OaWorkPlanShenpis?.Where(x=>x.ApprovalStaffId==Permissions.MemberId).FirstOrDefault(); |
| | | if (oashenpi != null) |
| | | x.ApprovalStatus = oashenpi.ApprovalStatus; |
| | | |
| | | |
| | | } |
| | | ; |
| | | }).FirstAsync(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | throw Oops.Oh("没有找到报销单"); |
| | | if (data.ApprovalStatus != null && data.ApprovalStatus != PlanStatusType.unApproval) |
| | | throw Oops.Oh("报销单已经批复完毕"); |
| | | if(data.ApprovalStatus== PlanStatusType.Uncommitted) |
| | | { |
| | | throw Oops.Oh("报销单未提交不可审批"); |
| | | } |
| | | OaWorkPlanShenpi shenpi = data.OaWorkPlanShenpis.Where(x => x.ApprovalStaffId == Permissions.MemberId&&x.Buzhou==1).FirstOrDefault(); |
| | | if (shenpi!=null) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | await _SugarClient.AsTenant().BeginTranAsync(); |
| | | |
| | | |
| | | data.RewardResult = param.RewardResult; |
| | | data.PlanContent = param.PlanContent; |
| | | if (param.PlanMoney > 0 && param.PlanMoney <= data.PlanMoney) |
| | | data.PlanMoney = param.PlanMoney; |
| | | |
| | | await _SugarClient.AsTenant().BeginTranAsync(); |
| | | try |
| | | { |
| | | if (param.ApprovalStatus == PlanStatusType.No) |