Преглед на файлове

团组管控流程内容更新;
新增Autofac服务调用帮助类AutofacIocManager;
新增Autofac依赖注入管理AutofacRegister;
新增部门Code对照表DepartmentCode;
appsettings.json更新团组流程管控配置信息以及对应实体类GroupsConfig

jiangjc преди 1 година
родител
ревизия
aed0311faa

+ 11 - 2
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -1,5 +1,6 @@
 using Microsoft.AspNetCore.Mvc;
 using Newtonsoft.Json.Serialization;
+using OASystem.API.OAMethodLibs;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Infrastructure.Repositories.Groups;
@@ -44,14 +45,15 @@ namespace OASystem.API.Controllers
             {
                 if (_ScheduleDto.SearchType == 2)//获取列表
                 {
-
+                    List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
+                    return Ok(JsonView(_grpScheduleViewList));
                 }
                 else//获取对象
                 {
                     Grp_ScheduleView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
                     if (_grpScheduleView != null)
                     {
-                        return Ok(JsonView(0, "获取成功", _grpScheduleView));
+                        return Ok(JsonView(_grpScheduleView));
                     }
                 }
             }
@@ -63,6 +65,13 @@ namespace OASystem.API.Controllers
             return Ok(JsonView(false, "暂无数据!"));
         }
 
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public void testGrpSchedule()
+        {
+            GroupStepForDelegation.CreateWorkStep(1228);
+        }
+
         #endregion
 
 

+ 55 - 0
OASystem/OASystem.Api/OAMethodLib/AutofacIocManager.cs

@@ -0,0 +1,55 @@
+using Autofac.Core;
+
+namespace OASystem.API.OAMethodLib
+{
+    public class AutofacIocManager
+    {
+        public static AutofacIocManager Instance = new AutofacIocManager();
+        public ILifetimeScope Container { get; set; }
+
+        public T GetService<T>()
+        {
+            return ResolutionExtensions.Resolve<T>((IComponentContext)(object)this.Container);
+        }
+
+        public T GetService<T>(string serviceKey)
+        {
+            return ResolutionExtensions.ResolveKeyed<T>((IComponentContext)(object)this.Container, (object)serviceKey);
+        }
+
+        public T GetService<T>(string serviceKey, params Parameter[] parameters)
+        {
+            return ResolutionExtensions.ResolveKeyed<T>((IComponentContext)(object)this.Container, (object)serviceKey, parameters);
+        }
+
+        public object GetService(Type serviceType)
+        {
+            return ResolutionExtensions.Resolve((IComponentContext)(object)this.Container, serviceType);
+        }
+
+        public object GetService(string serviceKey, Type serviceType)
+        {
+            return ResolutionExtensions.ResolveKeyed((IComponentContext)(object)this.Container, (object)serviceKey, serviceType);
+        }
+
+        public bool IsRegistered<T>()
+        {
+            return ResolutionExtensions.IsRegistered<T>((IComponentContext)(object)this.Container);
+        }
+
+        public bool IsRegistered<T>(string serviceKey)
+        {
+            return ResolutionExtensions.IsRegisteredWithKey<T>((IComponentContext)(object)this.Container, (object)serviceKey);
+        }
+
+        public bool IsRegistered(Type serviceType)
+        {
+            return ResolutionExtensions.IsRegistered((IComponentContext)(object)this.Container, serviceType);
+        }
+
+        public bool IsRegisteredWithKey(string serviceKey, Type serviceType)
+        {
+            return ResolutionExtensions.IsRegisteredWithKey((IComponentContext)(object)this.Container, (object)serviceKey, serviceType);
+        }
+    }
+}

+ 27 - 0
OASystem/OASystem.Api/OAMethodLib/AutofacRegister.cs

@@ -0,0 +1,27 @@
+using Microsoft.Extensions.Configuration.Json;
+using OASystem.Domain.Dtos.Groups;
+
+namespace OASystem.API.OAMethodLib
+{
+    public class AutofacRegister : Autofac.Module
+    {
+        protected override void Load(ContainerBuilder builder)
+        {
+            //OASystem.Infrastructure中所有以Repository结尾的文件都会被注入到项目
+            var assemblyServices = Assembly.Load("OASystem.Infrastructure");
+            builder.RegisterAssemblyTypes(assemblyServices).Where(a => a.Name.EndsWith("Repository")).AsSelf();
+
+            #region 团组流程管控配置
+
+            GroupsConfig _groupsConfig = new GroupsConfig();
+            _groupsConfig.AutoCreate = int.Parse(AppSettingsHelper.Get(GroupsConfig.KEY, "AutoCreate"));
+            _groupsConfig.Leader = int.Parse(AppSettingsHelper.Get(GroupsConfig.KEY, "Leader"));
+            _groupsConfig.ExBeginDays = int.Parse(AppSettingsHelper.Get(GroupsConfig.KEY, "ExBeginDays"));
+            _groupsConfig.ExEndDays = int.Parse(AppSettingsHelper.Get(GroupsConfig.KEY, "ExEndDays"));
+
+            builder.RegisterInstance<GroupsConfig>(_groupsConfig);
+            #endregion
+
+        }
+    }
+}

+ 0 - 93
OASystem/OASystem.Api/OAMethodLib/BaseConfig.cs

@@ -1,93 +0,0 @@
-namespace OASystem.API.OAMethodLib
-{
-    public static class BaseConfig
-    {
-        /// <summary>
-        /// 版本号
-        /// </summary>
-        public const string Version = "0.0.1";
-
-        /// <summary>
-        /// 编码方式
-        /// </summary>
-        public const string Encoding = "UTF-8";
-
-        /// <summary>
-        /// 签名方法 SM2
-        /// </summary>
-        public const string SignMethod = "02";
-
-        /// <summary>
-        /// 招商银行商户号
-        /// </summary>
-        public const string MER_ID = "3089991727300CV";
-
-        /// <summary>
-        /// 招商银行收银员
-        /// </summary>
-        public const string USER_ID = "V000072134"; // 
-
-        /// <summary>
-        /// header中的APPID
-        /// </summary>
-        public const string APPID = "8ab74856-8772-45c9-96db-54cb30ab9f74"; // 
-
-        /// <summary>
-        /// 用于生成header中的APISign
-        /// </summary>
-        public const string APP_SECRET = "5b96f20a-011f-4254-8be8-9a5ceb2f317f"; // 
-
-        private static X9ECParameters x9ECParameters = GMNamedCurves.GetByName("sm2p256v1");
-        private static ECDomainParameters ecDomainParameters = new ECDomainParameters(x9ECParameters.Curve, x9ECParameters.G, x9ECParameters.N);
-        /// <summary>
-        /// 国密标准公钥头(固定值)
-        /// </summary>
-        public const string SM2_KEY_TITLE = "3059301306072a8648ce3d020106082a811ccf5501822d03420004";
-        /// <summary>
-        /// 国密局推荐 ID(固定值)
-        /// </summary>
-        public const string SM_USER_ID = "1234567812345678";
-        /// <summary>
-        /// 国密私钥
-        /// </summary>
-        public const string SM_PRIVATE_KEY = "D5F2AFA24E6BA9071B54A8C9AD735F9A1DE9C4657FA386C09B592694BC118B38";
-        /// <summary>
-        /// 国密公钥 base64
-        /// </summary>
-        public const string SM_PUBLIC_KEY = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE6Q+fktsnY9OFP+LpSR5Udbxf5zHCFO0PmOKlFNTxDIGl8jsPbbB/9ET23NV+acSz4FEkzD74sW2iiNVHRLiKHg==";
-
-    }
-
-    public static class UrlConfig
-    {
-        /// <summary>
-        /// 通知地址
-        /// </summary>
-        public const string NotifyUrl = "https://payment.wh-trip.com:8082/Notify";
-
-        /// <summary>
-        /// 收款码申请
-        /// </summary>
-        public const string CollectionQRCode = "https://api.cmburl.cn:8065/polypay/v1.0/mchorders/qrcodeapply";
-
-        /// <summary>
-        /// 支付结果查询
-        /// </summary>
-        public const string OrderqueryUrl = "https://api.cmburl.cn:8065/polypay/v1.0/mchorders/orderquery";
-
-        /// <summary>
-        /// 发起退款申请
-        /// </summary>
-        public const string RefundUrl = "https://api.cmburl.cn:8065/polypay/v1.0/mchorders/refund";
-
-        /// <summary>
-        /// 退款申请查询
-        /// </summary>
-        public const string RefundqueryUrl = "https://api.cmburl.cn:8065/polypay/v1.0/mchorders/refundquery";
-
-        /// <summary>
-        /// 支付宝native支付
-        /// </summary>
-        public const string ZFBQRCodeUrl = "https://api.cmburl.cn:8065/polypay/v1.0/mchorders/zfbqrcode";
-    }
-}

+ 76 - 0
OASystem/OASystem.Api/OAMethodLib/GroupStepForDelegation.cs

@@ -0,0 +1,76 @@
+using OASystem.API.OAMethodLib;
+using OASystem.Domain.Dtos.Groups;
+using OASystem.Domain.Entities.Groups;
+using OASystem.Infrastructure.Repositories.Groups;
+using System.Configuration;
+
+namespace OASystem.API.OAMethodLibs
+{
+
+    /// <summary>
+    /// 团组流程管控
+    /// </summary>
+    public static class GroupStepForDelegation
+    {
+
+        /// <summary>
+        /// 创建流程管控
+        /// </summary>
+        /// <param name="Diid">团组Id</param>
+        public static async void CreateWorkStep(int DiId)
+        {
+            var _grpScheduleRep = AutofacIocManager.Instance.GetService<GrpScheduleRepository>();
+
+            //判断是否已存在团组的流程管控
+            Grp_ScheduleInfo check = _grpScheduleRep.Query(s => s.DiId == DiId).First();
+
+            if (check == null)
+            {
+                _grpScheduleRep.BeginTran();
+
+                GroupsConfig _groupConfig = AutofacIocManager.Instance.GetService<GroupsConfig>();
+
+                #region 主流程
+                Grp_ScheduleInfo _primary = new Grp_ScheduleInfo();
+                _primary.CreateUserId = _groupConfig.AutoCreate;
+                _primary.DiId = DiId;
+                _primary.Exception = 0;
+                _primary.ExpectBeginDt = DateTime.Now.AddDays(_groupConfig.ExBeginDays);
+                _primary.ExpectEndDt = DateTime.Now.AddDays(_groupConfig.ExEndDays);
+                _primary.Leader = _groupConfig.Leader;
+                _primary.PrimaryStep = GrpSchedulePrimaryStepEnum.Wait;
+                _primary.Remark = "请设置各流程预计开始/结束时间";
+                int _primaryId = await _grpScheduleRep.AddAsync(_primary);
+                if (_primaryId > 0)
+                {
+                    #region 子流程
+
+                    #region 经费预算
+
+                    Grp_ScheduleDetailInfo grp_budget = new Grp_ScheduleDetailInfo();
+                    grp_budget.CreateTime = DateTime.Now;
+                    grp_budget.CreateUserId = _groupConfig.AutoCreate;
+                    //grp_budget.Duty=
+
+                    #endregion
+
+
+                    #endregion
+                }
+                else
+                {
+                    _grpScheduleRep.RollbackTran();
+                }
+                #endregion
+
+                _grpScheduleRep.CommitTran();
+            }
+
+        }
+
+
+
+    }
+
+
+}

+ 6 - 3
OASystem/OASystem.Api/Program.cs

@@ -6,6 +6,8 @@ using OASystem.RedisRepository.RedisAsyncHelper;
 using OASystem.RedisRepository.Config;
 using OASystem.API.OAMethodLib;
 using System.Text.Json.Serialization;
+using OASystem.API.OAMethodLibs;
+using OASystem.Domain.Dtos.Groups;
 
 var builder = WebApplication.CreateBuilder(args);
 var basePath = AppContext.BaseDirectory;
@@ -175,14 +177,13 @@ Log.Logger = new LoggerConfiguration()
        .CreateLogger();
 #endregion
 
-#region 引入注册Autofac OASystem.Infrastructure中所有以Repository结尾的文件都会被注入到项目
+#region 引入注册Autofac Module
 builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
 var hostBuilder = builder.Host.ConfigureContainer<ContainerBuilder>(builder =>
 {
     try
     {
-        var assemblyServices = Assembly.Load("OASystem.Infrastructure");
-        builder.RegisterAssemblyTypes(assemblyServices).Where(a => a.Name.EndsWith("Repository")).AsSelf();
+        builder.RegisterModule(new AutofacRegister());
     }
     catch (Exception ex)
     {
@@ -203,6 +204,7 @@ builder.Services.AddScoped<IMapper, Mapper>();
 #endregion
 
 var app = builder.Build();
+AutofacIocManager.Instance.Container = app.UseHostFiltering().ApplicationServices.GetAutofacRoot();//AutofacIocManager
 
 // Configure the HTTP request pipeline.
 if (!app.Environment.IsDevelopment())
@@ -234,6 +236,7 @@ if (AppSettingsHelper.Get("UseSwagger").ToBool())
 }
 #endregion
 
+
 app.MapControllerRoute(
     name: "default",
     pattern: "{controller=Home}/{action=Index}/{id?}");

+ 7 - 2
OASystem/OASystem.Api/appsettings.json

@@ -3,6 +3,11 @@
     "OA2023DB": "server=132.232.92.186;uid=sa;pwd=Yjx@158291;database=OA2023DB;"
   },
   "JwtSecurityKey": "48d3f4fe770940a1068052f581536b81", //jwt密钥
-  "UseSwagger": "true" //启用Swagger
-
+  "UseSwagger": "true", //启用Swagger
+  "GroupsConfig": {
+    "AutoCreate": "4",
+    "Leader": "149",
+    "ExBeginDays": "3",
+    "ExEndDays": "30"
+  }
 }

+ 57 - 0
OASystem/OASystem.Domain/Common/DepartmentCode.cs

@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Common
+{
+    public class DepartmentCode
+    {
+        /// <summary>
+        /// 总经办
+        /// </summary>
+        public static int GMO = 1;
+
+        /// <summary>
+        /// 信息部
+        /// </summary>
+        public static int INFO = 2;
+
+        /// <summary>
+        /// 财务部
+        /// </summary>
+        public static int FIN = 3;
+
+        /// <summary>
+        /// 人事部
+        /// </summary>
+        public static int HR = 4;
+
+        /// <summary>
+        /// 策划部
+        /// </summary>
+        public static int PLAN = 5;
+
+        /// <summary>
+        /// 市场部
+        /// </summary>
+        public static int MARKET = 6;
+
+        /// <summary>
+        /// 国交部
+        /// </summary>
+        public static int IC = 7;
+
+        /// <summary>
+        /// 项目部
+        /// </summary>
+        public static int PROJECT = 8;
+
+        /// <summary>
+        /// OA管理部
+        /// </summary>
+        public static int OA = 9;
+
+    }
+}

+ 36 - 0
OASystem/OASystem.Domain/Dtos/Groups/GroupsConfig.cs

@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.Groups
+{
+    /// <summary>
+    /// appsettings.json配置对应实体类(团组管控流程配置)
+    /// </summary>
+    public class GroupsConfig
+    {
+        public const string KEY = "GroupsConfig";
+
+        /// <summary>
+        /// 创建团组管控流程的默认用户Id ,当前为管理员4
+        /// </summary>
+        public int AutoCreate { get; set; }
+
+        /// <summary>
+        /// 团组管控流程默认总负责人,当前为王鸽149
+        /// </summary>
+        public int Leader { get; set; }
+
+        /// <summary>
+        /// 团组默认初始日期(增加3天)
+        /// </summary>
+        public int ExBeginDays { get; set; }
+
+        /// <summary>
+        /// 团组默认结束日期(增加30天)
+        /// </summary>
+        public int ExEndDays { get; set; }  
+    }
+}

+ 6 - 0
OASystem/OASystem.Domain/Entities/Groups/Grp_ScheduleInfo.cs

@@ -104,6 +104,12 @@ namespace OASystem.Domain.Entities.Groups
         [SugarColumn(IsNullable = true, ColumnDataType = "int")]
         public int Duty { get; set; }
 
+        /// <summary>
+        /// 工作内容
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
+        public string JobContent { get; set; }
+
         /// <summary>
         /// 预计开始时间
         /// </summary>

+ 13 - 4
OASystem/OASystem.Domain/Enums/GrpScheduleEnum.cs

@@ -13,15 +13,15 @@ namespace OASystem.Domain.Enums
     public enum GrpSchedulePrimaryStepEnum
     {
         /// <summary>
-        /// 未开始
+        /// 未开始/等待任务分配
         /// </summary>
-        [Description("未开始")]
+        [Description("未开始/等待任务分配")]
         Wait = 0,
 
         /// <summary>
-        /// 确认出团
+        /// 确认出团/任务分配
         /// </summary>
-        [Description("确认出团")]
+        [Description("确认出团/任务分配完成")]
         Confirm = 1,
 
         /// <summary>
@@ -29,6 +29,15 @@ namespace OASystem.Domain.Enums
         /// </summary>
         [Description("经费预算")]
         Budget = 2,
+        /// <summary>
+        /// 经费预算子流程01:完成经费预算
+        /// </summary>
+        [Description("完成经费预算")]
+        BudgetChild01 = 201,
+        /// <summary>
+        /// 经费预算自定义子流程:
+        /// </summary>
+        BudgetChildCustom = 2011,
 
         /// <summary>
         /// 市场部人员对接反馈

+ 19 - 9
OASystem/OASystem.Infrastructure/Repositories/Groups/GrpScheduleRepository.cs

@@ -15,7 +15,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
         }
 
-        public string SetSqlWhere_GrpScheduleDto(Grp_ScheduleDto _dto)
+        public string SetSql_GrpScheduleDto(Grp_ScheduleDto _dto)
         {
             string sqlWhere = string.Empty;
 
@@ -35,7 +35,12 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 sqlWhere = r.Replace(sqlWhere, "Where", 1);
             }
 
-            return sqlWhere;
+            string sql = string.Format(@" Select s.Id,s.DiId,di.TeamName as DeleName,s.PrimaryStep,s.ExpectBeginDt,s.ExpectEndDt,s.Leader,s.Exception,u.CnName as LeaderName
+            From Grp_Schedule as s With(Nolock) Inner Join Grp_DelegationInfo as di With(Nolock) On s.DiId=di.Id
+            Inner Join Sys_Users as u With(Nolock) On s.Leader=u.Id
+            {0} ", sqlWhere);
+
+            return sql;
         }
 
         /// <summary>
@@ -47,18 +52,23 @@ namespace OASystem.Infrastructure.Repositories.Groups
         public async Task<Grp_ScheduleView> GetView_GrpSchedule(Grp_ScheduleDto _dto)
         {
             Grp_ScheduleView _view = null;
+            string sql = this.SetSql_GrpScheduleDto(_dto);
+            _view = await _sqlSugar.SqlQueryable<Grp_ScheduleView>(sql).FirstAsync();
+            return _view;
+        }
 
-            string sqlWhere = this.SetSqlWhere_GrpScheduleDto(_dto);
-            string sql = string.Format(@" Select s.Id,s.DiId,di.TeamName as DeleName,s.PrimaryStep,s.ExpectBeginDt,s.ExpectEndDt,s.Leader,s.Exception,u.CnName as LeaderName
-            From Grp_Schedule as s With(Nolock) Inner Join Grp_DelegationInfo as di With(Nolock) On s.DiId=di.Id
-            Inner Join Sys_Users as u With(Nolock) On s.Leader=u.Id
-            {0} ", sqlWhere);
+        public async Task<List<Grp_ScheduleView>> GetViewList_GrpSchedule(Grp_ScheduleDto _dto)
+        {
+            List<Grp_ScheduleView> _viewList = new List<Grp_ScheduleView>();
+            string sqlInner = this.SetSql_GrpScheduleDto(_dto);
+            string sql = string.Format(@" Select * From ( Select ROW_NUMBER() Over(order By Id desc) as RowNumber,* From ( {2} ) ) as tb Where tb.RowNumber Between {0} And {1} ", (((_dto.PageIndex > 0) ? (_dto.PageIndex - 1) : 0) * _dto.PageSize) + 1, (((_dto.PageIndex > 0) ? (_dto.PageIndex - 1) : 0) + 1) * _dto.PageSize, sqlInner);
 
-            _view = await _sqlSugar.SqlQueryable<Grp_ScheduleView>(sql).FirstAsync();
+            _viewList = await _sqlSugar.SqlQueryable<Grp_ScheduleView>(sql).ToListAsync();
 
-            return _view;
+            return _viewList;
         }
 
 
+
     }
 }