Browse Source

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

jiangjc 1 year ago
parent
commit
fbe02d28c5

+ 30 - 2
OASystem/OASystem.Api/Controllers/MarketCustomerResourcesController.cs

@@ -66,7 +66,6 @@ namespace OASystem.API.Controllers
             catch (Exception)
             {
                 return Ok(JsonView(false, "程序错误!"));
-                throw;
             }
         }
         /// <summary>
@@ -94,6 +93,32 @@ namespace OASystem.API.Controllers
             }
         }
 
+        /// <summary>
+        /// 获取下拉列表数据和单条数据信息
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> QuerySelectAndSingleData(QuerySingleDto dto)
+        {
+            JsonView jw = new JsonView();
+            var result = await _clientDataRepository.QuerySelectAndSingleData(dto);
+            if (result.Code == 0)
+            {
+                jw = JsonView(true, result.Msg,result.Data);
+            }
+            else
+            {
+                jw = JsonView(false, result.Msg);
+            }
+            return Ok(jw);
+        }
+
+        /// <summary>
+        /// 获取现有负责人
+        /// </summary>
+        /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> QueryUserSelect()
@@ -110,7 +135,10 @@ namespace OASystem.API.Controllers
             }
         }
 
-
+        /// <summary>
+        /// 获取出团数据
+        /// </summary>
+        /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> QueryNumberGroups()

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

@@ -17,6 +17,7 @@ using OASystem.Domain.Dtos.Financial;
 using OASystem.Domain.Entities.Financial;
 using static OASystem.Domain.Dtos.CRM.NewClientDataQueryDto;
 using OASystem.Domain.ViewModels.Groups;
+using OASystem.Domain.ViewModels.CRM;
 
 namespace OASystem.Domain.AutoMappers
 {
@@ -139,6 +140,7 @@ namespace OASystem.Domain.AutoMappers
             #endregion
             #region 新客户资料
             CreateMap<NewClientOpDto, Crm_NewClientData>();
+            CreateMap<Crm_NewClientData, NewClientDataView>();
             #endregion
             #endregion
 

+ 10 - 0
OASystem/OASystem.Domain/Dtos/CRM/NewClientDataQueryDto.cs

@@ -1,4 +1,5 @@
 using AutoMapper.Execution;
+using OASystem.Domain.ViewModels.CRM;
 using Org.BouncyCastle.Asn1.Ocsp;
 using Org.BouncyCastle.Asn1.X9;
 using System;
@@ -175,5 +176,14 @@ namespace OASystem.Domain.Dtos.CRM
         /// </summary>
         public string Remark { get; set; }
 
+        /// <summary>
+        /// 负责人
+        /// </summary>
+        public List<AscribedUser> AscribedUser { get; set; }
+        /// <summary>
+        /// 业务归属
+        /// </summary>
+        public List<AscribedDepartment> AscribedDepartment { get; set; }
+
     }
 }

+ 13 - 0
OASystem/OASystem.Domain/Dtos/CRM/QuerySingleDto.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.CRM
+{
+    public class QuerySingleDto
+    {
+        public int Id { get; set; }
+    }
+}

+ 95 - 6
OASystem/OASystem.Infrastructure/Repositories/CRM/NewClientDataRepository.cs

@@ -18,7 +18,7 @@ using static OASystem.Domain.Dtos.CRM.NewClientDataQueryDto;
 
 namespace OASystem.Infrastructure.Repositories.CRM
 {
-    public class NewClientDataRepository : BaseRepository<Crm_NewClientData, Crm_NewClientData>
+    public class NewClientDataRepository : BaseRepository<Crm_NewClientData, NewClientDataView>
     {
         private readonly IMapper _mapper;
         public NewClientDataRepository(SqlSugarClient sqlSugar, IMapper mapper) :
@@ -47,7 +47,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
                 #region 负责人
                 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", dto.Userid);
+                    string sql = string.Format(@"select u1.UsersId as UserId,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", dto.Userid);
                     List<AscribedUser> ascribedUsers = await _sqlSugar.SqlQueryable<AscribedUser>(sql).ToListAsync();
                     if (ascribedUsers.Count != 0)
                     {
@@ -70,7 +70,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
                 #region 业务归属
                 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", dto.Business);
+                    string sql = string.Format(@"select   d2.Id,d2.Name,d1.NewClientDataId   from Crm_ClientDataAndBusiness d1,Sys_SetData d2 where d1.SetDataId=d2.Id and d1.SetDataId in ({0}) and d1.isdel = 0", dto.Business);
                     List<AscribedDepartment> AscribedDepartment = await _sqlSugar.SqlQueryable<AscribedDepartment>(sql).ToListAsync();
                     if (AscribedDepartment.Count != 0)
                     {
@@ -192,7 +192,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
                             break;
                     }
 
-                    var RangeSetDataList = _sqlSugar.SqlQueryable<Sys_SetData>(setDataSql).Select(x=>x.Id).ToList();
+                    var RangeSetDataList = _sqlSugar.SqlQueryable<Sys_SetData>(setDataSql).Select(x => x.Id).ToList();
                     string lvlds = string.Join(',', RangeSetDataList).TrimEnd(',');
                     if (!string.IsNullOrEmpty(lvlds))
                     {
@@ -308,11 +308,11 @@ namespace OASystem.Infrastructure.Repositories.CRM
                         foreach (var item in NewClientDataView)
                         {
                             List<AscribedUser> AscribedUser = await _sqlSugar.SqlQueryable<AscribedUser>
-                           ("select u1.UsersId,u2.CnName,u1.NewClientDataId from Crm_ClientDataAndUser u1,Sys_Users u2 where u1.UsersId=u2.Id and NewClientDataId=" + item.Id + "").ToListAsync();
+                           ("select u1.UsersId as UserId ,u2.CnName,u1.NewClientDataId from Crm_ClientDataAndUser u1,Sys_Users u2 where u1.UsersId=u2.Id and NewClientDataId=" + item.Id + "   AND u1.ISDEL = 0").ToListAsync();
                             item.AscribedUser = AscribedUser;
 
                             List<AscribedDepartment> AscribedDepartment = await _sqlSugar.SqlQueryable<AscribedDepartment>
-                          ("select d1.*,d2.Name from Crm_ClientDataAndBusiness d1,Sys_SetData d2 where d1.SetDataId=d2.Id and NewClientDataId=" + item.Id + "").ToListAsync();
+                          ("select  d2.Id,d2.Name,d1.NewClientDataId  from Crm_ClientDataAndBusiness d1,Sys_SetData d2 where d1.SetDataId=d2.Id and NewClientDataId=" + item.Id + "  AND d1.ISDEL = 0").ToListAsync();
                             item.AscribedDepartment = AscribedDepartment;
                         }
 
@@ -481,5 +481,94 @@ namespace OASystem.Infrastructure.Repositories.CRM
 
             return result;
         }
+
+        /// <summary>
+        /// 获取下拉列表数据和单条数据信息
+        /// </summary>
+        /// <param name="dto"></param>
+        public async Task<Result> QuerySelectAndSingleData(QuerySingleDto dto)
+        {
+            Result rest = new Result();
+            var QueryData = await GetAsync<Crm_NewClientData>(x => x.Id == dto.Id);
+            NewClientDataView MapQueryData = null;
+            if (QueryData != null)
+            {
+                MapQueryData = _mapper.Map<NewClientDataView>(QueryData);
+                MapQueryData.AscribedUser = await _sqlSugar.SqlQueryable<AscribedUser>
+        ("select u1.UsersId as UserId,u2.CnName,u1.NewClientDataId from Crm_ClientDataAndUser u1,Sys_Users u2 where u1.UsersId=u2.Id and NewClientDataId=" + dto.Id + " and u1.isdel = 0").ToListAsync();
+
+                MapQueryData.AscribedDepartment = await _sqlSugar.SqlQueryable<AscribedDepartment>
+              ("select   d2.Id,d2.Name,d1.NewClientDataId   from Crm_ClientDataAndBusiness d1,Sys_SetData d2 where d1.SetDataId=d2.Id and NewClientDataId=" + dto.Id + " and d1.isdel = 0").ToListAsync();
+            }
+
+            #region 下拉框初始化数据
+            //负责人下拉框
+            List<dynamic> _Users = new List<dynamic>();
+            List<Sys_Users> users = _sqlSugar.Queryable<Sys_Users>()
+            .Where(u => (u.CnName == "张海麟" || u.CnName == "安宁" || u.CnName == "李彩娟" || u.CnName == "舒庆" || u.CnName == "李媛媛") && u.IsDel == 0).ToList();
+            foreach (Sys_Users user in users)
+            {
+                var data = new
+                {
+                    Id = user.Id,
+                    Name = user.CnName
+                };
+                _Users.Add(data);
+            };
+            
+            //客户级别数据
+            List<dynamic> _level = new List<dynamic>();
+            List<Sys_SetData> level = _sqlSugar.Queryable<Sys_SetData>()
+            .Where(u => u.STid == 33 && u.IsDel == 0).ToList();
+            foreach (Sys_SetData item in level)
+            {
+                var data = new
+                {
+                    Id = item.Id,
+                    Name = item.Name
+                };
+                _level.Add(data);
+            };
+            //客户类别
+            List<dynamic> _CustomerClass = new List<dynamic>();
+            List<Sys_SetData> CustomerClass = _sqlSugar.Queryable<Sys_SetData>()
+            .Where(u => u.STid == 37 && u.IsDel == 0).ToList();
+            foreach (Sys_SetData item in CustomerClass)
+            {
+                var data = new
+                {
+                    Id = item.Id,
+                    Name = item.Name
+                };
+                _CustomerClass.Add(data);
+            };
+            //业务分类 
+            List<dynamic> _ServiceClass = new List<dynamic>();
+            List<Sys_SetData> ServiceClass = _sqlSugar.Queryable<Sys_SetData>()
+            .Where(u => u.STid == 36 && u.IsDel == 0).ToList();
+            foreach (Sys_SetData item in ServiceClass)
+            {
+                var data = new
+                {
+                    Id = item.Id,
+                    Name = item.Name
+                };
+                _ServiceClass.Add(data);
+            };
+            #endregion
+
+            rest.Code = 0;
+            rest.Data = new
+            {
+                data = MapQueryData,
+                Users = _Users,
+                level = _level,
+                CustomerClass = _CustomerClass,
+                ServiceClass = _ServiceClass,
+            };
+            rest.Msg = "获取成功!";
+            return rest;
+        }
+
     }
 }