|
@@ -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
|