Browse Source

1、签证提成录入 --> 数据表设计、创建;API:CURD 代码编写及开发环境测试
2、邀请公务活动分配给王鸽(UserID:149)

LEIYI 6 months ago
parent
commit
0ad221cb34

+ 77 - 5
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -6397,7 +6397,7 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> VisaCommissionInit()
         {
-            return Ok(await _visaCommissionRep._Init());
+            return Ok(await _visaCommissionRep.Init());
         }
 
         /// <summary>
@@ -6406,12 +6406,65 @@ namespace OASystem.API.Controllers
         /// </summary>
         /// <param name="_dto"></param>
         /// <returns></returns>
-        [HttpGet]
+        [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto dto)
+        public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
         {
             var validator = new VisaCommissionItemDtoValidator();
-            var validatorRes = await validator.ValidateAsync(dto);
+            var validatorRes = await validator.ValidateAsync(_dto);
+            if (!validatorRes.IsValid)
+            {
+                StringBuilder sb = new StringBuilder();
+                foreach (var item in validatorRes.Errors)
+                {
+                    sb.AppendLine(item.ErrorMessage);
+                }
+                return Ok(JsonView(false, sb.ToString()));
+            }
+
+            return Ok(await _visaCommissionRep.Item(_dto));
+        }
+
+        /// <summary>
+        /// 签证提成录入 
+        /// Create
+        /// </summary>
+        /// <param name="_dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
+        {
+            var validator = new VisaCommissionCreateDtoValidator();
+            var validatorRes = await validator.ValidateAsync(_dto);
+            if (!validatorRes.IsValid)
+            {
+                StringBuilder sb = new StringBuilder();
+                foreach (var item in validatorRes.Errors)
+                {
+                    sb.AppendLine(item.ErrorMessage);
+                }
+                return Ok(JsonView(false, sb.ToString()));
+            }
+
+            return Ok(await _visaCommissionRep.Create(_dto));
+        }
+
+        /// <summary>
+        /// 签证提成录入
+        /// Put(编辑)
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="_dto"></param>
+        /// <returns></returns>
+        [HttpPut]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> VisaCommissionEdit(int id,VisaCommissionCreateDto _dto)
+        {
+            if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
+
+            var validator = new VisaCommissionCreateDtoValidator();
+            var validatorRes = await validator.ValidateAsync(_dto);
             if (!validatorRes.IsValid)
             {
                 StringBuilder sb = new StringBuilder();
@@ -6422,9 +6475,28 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, sb.ToString()));
             }
 
-            return Ok(await _visaCommissionRep._Init());
+            return Ok(await _visaCommissionRep.Edit(id,_dto));
         }
 
+        /// <summary>
+        /// 签证提成录入
+        /// Del
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="currUserId"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> VisaCommissionDel(int id,int currUserId)
+        {
+            if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
+            if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
+
+
+            return Ok(await _visaCommissionRep.Del(id, currUserId));
+        }
+
+
 
         #endregion
 

+ 13 - 2
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -663,8 +663,7 @@ namespace OASystem.API.OAMethodLib
 
             //81  邀请/公务活动 --> 国交部门(7) 商邀(27) 岗位
             _GroupsTaskAssignments.AddRange(
-                userDatas
-                .Where(it => it.DepId == 7 && it.JobPostId == 27)
+                userDatas.Where(it => it.DepId == 7 && it.JobPostId == 27)
                 .Select(it => new Grp_GroupsTaskAssignment()
                 {
                     DIId = diId,
@@ -674,6 +673,18 @@ namespace OASystem.API.OAMethodLib
                 }).ToList()
             );
 
+            //2024年8月26日16点27分 “邀请公务活动分配给王鸽(UserID:149)”
+            _GroupsTaskAssignments.Add(
+                 new Grp_GroupsTaskAssignment()
+                {
+                    DIId = diId,
+                    CTId = 81,
+                    UId = 149, 
+                    CreateUserId = userId
+                }
+            );
+
+
             //80  签证  --> 国交部门(7) 签证(26) 岗位
             _GroupsTaskAssignments.AddRange(
                 userDatas

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

@@ -167,6 +167,11 @@ namespace OASystem.Domain.AutoMappers
 
             #endregion
 
+            #region 签证提成录入
+
+            CreateMap<VisaCommissionCreateDto, Grp_VisaCommission>();
+            #endregion
+
             #endregion
             #region Resource
 

+ 48 - 1
OASystem/OASystem.Domain/Dtos/Groups/VisaCommissionDto.cs

@@ -23,8 +23,55 @@ namespace OASystem.Domain.Dtos.Groups
 
             RuleFor(x => x.PortType).InclusiveBetween(from: 1, to: 3)
                                     .WithMessage(MsgTips.Port);
-            RuleFor(x => x.CurrUserId).LessThan(valueToCompare: 1)
+            RuleFor(x => x.CurrUserId).GreaterThan(valueToCompare: 1)
                                       .WithMessage("请输入有效的CurrUserId!");
+            RuleFor(x => x.DiId).GreaterThan(valueToCompare: 1)
+                                .WithMessage("请输入有效的DiId!");
+        }
+    }
+
+    /// <summary>
+    /// Create Dto
+    /// </summary>
+    public class VisaCommissionCreateDto
+    {
+        /// <summary>
+        /// 用户ID
+        /// </summary>
+        public int CurrUserId { get; set; }
+        /// <summary>
+        /// 团组ID
+        /// </summary>
+        public int DiId { get; set; }
+
+        /// <summary>
+        /// 国家
+        /// </summary>
+        public string Country { get; set; }
+
+        /// <summary>
+        /// 数量
+        /// </summary>
+        public int Quantity { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+    }
+
+    public class VisaCommissionCreateDtoValidator : AbstractValidator<VisaCommissionCreateDto>
+    {
+        public VisaCommissionCreateDtoValidator()
+        {
+            RuleFor(x => x.CurrUserId).GreaterThan(valueToCompare: 0)
+                                      .WithMessage("请输入有效的CurrUserId!");
+            RuleFor(x => x.DiId).GreaterThan(valueToCompare: 0)
+                                .WithMessage("请输入有效的DiId!");
+            RuleFor(x => x.Country).NotEmpty()
+                                   .WithMessage("国家不能为空!");
+            RuleFor(x => x.Quantity).GreaterThan(valueToCompare: 0)
+                                    .WithMessage("请输入有效的Qauntity!");
         }
     }
 }

+ 140 - 2
OASystem/OASystem.Infrastructure/Repositories/Groups/VisaCommissionRepository.cs

@@ -1,4 +1,5 @@
 using AutoMapper;
+using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Groups;
 using System;
@@ -25,14 +26,151 @@ namespace OASystem.Infrastructure.Repositories.Groups
         }
 
         /// <summary>
-        /// 基础数据
+        /// Init
         /// </summary>
         /// <returns></returns>
-        public async Task<JsonView> _Init()
+        public async Task<JsonView> Init()
         {
             var groupInfo = await _groupRep.GetGroupNameList(new Domain.Dtos.Groups.GroupNameDto() { PortType = 1 });
 
             return new JsonView() { Code = StatusCodes.Status200OK, Msg = "操作成功!", Data = new { GroupData = groupInfo.Data } };
         }
+
+        /// <summary>
+        /// Item
+        /// </summary>
+        /// <returns></returns>
+        public async Task<JsonView> Item(VisaCommissionItemDto _dto)
+        {
+            var data = await _sqlSugar.Queryable<Grp_VisaCommission>()
+                                      .Where(x => x.IsDel == 0 && x.DiId == _dto.DiId && x.UId == _dto.CurrUserId)
+                                      .Select(x => new
+                                      {
+                                          x.Id,
+                                          x.Country,
+                                          x.Quantity,
+                                          x.Remark
+                                      })
+                                      .ToListAsync();
+
+            var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == _dto.DiId).FirstAsync();
+            if (groupInfo != null)
+            {
+                string[] countryArray = _groupRep.GroupSplitCountry(groupInfo.VisitCountry).ToArray();
+                foreach (string country in countryArray)
+                {
+                    if (data.Find(x => country.Equals(x.Country)) == null)
+                    {
+                        data.Add(new
+                        {
+                            Id = 0,
+                            Country = country,
+                            Quantity = 0,
+                            Remark = ""
+                        });
+                    }
+                }
+            }
+            return new JsonView() { Code = StatusCodes.Status200OK, Msg = "操作成功!", Data = data };
+        }
+
+
+        /// <summary>
+        /// Create
+        /// </summary>
+        /// <returns></returns>
+        public async Task<JsonView> Create(VisaCommissionCreateDto _dto)
+        {
+            var _view = new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "操作失败!" };
+
+            //添加查重
+            var info = await _sqlSugar.Queryable<Grp_VisaCommission>()
+                                      .Where(x => x.IsDel == 0 && x.DiId == _dto.DiId && x.Country.Equals(_dto.Country))
+                                      .FirstAsync();
+            //if (info != null)
+            //{
+            //    _view.Code = StatusCodes.Status400BadRequest;
+            //    _view.Msg = "该数据已存在请勿重新添加!";
+
+            //    return _view;
+            //}
+
+            var createInfo =  _mapper.Map<Grp_VisaCommission>(_dto);
+            createInfo.CreateUserId = _dto.CurrUserId;
+            createInfo.UId = _dto.CurrUserId;
+
+
+            var createStatus = await _sqlSugar.Insertable<Grp_VisaCommission>(createInfo)
+                                              .ExecuteCommandAsync();
+            if (createStatus > 0)
+            {
+                _view.Code = StatusCodes.Status200OK;
+                _view.Msg = "操作成功!";
+                return _view;
+            }
+            return _view;
+        }
+
+
+        /// <summary>
+        /// Edit
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="_dto"></param>
+        /// <returns></returns>
+        public async Task<JsonView> Edit(int id,VisaCommissionCreateDto _dto)
+        {
+            var _view = new JsonView() { Code = StatusCodes.Status204NoContent, Msg = "操作失败!" };
+
+            var editInfo = _mapper.Map<Grp_VisaCommission>(_dto);
+            editInfo.CreateUserId = _dto.CurrUserId;
+            editInfo.UId = _dto.CurrUserId;
+
+            var editStatus = await _sqlSugar.Updateable<Grp_VisaCommission>(editInfo)
+                                            .UpdateColumns(x => new
+                                            {
+                                                x.Country,
+                                                x.Quantity,
+                                                x.Remark
+                                            })
+                                            .Where(x => x.Id == id)
+                                            .ExecuteCommandAsync();
+            if (editStatus > 0)
+            {
+                _view.Code = StatusCodes.Status200OK;
+                _view.Msg = "操作成功!";
+                return _view;
+            }
+            return _view;
+        }
+
+        /// <summary>
+        /// Del
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="currUserId"></param>
+        /// <returns></returns>
+        public async Task<JsonView> Del(int id,int currUserId)
+        {
+            var _view = new JsonView() { Code = StatusCodes.Status204NoContent, Msg = "操作失败!" };
+
+            var editStatus = await _sqlSugar.Updateable<Grp_VisaCommission>()
+                                            .SetColumns(x => new Grp_VisaCommission
+                                            {
+                                                DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+                                                DeleteUserId = currUserId,
+                                            })
+                                            .Where(x => x.Id == id)
+                                            .ExecuteCommandAsync();
+            if (editStatus > 0)
+            {
+                _view.Code = StatusCodes.Status200OK;
+                _view.Msg = "操作成功!";
+                return _view;
+            }
+            return _view;
+        }
+
+
     }
 }