From 7eca0ab1b6d5142d623efd471985b2a20b559616 Mon Sep 17 00:00:00 2001
From: 小飞侠 <8277136+liaoxujun@user.noreply.gitee.com>
Date: 星期一, 01 十二月 2025 10:55:02 +0800
Subject: [PATCH] 修正审批备注长度

---
 cylsg/cylsg.Application/CyOS/CyOSBaoXiaoZHuGuanController.cs |   79 +++++++++++++++++++++++++++++++++++----
 1 files changed, 71 insertions(+), 8 deletions(-)

diff --git a/cylsg/cylsg.Application/CyOS/CyOSBaoXiaoZHuGuanController.cs b/cylsg/cylsg.Application/CyOS/CyOSBaoXiaoZHuGuanController.cs
index d255339..103387b 100644
--- a/cylsg/cylsg.Application/CyOS/CyOSBaoXiaoZHuGuanController.cs
+++ b/cylsg/cylsg.Application/CyOS/CyOSBaoXiaoZHuGuanController.cs
@@ -2,6 +2,7 @@
 using cylsg.Model.utilityViewModel;
 using ECTESTOA;
 using Furion.LinqBuilder;
+using Models;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -15,6 +16,7 @@
     /// 鎶ラ攢涓荤鐩稿叧鎺у埗鍣�
     /// </summary>
     [Authorize]
+    [ApiDescriptionSettings("CYOA")]
     public class CyOSBaoXiaoZHuGuanController: IDynamicApiController
     {
         private readonly IOAServices _OAServices;
@@ -25,8 +27,29 @@
             _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>
@@ -41,12 +64,14 @@
             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.OaWorkPlanShenpis.Count(y => y.Buzhou == 1&& y.ApprovalStaffId != Permissions.MemberId) < 2);//鍙渶瑕佷袱涓汉瀹℃壒 鍙﹀涓や釜浜哄鎵逛簡锛屼笉鍦ㄦ樉绀�
+            //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); 閮ㄩ棬绛涢��
             if (!string.IsNullOrEmpty(param.StaffName))
             {
                 SearchList = SearchList.And(x => x.SentStaff.Name.Contains(param.StaffName));
@@ -90,9 +115,9 @@
             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())
+                    .Includes(x=>x.OaWorkPlanShenpis.Where(y=>y.Buzhou==1).ToList())
                     .Where(SearchList).OrderByDescending(x => x.PlanStartTime).Mapper(
                     x =>
                     {
@@ -135,7 +160,18 @@
             {
                 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>
@@ -157,6 +193,17 @@
                 throw Oops.Oh("娌℃湁鎵惧埌鎶ラ攢鍗�");
             if (data.ApprovalStatus != null && data.ApprovalStatus != PlanStatusType.unApproval)
                 throw Oops.Oh("鎶ラ攢鍗曞凡缁忔壒澶嶅畬姣�");
+            if(data.ApprovalStatus== PlanStatusType.Uncommitted)
+            {
+                throw Oops.Oh("鎶ラ攢鍗曟湭鎻愪氦涓嶅彲瀹℃壒");
+            }
+            int shenpiCount = data.OaWorkPlanShenpis.Where(x => x.ApprovalStaffId != Permissions.MemberId && x.Buzhou == 1).Count();
+            if(shenpiCount >= 2)
+            {
+                //涓や釜浜哄鎵瑰悗銆備笉鍙啀瀹℃壒
+                throw Oops.Oh("宸茬粡宸茬粡缁撴潫");
+
+            }
             OaWorkPlanShenpi shenpi = data.OaWorkPlanShenpis.Where(x => x.ApprovalStaffId == Permissions.MemberId&&x.Buzhou==1).FirstOrDefault();
              if (shenpi!=null)
             {
@@ -167,7 +214,14 @@
             }
              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)
@@ -179,6 +233,15 @@
                         data.Operator = Permissions.Name;
                        await  _SugarClient.Updateable(data).ExecuteCommandAsync();
 
+                        //璁剧疆璁惧weixiu鐘舵�佷负鎷掔粷
+                        var shenpis = await _SugarClient.Queryable<OA_ShebeiWeixiu>().Where(x => x.FukuanShebeiId == data.Keyid).FirstAsync();
+                        if (shenpis != null)
+                        {
+                            shenpis.ApprovalStatus = (int )PlanStatusType.No;
+
+                            await _SugarClient.Updateable(shenpis).ExecuteCommandAsync();
+                        }
+
                     }
 
                     shenpi = new OaWorkPlanShenpi()

--
Gitblit v1.9.1