|
@@ -85,21 +85,64 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
try
|
|
|
{
|
|
|
List<int> id = new List<int>();
|
|
|
- List<int> NewId = dto.UIdStr;
|
|
|
- List<Grp_GroupsTaskAssignment> _GroupsTaskAssignments = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(a=>a.DIId==dto.DIId).ToList();
|
|
|
+ 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.Id);
|
|
|
+ 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 = "未知错误" };
|
|
|
+ result = new Result() { Code = -2, Msg = "保存失败,未知错误" };
|
|
|
}
|
|
|
return result;
|
|
|
|