| | |
| | | using MES.Service.Modes; |
| | | using SqlSugar; |
| | | |
| | | namespace MES.Service.service; |
| | | namespace MES.Service.service.BasicData; |
| | | |
| | | public class OrganizeManager : Repository<SysOrganization> |
| | | { |
| | |
| | | if (UpdateOrganizetatus(db, entity.FNumber, "B")) |
| | | return 1; |
| | | break; |
| | | case "2": |
| | | if (InsertItem(db, entity)) |
| | | return 1; |
| | | break; |
| | | case "3": |
| | | if (DeleteItem(db, entity.FNumber)) |
| | | return 1; |
| | | break; |
| | | case "2": |
| | | case "4": |
| | | if (InsertOrUpdate(db, entity)) |
| | | return 1; |
| | |
| | | if (!UpdateOrganizetatusBatch(db, itemGroup.Value, "B")) |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (!InsertItemBatch(db, itemGroup.Value)) |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteItemBatch(db, itemGroup.Value)) |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "2": |
| | | case "4": |
| | | if (!InsertOrUpdateBatch(db, itemGroup.Value)) |
| | | throw new NotImplementedException("同步失败"); |
| | |
| | | private bool UpdateOrganizetatus(SqlSugarScope db, string number, |
| | | string status) |
| | | { |
| | | var equals = status.Equals("A"); |
| | | var result = db.Updateable<SysOrganization>() |
| | | .SetColumns(s => s.IsStatus == status.Equals("A")) |
| | | .SetColumns(s => s.IsStatus == equals) |
| | | .Where(s => s.FNumber == number).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | |
| | | Name = organize.FName, |
| | | FNumber = organize.FNumber, |
| | | FParentlD = organize.FParentID, |
| | | IsStatus = organize.FForbidStatus.Equals("A") |
| | | IsStatus = organize.FForbidStatus.Equals("A"), |
| | | Fid = organize.Id, |
| | | SynchronousDate = DateTime.Now |
| | | }; |
| | | } |
| | | |
| | |
| | | private bool InsertOrUpdateBatch(SqlSugarScope db, |
| | | List<SysOrganization> itemList) |
| | | { |
| | | foreach (var entity in itemList) |
| | | if (!InsertOrUpdate(db, entity)) |
| | | return false; |
| | | |
| | | return true; |
| | | return itemList.All(entity => InsertOrUpdate(db, entity)); |
| | | } |
| | | } |