Browse Source

合并冲突

yuanrf 1 year ago
parent
commit
b4099632bc

+ 4 - 3
OASystem/EntitySync/Program.cs

@@ -89,8 +89,9 @@ db.CodeFirst.SetStringDefaultLength(50).BackupTable().InitTables(new Type[]
     //typeof(Bus_ConfItemInfo)
     //typeof(Bus_ConfItemListInfo)
     //typeof(Res_CountryFeeCost)
-    typeof(Res_MemoInfo),
-    typeof(Fin_DailyFeePayment), // 财务 - 日付申请
-    typeof(Fin_DailyFeePaymentContent)  // 财务 - 日付申请详细类
+    //typeof(Res_MemoInfo),
+    //typeof(Fin_DailyFeePayment), // 财务 - 日付申请
+    //typeof(Fin_DailyFeePaymentContent)  // 财务 - 日付申请详细类
+    typeof(Grp_GroupsTaskAssignment)
 });
 Console.WriteLine("数据库结构同步完成!");

+ 57 - 1
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -18,12 +18,14 @@ namespace OASystem.API.Controllers
         private readonly GrpScheduleRepository _grpScheduleRep;
         private readonly IMapper _mapper;
         private readonly DelegationInfoRepository _groupRepository;
+        private readonly TaskAssignmentRepository _taskAssignmentRep;
 
-        public GroupsController(IMapper mapper, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository)
+        public GroupsController(IMapper mapper, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository, TaskAssignmentRepository taskAssignmentRep)
         {
             _mapper = mapper;
             _grpScheduleRep = grpScheduleRep;
             _groupRepository = groupRepository;
+            _taskAssignmentRep = taskAssignmentRep;
         }
 
         #region 流程管控
@@ -374,6 +376,60 @@ namespace OASystem.API.Controllers
 
 
 
+        #endregion
+
+        #region 团组任务分配
+        /// <summary>
+        /// 团组任务分配初始化
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GetTaskAssignmen()
+        {
+            var groupData = await _taskAssignmentRep.GetTaskAssignmen();
+            if (groupData.Code != 0)
+            {
+                return Ok(JsonView(false, groupData.Msg));
+            }
+            return Ok(JsonView(true,groupData.Msg,groupData.Data));
+        }
+
+        /// <summary>
+        /// 团组任务分配查询
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
+        {
+            var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
+            if (groupData.Code != 0)
+            {
+                return Ok(JsonView(false, groupData.Msg));
+            }
+            return Ok(JsonView(true, groupData.Msg, groupData.Data));
+        }
+
+
+        /// <summary>
+        /// 团组任务分配操作
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
+        {
+            Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
+            if (groupData.Code != 0)
+            {
+                return Ok(JsonView(false, groupData.Msg));
+            }
+            return Ok(JsonView(true, groupData.Msg, groupData.Data));
+        }
         #endregion
     }
 }

+ 1 - 1
OASystem/OASystem.Api/Controllers/MarketCustomerResourcesController.cs

@@ -92,7 +92,7 @@ namespace OASystem.API.Controllers
             try
             {
                 Result resTable = await _clientDataRepository.QueryUserSelect();
-                return Ok(JsonView(true, resTable.Msg, resTable));
+                return Ok(JsonView(true, resTable.Msg, resTable.Data));
             }
             catch (Exception)
             {

+ 1 - 0
OASystem/OASystem.Domain/AutoMappers/_baseMappingProfile.cs

@@ -74,6 +74,7 @@ namespace OASystem.Domain.AutoMappers
             CreateMap<GroupListDto, Grp_DelegationInfo>();
             CreateMap<Grp_ScheduleDetailUpdDto, Grp_ScheduleDetailInfo>();
             CreateMap<Grp_ScheduleDetailInsertDto, Grp_ScheduleDetailInfo>();
+            CreateMap<TaskAssignmenDto, Grp_GroupsTaskAssignment>();
             #endregion
 
             #region Resource

+ 2 - 15
OASystem/OASystem.Domain/Dtos/CRM/NewClientDataQueryDto.cs

@@ -28,29 +28,16 @@ namespace OASystem.Domain.Dtos.CRM
         /// <summary>
         /// 负责人
         /// </summary>
-        public int Userid { get; set; }
-        
-        //省域
-
-        //单独负责的客户 (只看老张的)
-
-        /// <summary>
-        /// 权重
-        /// </summary>
-        //public char Weight { get; set; }
-
-
+        public string Userid { get; set; }
         /// <summary>
         /// 客户级别(地市州)
         /// </summary>
         public int Lvlid { get; set; }
 
-        //客户类别
-
         /// <summary>
         /// 业务分类
         /// </summary>
-        public int Business { get; set; }
+        public string Business { get; set; }
 
         public class NewClientOpDto
         {

+ 50 - 0
OASystem/OASystem.Domain/Dtos/Groups/TaskAssignmenDto.cs

@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.Groups
+{
+    public class TaskAssignmenDto
+    {
+        /// <summary>
+        /// 团组外键编号
+        /// </summary>
+        public int DIId { get; set; }
+        /// <summary>
+        /// 配置任务(设置数据外键编号)
+        /// </summary>
+        public int CTId { get; set; }
+
+        /// <summary>
+        /// 员工外键编号
+        /// </summary>
+        public List<int> UIdStr { get; set; }
+
+        /// <summary>
+        /// 启用标识
+        /// </summary>
+        public int IsEnable { get; set; } = 1;
+        /// <summary>
+        /// 创建者Id
+        /// </summary>
+        public int CreateUserId { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+    }
+    public class TaskAssignmenQueryDto
+    {
+        /// <summary>
+        /// 团组外键编号
+        /// </summary>
+        public int DIId { get; set; }
+        /// <summary>
+        /// 配置任务(设置数据外键编号)
+        /// </summary>
+        public int CTId { get; set; }
+    }
+
+}

+ 42 - 0
OASystem/OASystem.Domain/Entities/Groups/Grp_GroupsTaskAssignment.cs

@@ -0,0 +1,42 @@
+using OASystem.Domain.Dtos;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Entities.Groups
+{
+
+    /// <summary>
+    /// 团组任务分配表
+    /// </summary>
+    [SugarTable("Grp_GroupsTaskAssignment")]
+    public class Grp_GroupsTaskAssignment:EntityBase
+    {
+
+        /// <summary>
+        /// 团组外键编号
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
+        public int DIId { get; set; }
+        /// <summary>
+        /// 配置任务(设置数据外键编号)
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
+        public int CTId { get; set; }
+
+        /// <summary>
+        /// 员工外键编号
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
+        public int UId { get; set; }
+
+        /// <summary>
+        /// 启用标识
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
+        public int IsEnable { get; set; }
+    }
+}

+ 3 - 3
OASystem/OASystem.Infrastructure/Repositories/CRM/NewClientDataRepository.cs

@@ -64,7 +64,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
                         }
                         state = -1;
                     }
-                    if (dto.Business != 0)
+                    if (!string.IsNullOrWhiteSpace(dto.Business))
                     {
                         string sql = string.Format(@"select d1.*,d2.Name from Crm_ClientDataAndBusiness d1,Sys_SetData d2 where d1.SetDataId=d2.Id and d1.SetDataId in ({0})", dto.Business);
                         List<AscribedDepartment> AscribedDepartment = await _sqlSugar.SqlQueryable<AscribedDepartment>(sql).ToListAsync();
@@ -272,7 +272,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
                     List<int> NewClientDataId1 = new List<int>();
                     List<int> NewClientDataId2 = new List<int>();
                     string NewClientDataId = "";
-                    if (dto.Userid != 0)
+                    if (!string.IsNullOrWhiteSpace(dto.Userid))
                     {
                         string sql = string.Format(@"select u1.UsersId,u2.CnName,u1.NewClientDataId from Crm_ClientDataAndUser u1,Sys_Users u2 where u1.UsersId=u2.Id and u1.UsersId in ({0}) and u1.isdel = 0 and u2.isdel = 0", dto.Userid);
                         List<AscribedUser> ascribedUsers = await _sqlSugar.SqlQueryable<AscribedUser>(sql).ToListAsync();
@@ -291,7 +291,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
                             result = new Result() { Code = -1, Msg = "暂无数据" };
                         }
                     }
-                    if (dto.Business != 0)
+                    if (!string.IsNullOrWhiteSpace(dto.Business))
                     {
                         string sql = string.Format(@"select d1.*,d2.Name from Crm_ClientDataAndBusiness d1,Sys_SetData d2 where d1.SetDataId=d2.Id and d1.SetDataId in({0}) and d1.isdel = 0 and d2.isdel = 0", dto.Business);
                         List<AscribedDepartment> AscribedDepartment = await _sqlSugar.SqlQueryable<AscribedDepartment>(sql).ToListAsync();

+ 220 - 0
OASystem/OASystem.Infrastructure/Repositories/Groups/TaskAssignmentRepository.cs

@@ -0,0 +1,220 @@
+using AutoMapper;
+using MySqlX.XDevAPI.Relational;
+using OASystem.Domain;
+using OASystem.Domain.Dtos.Groups;
+using OASystem.Domain.Entities.Groups;
+using OASystem.Domain.Entities.Resource;
+using OASystem.Domain.ViewModels.Groups;
+using Org.BouncyCastle.Utilities.Collections;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Infrastructure.Repositories.Groups
+{
+    public class TaskAssignmentRepository : BaseRepository<Grp_GroupsTaskAssignment, Grp_GroupsTaskAssignment>
+    {
+        private readonly IMapper _mapper;
+        public TaskAssignmentRepository(SqlSugarClient sqlSugar, IMapper mapper) :
+            base(sqlSugar)
+        {
+            this._mapper = mapper;
+        }
+
+        public async Task<Result> GetTaskAssignmen()
+        {
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+            try
+            {
+                //团组下拉框
+                List<dynamic> _DelegationInfos = new List<dynamic>();
+                List<Grp_DelegationInfo> grp_DelegationInfos=_sqlSugar.Queryable<Grp_DelegationInfo>().Where(a=>a.IsDel == 0 && a.TourCode !="" && a.IsState == 0).ToList();
+                foreach (var Item in grp_DelegationInfos)
+                {
+                    var data = new
+                    {
+                        Id = Item.Id,
+                        Name = Item.TeamName
+                    };
+                    _DelegationInfos.Add(data);
+                }
+                //任务下拉框
+                List<dynamic> _SetData = new List<dynamic>();
+                List<Sys_SetData> sys_SetData = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0 && a.Name != "其他款项" && a.STid ==16).ToList();
+                foreach (var Item in sys_SetData)
+                {
+                    var data = new
+                    {
+                        Id = Item.Id,
+                        Name = Item.Name
+                    };
+                    _SetData.Add(data);
+                }
+                //人员安排列表
+                List<dynamic> _User = new List<dynamic>();
+                List<Sys_Users> sys_User = _sqlSugar.Queryable<Sys_Users>().Where(a => a.IsDel == 0 &&a.Id!=4).ToList();
+                foreach (var Item in sys_User)
+                {
+                    var data = new
+                    {
+                        Id = Item.Id,
+                        Name = Item.CnName
+                    };
+                    _User.Add(data);
+                }
+                var dataList = new
+                {
+                    DelegationInfos=_DelegationInfos,
+                    SetData= _SetData,
+                    User= _User
+                };
+                result=new Result(){ Code = 0, Msg = "成功", Data = dataList };
+            }
+            catch (Exception)
+            {
+                result = new Result() { Code = -2, Msg = "未知错误" };
+            }
+            return result;
+        }
+
+        public async Task<Result> GetTaskAssignmenOp(TaskAssignmenDto dto)
+        {
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+            try 
+            {
+                List<int> id = new List<int>();
+                List<Grp_GroupsTaskAssignment> _GroupsTaskAssignments = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(a=>a.DIId==dto.DIId && a.CTId==dto.CTId && a.IsDel==0).ToList();
+                foreach(var Group in _GroupsTaskAssignments) 
+                {
+                    id.Add(Group.UId);
+                }
+
+                List<int> intersection = id.Intersect(dto.UIdStr).ToList();//交集
+                List<int> del = id.Except(dto.UIdStr).ToList();//差集
+                List<int> union = id.Union(dto.UIdStr).ToList();//并集
+                for (int i = 0; i < del.Count; i++)
+                {
+                   await _sqlSugar.Updateable<Grp_GroupsTaskAssignment>().Where(a => a.UId == del[i] && a.DIId==dto.DIId && a.CTId==dto.CTId).SetColumns(a => new Grp_GroupsTaskAssignment()
+                    {
+                        IsDel = 1,
+                        DeleteUserId = dto.CreateUserId,
+                        DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+                    }).ExecuteCommandAsync();
+                }
+
+                //去掉交集
+                foreach (var item in intersection)
+                {
+                    union.Remove(item);
+                }
+                //去掉差集
+                foreach (var item in del)
+                {
+                    union.Remove(item);
+                }
+                //需添加的
+                foreach (var item in union)
+                {
+                    Grp_GroupsTaskAssignment AddData= _mapper.Map<Grp_GroupsTaskAssignment>(dto);
+                    AddData.UId = item;
+
+                    Grp_GroupsTaskAssignment addQuery = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().First(a=>a.DIId==AddData.DIId && a.UId==AddData.UId && a.CTId==AddData.CTId);
+                    if (addQuery != null)
+                    {
+                        await _sqlSugar.Updateable<Grp_GroupsTaskAssignment>().Where(a =>a.Id==addQuery.Id).SetColumns(a => new Grp_GroupsTaskAssignment()
+                        {
+                            IsDel = 0,
+                            DeleteUserId = 0,
+                            CreateUserId = AddData.CreateUserId,
+                            CreateTime = DateTime.Now
+                        }).ExecuteCommandAsync();
+                    }
+                    else
+                    {
+                        int AddId = await AddAsyncReturnId(AddData);
+                    }
+                    
+                }
+
+                result = new Result() { Code = 0, Msg = "保存成功!" };
+            }
+            catch (Exception)
+            {
+                result = new Result() { Code = -2, Msg = "保存失败,未知错误" };
+            }
+            return result;
+            
+        }
+
+        public async Task<Result> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
+        {
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+            try
+            {
+                string sqlWhere = string.Empty;
+                if (dto.DIId!=0)
+                {
+                    sqlWhere += string.Format(@" And DIId ={0}", dto.DIId);
+                }
+                else
+                {
+                    return result = new Result() { Code = -1, Msg = "暂无数据" };
+                }
+                if (dto.CTId!=0)
+                {
+                    sqlWhere += string.Format(@" And CTId ={0}", dto.CTId);
+                }
+                else
+                {
+                    return result = new Result() { Code = -1, Msg = "暂无数据" };
+                }
+                
+                sqlWhere += string.Format(@" And IsDel={0} ", 0);
+                if (!string.IsNullOrEmpty(sqlWhere.Trim()))
+                {
+                    Regex r = new Regex("And");
+                    sqlWhere = r.Replace(sqlWhere, "Where", 1);
+                }
+                string sql = string.Format(@"select * from Grp_GroupsTaskAssignment {0}", sqlWhere);
+                List<Grp_GroupsTaskAssignment> GroupsTaskAssignment = await _sqlSugar.SqlQueryable<Grp_GroupsTaskAssignment>(sql).ToListAsync();
+                Grp_DelegationInfo grp_DelegationInfo = new Grp_DelegationInfo();
+                if (GroupsTaskAssignment.Count!=0)
+                {
+                    List<int> UserId = new List<int>();
+                    foreach (var item in GroupsTaskAssignment)
+                    {
+                        UserId.Add(item.UId);
+                    }
+
+                    grp_DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == GroupsTaskAssignment[0].DIId && a.IsDel==0);
+                    
+                    var data = new
+                    {
+                        TaskAssignment = GroupsTaskAssignment[0],
+                        UserStr = UserId,
+                        DelegationInfo = grp_DelegationInfo
+                    };
+                    result = new Result()
+                    {
+                        Code = 0,
+                        Msg = "查询成功!",
+                        Data = data
+                    };
+                }
+                else
+                {
+                    result = new Result() { Code = -1, Msg = "暂无数据" };
+                }
+                
+            }
+            catch (Exception)
+            {
+                result = new Result() { Code = -2, Msg = "未知错误" };
+                throw;
+            }
+            return result;
+        }
+    }
+}

+ 6 - 6
OASystem/_Doc/OA2023数据字典.docx

@@ -2958,23 +2958,23 @@ Null
 团组外键编号
 Grp_DelegationInfo.id
 CTId
-varchar(50)
+Int
 Null
 
  配置任务(设置数据外键编号)
 Sys_SetData.id
 UId
-varchar(50)
+Int
 Null
 
 员工外键编号
 Sys_User.id
 IsEnable
+int
+Null
 
-
-
-
-
+启用标识
+0否1是
 
 1. 资源板块
 1) 酒店数据表:Res_HotelData(挪用)