Browse Source

公务出访 --> 增加数据来源、翻译人员相关资料编辑、查看 代码编写;

LEIYI 2 weeks ago
parent
commit
4ec1062edf

+ 2 - 1
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -2024,13 +2024,14 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
             var data = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0).ToList();
             var data1 = data.Where(a => a.STid == 38).ToList();
             var data2 = data.Where(a => a.STid == 101).ToList();
+            var data3 = data.Where(a => a.STid == 66).ToList();
 
             var _DeleFile = _sqlSugar.Queryable<Grp_DeleFile>().Where(a => a.Diid == dto.DiId && a.IsDel == 0 && a.Category == 970).ToList();
 
             var translatorData = _sqlSugar.Queryable<Res_TranslatorLibrary>().Where(a => a.IsDel == 0).Select(x => new TranslatorLibraryNameView() { Id = x.Id, Name = x.Name }).ToList();
             foreach (var item in translatorData) EncryptionProcessor.DecryptProperties(item);
 
-            return Ok(JsonView(true, "查询成功!", new { Delegation = groupInfos, SetData = data1,DataSource = data2, DeleFile = _DeleFile , TranslatorData = translatorData }));
+            return Ok(JsonView(true, "查询成功!", new { Delegation = groupInfos, SetData = data1,DataSource = data2, currencyData = data3, DeleFile = _DeleFile , TranslatorData = translatorData }));
         }
 
         /// <summary>

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

@@ -192,6 +192,7 @@ namespace OASystem.Domain.AutoMappers
             CreateMap<OpinionaireUserSaveInfo, Grp_Opinionaire>();
             CreateMap<Res_TranslatorLibrary, TranslatorLibraryInfoView>();
             CreateMap<Res_TranslatorLibrary, TranslatorView>();
+            CreateMap<TranslatorView, Res_TranslatorLibrary>();
             #endregion
             #endregion
 

+ 5 - 0
OASystem/OASystem.Domain/Dtos/Resource/OfficialActivitiesDto.cs

@@ -27,6 +27,11 @@ namespace OASystem.Domain.Dtos.Resource
         /// 2 修改 
         /// </summary>
         public int Status { get; set; }
+
+        /// <summary>
+        /// 公务数据来源
+        /// </summary>
+        public int DataSource { get; set; }
         /// <summary>
         /// 编号
         /// </summary>

+ 109 - 52
OASystem/OASystem.Infrastructure/Repositories/Resource/OfficialActivitiesRepository.cs

@@ -223,8 +223,9 @@ FROM
             //翻译人员资料
             var translatorInfo = _mapper.Map<Res_TranslatorLibrary>(dto.TranslatorInfo);
             translatorInfo.CreateUserId = dto.CreateUserId;
-            //translatorInfo.
+            if (dto.TranslatorIdItem.Any()) translatorInfo.Id = dto.TranslatorIdItem[0];
 
+            EncryptionProcessor.EncryptProperties(translatorInfo);
 
             int DataID = 0;
             if (dto.Status == 1)//添加
@@ -241,26 +242,58 @@ FROM
                 }
                 else
                 {
-                    #region 新增(公务信息关联翻译人员) 关联信息
-
-                    if (dto.TranslatorIdItem != null && dto.TranslatorIdItem.Length > 0)
+                    var translatorId = translatorInfo.Id;
+                    if (translatorId > 0) // 翻译人员资料更新
                     {
-                        var officialDutyLinkTranslators = new List<Grp_OfficialDutyLinkTranslator>();
-                        foreach (var translatorId in dto.TranslatorIdItem)
-                        {
-                            officialDutyLinkTranslators.Add(new Grp_OfficialDutyLinkTranslator()
+                        var tiStatus = await _sqlSugar.Updateable<Res_TranslatorLibrary>(translatorInfo)
+                            .UpdateColumns(x => new
                             {
-                                TranslatorId = translatorId,
-                                OfficialDutyId = id,
-                                CreateUserId = dto.CreateUserId,
-                                Remark = $"公务出访客户资料-->添加"
-                            });
+                                x.Area,
+                                x.Name,
+                                x.Sex,
+                                x.Tel,
+                                x.Email,
+                                x.WechatNo,
+                                x.OtherSocialAccounts,
+                                x.Language,
+                                x.Price,
+                                x.Currency,
+                            })
+                            .ExecuteCommandAsync();
+
+                        if (tiStatus < 1)
+                        {
+                            _sqlSugar.RollbackTran();
+                            return new Result() { Code = -1, Msg = "翻译人员资料更新失败!", Data = new { Id = id } };
                         }
-                        if (officialDutyLinkTranslators.Count > 0)
+                    }
+                    else //添加翻译人员资料
+                    {
+                        translatorId = await _sqlSugar.Insertable(translatorInfo).ExecuteReturnIdentityAsync();
+                        if (translatorId == 0)
                         {
-                            await _sqlSugar.Insertable(officialDutyLinkTranslators).ExecuteCommandAsync();
+                            _sqlSugar.RollbackTran();
+                            return new Result() { Code = -1, Msg = "翻译人员资料添加失败!", Data = new { Id = id } };
                         }
                     }
+
+                    #region 新增(公务信息关联翻译人员) 关联信息
+
+                    var linkStatus = await _sqlSugar
+                        .Insertable(new Grp_OfficialDutyLinkTranslator()
+                        {
+                            TranslatorId = translatorId,
+                            OfficialDutyId = id,
+                            CreateUserId = dto.CreateUserId,
+                            Remark = $"公务出访客户资料-->添加"
+                        }).ExecuteCommandAsync();
+
+                    if (linkStatus < 1)
+                    {
+                        _sqlSugar.RollbackTran();
+                        return new Result() { Code = -1, Msg = "公务出访关联翻译人员资料添加失败!", Data = new { Id = id } };
+                    }
+                    
                     #endregion
 
 
@@ -277,12 +310,12 @@ FROM
                 }
                 else
                 {
-                    Res_InvitationOfficialActivityData ifNullUp = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
-                                                                                 .FirstAsync(a => a.Country == res_InvitationData.Country 
-                                                                                    && a.City == res_InvitationData.City 
-                                                                                    && a.UnitName == res_InvitationData.UnitName 
-                                                                                    && a.IsDel == 0 
-                                                                                    && a.Address == res_InvitationData.Address);
+                    var ifNullUp = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
+                        .FirstAsync(a => a.Country == res_InvitationData.Country 
+                           && a.City == res_InvitationData.City 
+                           && a.UnitName == res_InvitationData.UnitName 
+                           && a.IsDel == 0 
+                           && a.Address == res_InvitationData.Address);
                     if (ifNullUp != null)
                     {
                         res_InvitationData.Id = ifNullUp.Id;
@@ -314,10 +347,10 @@ FROM
                                     .ExecuteCommandAsync();
                 }
                
-
                 //公务出访
                 bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Res_OfficialActivities
                 {
+                    DataSource = dto.DataSource,
                     Country = dto.Country,
                     Area = dto.Area,
                     Type = dto.Type,
@@ -349,46 +382,70 @@ FROM
                 });
                 if (res)
                 {
-
                     #region 更新(公务信息关联翻译人员) 关联信息
 
-                    var officialDutyLinkTranslators_select = await _sqlSugar.Queryable<Grp_OfficialDutyLinkTranslator>()
-                        .Where(x => x.IsDel == 0 && x.OfficialDutyId == dto.Id)
-                        .ToListAsync();
-
-                    //删除
-                    var officialDutyLinkTranslatorIds = officialDutyLinkTranslators_select.Select(x => x.Id).ToList();
-                    if (officialDutyLinkTranslatorIds.Count > 0)
+                    if (translatorInfo.Id > 0) //资料更新
                     {
-                        await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
-                            .SetColumnsIF(officialDutyLinkTranslatorIds.Count > 0, x => new Grp_OfficialDutyLinkTranslator()
+                        var tiStatus = await _sqlSugar.Updateable<Res_TranslatorLibrary>(translatorInfo)
+                            .UpdateColumns(x => new
                             {
-                                DeleteUserId = dto.CreateUserId,
-                                DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
-                                IsDel = 1,
-                                Remark = $"公务出访客户资料-->删除"
+                                x.Area,
+                                x.Name,
+                                x.Sex,
+                                x.Tel,
+                                x.Email,
+                                x.WechatNo,
+                                x.OtherSocialAccounts,
+                                x.Language,
+                                x.Price,
+                                x.Currency,
                             })
-                            .Where(x => officialDutyLinkTranslatorIds.Contains(x.Id))
                             .ExecuteCommandAsync();
-                    }
 
-                    //添加
-                    if (dto.TranslatorIdItem != null && dto.TranslatorIdItem.Length > 0)
-                    {
-                        var officialDutyLinkTranslators = new List<Grp_OfficialDutyLinkTranslator>();
-                        foreach (var translatorId in dto.TranslatorIdItem)
+                        if (tiStatus < 1)
                         {
-                            officialDutyLinkTranslators.Add(new Grp_OfficialDutyLinkTranslator()
+                            _sqlSugar.RollbackTran();
+                            return new Result() { Code = -1, Msg = "翻译人员资料更新失败!", Data = new { Id = dto.Id } };
+                        }
+
+                        var dutyLink_select = await _sqlSugar.Queryable<Grp_OfficialDutyLinkTranslator>()
+                       .Where(x => x.IsDel == 0 && x.OfficialDutyId == dto.Id&& x.TranslatorId == translatorInfo.Id)
+                       .FirstAsync();
+                        if (dutyLink_select == null)
+                        {
+                            var odltStatus = await _sqlSugar.Insertable(new Grp_OfficialDutyLinkTranslator()
+                                {
+                                    TranslatorId = translatorInfo.Id,
+                                    OfficialDutyId = dto.Id,
+                                    CreateUserId = dto.CreateUserId,
+                                    Remark = $"公务出访客户资料-->添加"
+                                }).ExecuteCommandAsync();
+                            if (odltStatus < 1)
                             {
-                                TranslatorId = translatorId,
-                                OfficialDutyId = dto.Id,
-                                CreateUserId = dto.CreateUserId,
-                                Remark = $"公务出访客户资料-->更新"
-                            });
+                                _sqlSugar.RollbackTran();
+                                result = new Result() { Code = -1, Msg = "公务出访关联翻译人员资料添加失败!" };
+                            }
                         }
-                        if (officialDutyLinkTranslators.Count > 0)
+                    }
+                    else // 添加
+                    {
+                        translatorInfo.Id = await _sqlSugar.Insertable(translatorInfo).ExecuteReturnIdentityAsync();
+                        if (translatorInfo.Id == 0)
+                        {
+                            _sqlSugar.RollbackTran();
+                            return new Result() { Code = -1, Msg = "翻译人员资料添加失败!", Data = new { Id = dto.Id } };
+                        }
+                        var odltStatus = await _sqlSugar.Insertable(new Grp_OfficialDutyLinkTranslator()
+                        {
+                            TranslatorId = translatorInfo.Id,
+                            OfficialDutyId = dto.Id,
+                            CreateUserId = dto.CreateUserId,
+                            Remark = $"公务出访客户资料-->添加"
+                        }).ExecuteCommandAsync();
+                        if (odltStatus < 1)
                         {
-                            await _sqlSugar.Insertable(officialDutyLinkTranslators).ExecuteCommandAsync();
+                            _sqlSugar.RollbackTran();
+                            result = new Result() { Code = -1, Msg = "公务出访关联翻译人员资料添加失败!" };
                         }
                     }
                     #endregion
@@ -399,7 +456,7 @@ FROM
                 else
                 {
                     _sqlSugar.RollbackTran();
-                    result = new Result() { Code = -1, Msg = "修改失败!" };
+                    result = new Result() { Code = -1, Msg = "公务出访修改失败!" };
                 }
             }
             else