| | |
| | | public string Id { get; set; } |
| | | public string? Type { get; set; } |
| | | public string? FNumber { get; set; } |
| | | |
| | | public string? FName { get; set; } |
| | | |
| | | |
| | | public string? FAllowMinusQty { get; set; } |
| | | |
| | | public string? FPrincipal { get; set; } |
| | | |
| | | public string? FStockProperty { get; set; } |
| | | |
| | | public string? FForbidStatus { get; set; } |
| | | |
| | | public string? FGroup { get; set; } |
| | | |
| | | |
| | | public string? FCreateOrgId { get; set; } |
| | | |
| | | public string? FUseOrgId { get; set; } |
| | | } |
| | |
| | | { |
| | | |
| | | public string Id { get; set; } |
| | | /// <summary> |
| | | /// 0 启用 1禁用 2 审核 3反审核 |
| | | /// </summary> |
| | | public string? Type { get; set; } |
| | | |
| | | |
| | | public string? FNumber { get; set; } |
| | | |
| | | public string? FName { get; set; } |
| | | |
| | | public string? FDESCRIPTIONS { get; set; } |
| | | |
| | | public string? FDept { get; set; } |
| | | |
| | | public string? FCreateDate { get; set; } |
| | | |
| | | public string? FForbidderId { get; set; } |
| | | |
| | | public string? FForbidDate { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 禁用状态 A 启用 B禁用 |
| | | /// </summary> |
| | | public string? FForbidStatus { get; set; } |
| | | public string? FCreateOrgId { get; set; } |
| | | public string? FUseOrgId { get; set; } |
| | | } |
| | |
| | | public string? FRequireDeptId { get; set; } |
| | | public string? FReceiveOrgId { get; set; } |
| | | public string? FReceiveDeptId { get; set; } |
| | | public string? FEntrySettleOrgId { get; set; } |
| | | public string? Fsettleorgid { get; set; } |
| | | // end |
| | | public string? FGiveAway { get; set; } |
| | | public string? FNote { get; set; } |
| | |
| | | public string? FMRPTerminateStatus { get; set; } |
| | | public string? FTerminaterId { get; set; } |
| | | public string? FTerminateDate { get; set; } |
| | | public string? FBaseReceiveQty { get; set; } |
| | | public string? FReceiveQty { get; set; } |
| | | public string? FRemainReceiveQty { get; set; } |
| | | public string? FBaseStockInQty { get; set; } |
| | | public string? FStockInQty { get; set; } |
| | | public string? FRemainStockINQty { get; set; } |
| | | public string? FMrbQty { get; set; } |
| | | public string? FBaseCheckRetQty { get; set; } |
| | | public string? FBaseStockRetQty { get; set; } |
| | | public string? Fcheckretqty { get; set; } |
| | | public string? Fstockretqty { get; set; } |
| | | public string? FSrcBillTypeId { get; set; } |
| | | public string? FSrcBillNo { get; set; } |
| | | public string? FReqTraceNo { get; set; } |
| | |
| | | [SugarColumn(ColumnName = "REMARK5")] |
| | | public string? Remark5 { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 使用组织 |
| | | /// </summary> |
| | | [SugarColumn(ColumnName = "FUSEORGID")] |
| | | public string? FUserOrgId { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 创建组织 |
| | | /// </summary> |
| | | [SugarColumn(ColumnName = "FCREATEORGID")] |
| | | public string? FCreateOrgId { get; set; } |
| | | |
| | | [SugarColumn(IsIgnore = true)] public string? Type { get; set; } |
| | | } |
| | |
| | | public DateTime? ArriveDate { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 采购日期 |
| | | /// 收料组织 |
| | | /// </summary> |
| | | [SugarColumn(ColumnName = "RECEIVE_ORG")] |
| | | public decimal? ReceiveOrg { get; set; } |
| | |
| | | /// <summary> |
| | | /// 物料名称 |
| | | /// </summary> |
| | | // [SugarColumn(ColumnName = "ITEM_NAME")] |
| | | [SugarColumn(IsIgnore = true)] |
| | | public string? ItemName { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 物料规格 |
| | | /// </summary> |
| | | // [SugarColumn(ColumnName = "ITEM_SPEC")] |
| | | [SugarColumn(IsIgnore = true)] |
| | | public string? ItemSpec { get; set; } |
| | | |
| | |
| | | /// <summary> |
| | | /// SEQ_BASEINFO_ID |
| | | /// </summary> |
| | | [SugarColumn(ColumnName = "ID", OracleSequenceName = "SEQ_BASEINFO_ID", |
| | | IsPrimaryKey = true)] |
| | | [SugarColumn(ColumnName = "ID", OracleSequenceName = "SEQ_BASEINFO_ID",IsPrimaryKey = true)] |
| | | public decimal Id { get; set; } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | public bool Save(ErpCustomer customer) |
| | | { |
| | | var entity = GetSysDepartment(customer); |
| | | var entity = GetMesCustomer(customer); |
| | | |
| | | return UseTransaction(db => |
| | | { |
| | |
| | | return 1; |
| | | break; |
| | | case "3": |
| | | if (DeleteCustomer(db, entity.Id)) |
| | | if (UpdateCustomerStatus(db, entity.Id, "B")) |
| | | return 1; |
| | | break; |
| | | case "4": |
| | |
| | | return 1; |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{customer.Type}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{customer.Type}这个类型的参数"); |
| | | } |
| | | |
| | | throw new NotImplementedException("操作失败"); |
| | |
| | | |
| | | public bool SaveList(List<ErpCustomer> customers) |
| | | { |
| | | var list = customers.Select(GetSysDepartment).ToList(); |
| | | var groupBy = list.GroupBy(s => s.Type) |
| | | .ToDictionary(g => g.Key, g => g.ToList()); |
| | | var list = customers.Select(GetMesCustomer).ToList(); |
| | | |
| | | var groupBy = list.GroupBy(s => s.Type).ToDictionary(g => g.Key, g => g.ToList()); |
| | | |
| | | return UseTransaction(db => |
| | | { |
| | |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteCustomerBatch(db, customerGroup.Value)) |
| | | if (!UpdateCustomerStatusBatch(db, customerGroup.Value, "B")) |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "4": |
| | |
| | | throw new NotImplementedException("同步失败"); |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{customerGroup.Key}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{customerGroup.Key}这个类型的参数"); |
| | | } |
| | | |
| | | return 1; |
| | | }) > 0; |
| | | } |
| | | |
| | | private bool UpdateCustomerStatus(SqlSugarScope db, decimal customerId, |
| | | string status) |
| | | private bool UpdateCustomerStatus(SqlSugarScope db, decimal customerId,string status) |
| | | { |
| | | var result = db.Updateable<MesCustomer>() |
| | | .SetColumns(s => s.Fforbidstatus == status) |
| | | .Where(s => s.Id == customerId).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | var result = db.Updateable<MesCustomer>().SetColumns(s => s.Fforbidstatus == status).Where(s => s.Id == customerId).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | private bool InsertCustomer(SqlSugarScope db, MesCustomer entity) |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | var exists = db.Queryable<MesCustomer>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var result = db.Updateable<MesCustomer>().ExecuteCommand(); |
| | | return true; |
| | | |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private bool DeleteCustomer(SqlSugarScope db, decimal customerId) |
| | | private bool InsertOrUpdate(SqlSugarScope db, MesCustomer entity) |
| | | { |
| | | var deleteById = db.Deleteable<MesCustomer>().In(customerId) |
| | | .ExecuteCommand(); |
| | | if (deleteById > 0) |
| | | var exists = db.Queryable<MesCustomer>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | return true; |
| | | |
| | | throw new NotImplementedException("删除失败"); |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private MesCustomer GetSysDepartment(ErpCustomer customer) |
| | | private MesCustomer GetMesCustomer(ErpCustomer customer) |
| | | { |
| | | return new MesCustomer |
| | | { |
| | |
| | | }; |
| | | } |
| | | |
| | | private bool UpdateCustomerStatusBatch(SqlSugarScope db, |
| | | List<MesCustomer> customerList, string status) |
| | | private bool UpdateCustomerStatusBatch(SqlSugarScope db,List<MesCustomer> customerList, string status) |
| | | { |
| | | var ids = customerList.Select(it => it.Id).ToArray(); |
| | | var result = db.Updateable<MesCustomer>() |
| | | .SetColumns(s => s.Fforbidstatus == status) |
| | | .Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | var result = db.Updateable<MesCustomer>().SetColumns(s => s.Fforbidstatus == status).Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | private bool InsertCustomerBatch(SqlSugarScope db, |
| | | List<MesCustomer> customerList) |
| | | { |
| | | var insertRange = db.Insertable(customerList).ExecuteCommand(); |
| | | if (insertRange > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | |
| | | private bool DeleteCustomerBatch(SqlSugarScope db, |
| | | List<MesCustomer> customerList) |
| | | { |
| | | var ids = customerList.Select(it => it.Id).ToArray(); |
| | | var deleteByIds = db.Deleteable<MesCustomer>().In(ids).ExecuteCommand(); |
| | | if (deleteByIds > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("删除失败"); |
| | | } |
| | | |
| | | private bool InsertOrUpdate(SqlSugarScope db, MesCustomer entity) |
| | | { |
| | | var exists = db.Queryable<MesCustomer>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | if (update > 0) |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | private bool InsertOrUpdateBatch(SqlSugarScope db, |
| | | List<MesCustomer> customerList) |
| | | private bool InsertCustomerBatch(SqlSugarScope db,List<MesCustomer> customerList) |
| | | { |
| | | foreach (var entity in customerList) |
| | | if (!InsertOrUpdate(db, entity)) |
| | | { |
| | | if (!InsertCustomer(db, entity)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private bool InsertOrUpdateBatch(SqlSugarScope db,List<MesCustomer> customerList) |
| | | { |
| | | foreach (var entity in customerList) |
| | | { |
| | | if (!InsertOrUpdate(db, entity)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | |
| | | switch (depots.Type) |
| | | { |
| | | case "0": |
| | | if (UpdateDepotStatus(db, entity.DepotId, "A")) return 1; |
| | | |
| | | if (UpdateDepotStatus(db, entity.DepotId, "A")) |
| | | return 1; |
| | | break; |
| | | case "1": |
| | | if (UpdateDepotStatus(db, entity.DepotId, "B")) return 1; |
| | | |
| | | if (UpdateDepotStatus(db, entity.DepotId, "B")) |
| | | return 1; |
| | | break; |
| | | case "2": |
| | | if (InsertDepot(db, entity)) return 1; |
| | | |
| | | if (InsertDepot(db, entity)) |
| | | return 1; |
| | | break; |
| | | case "3": |
| | | if (DeleteDepot(db, entity.DepotId)) return 1; |
| | | |
| | | if (UpdateDepotStatus(db, entity.DepotId, "B")) |
| | | return 1; |
| | | break; |
| | | case "4": |
| | | if (InsertOrUpdate(db, entity)) return 1; |
| | | |
| | | if (InsertOrUpdate(db, entity)) |
| | | return 1; |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{depots.Type}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{depots.Type}这个类型的参数"); |
| | | } |
| | | |
| | | throw new NotImplementedException("操作失败"); |
| | |
| | | } |
| | | |
| | | // 更新仓库状态的方法 |
| | | private bool UpdateDepotStatus(SqlSugarScope db, decimal depotId, |
| | | string status) |
| | | private bool UpdateDepotStatus(SqlSugarScope db, decimal depotId,string status) |
| | | { |
| | | var result = db.Updateable<MesDepots>() |
| | | .SetColumns(s => s.IsNg == status) |
| | | .Where(s => s.DepotId == depotId).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | var result = db.Updateable<MesDepots>().SetColumns(s => s.IsNg == status).Where(s => s.DepotId == depotId).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | // 插入新仓库的方法 |
| | | private bool InsertDepot(SqlSugarScope db, MesDepots entity) |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("审核失败"); |
| | | } |
| | | |
| | | // 删除仓库的方法 |
| | | private bool DeleteDepot(SqlSugarScope db, decimal depotId) |
| | | { |
| | | var deleteById = db.Deleteable<MesDepots>().In(depotId) |
| | | .ExecuteCommand(); |
| | | if (deleteById > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("反审核失败"); |
| | | } |
| | | |
| | | // 插入或更新仓库的方法 |
| | | private bool InsertOrUpdate(SqlSugarScope db, MesDepots entity) |
| | | { |
| | | var exists = db.Queryable<MesDepots>() |
| | | .Any(e => e.DepotId == entity.DepotId); |
| | | var exists = db.Queryable<MesDepots>().Any(e => e.DepotId == entity.DepotId); |
| | | if (exists) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | if (update > 0) |
| | | return true; |
| | | var result = db.Updateable<MesDepots>().ExecuteCommand(); |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | // 插入或更新仓库的方法 |
| | | private bool InsertOrUpdate(SqlSugarScope db, MesDepots entity) |
| | | { |
| | | var exists = db.Queryable<MesDepots>().Any(e => e.DepotId == entity.DepotId); |
| | | if (exists) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 将 ErpDepots 对象转换为 MesDepots 对象的方法 |
| | |
| | | // SaveList 方法用于保存多个仓库记录,根据类型批量执行不同的操作 |
| | | public bool SaveList(List<ErpDepots> erpDepots) |
| | | { |
| | | var list = new List<MesDepots>(); |
| | | erpDepots.ForEach(s => |
| | | { |
| | | var entity = GetMesDepots(s); // 将 ErpDepots 转换为 MesDepots |
| | | entity.Type = s.Type; |
| | | list.Add(entity); |
| | | }); |
| | | |
| | | var groupBy = list.GroupBy(s => s.Type) |
| | | .ToDictionary(g => g.Key, g => g.ToList()); |
| | | var list = erpDepots.Select(GetMesDepots).ToList(); |
| | | var groupBy = list.GroupBy(s => s.Type).ToDictionary(g => g.Key, g => g.ToList()); |
| | | return UseTransaction(db => |
| | | { |
| | | foreach (var depotsGroup in groupBy) |
| | | switch (depotsGroup.Key) |
| | | { |
| | | case "0": |
| | | if (!UpdateDepotStatusBatch(db, depotsGroup.Value, |
| | | "A")) // 批量启用仓库 |
| | | if (!UpdateDepotStatusBatch(db, depotsGroup.Value,"A")) // 批量启用仓库 |
| | | throw new NotImplementedException("启用失败"); |
| | | break; |
| | | case "1": |
| | | if (!UpdateDepotStatusBatch(db, depotsGroup.Value, |
| | | "B")) // 批量禁用仓库 |
| | | if (!UpdateDepotStatusBatch(db, depotsGroup.Value,"B")) // 批量禁用仓库 |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (!InsertDepotBatch(db, |
| | | depotsGroup.Value)) // 批量插入仓库 |
| | | if (!InsertDepotBatch(db,depotsGroup.Value)) // 批量插入仓库 |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteDepotBatch(db, |
| | | depotsGroup.Value)) // 批量删除仓库 |
| | | if (!UpdateDepotStatusBatch(db, depotsGroup.Value, "B")) // 批量禁用仓库 |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "4": |
| | | if (!InsertOrUpdateBatch(db, |
| | | depotsGroup.Value)) // 批量插入或更新仓库 |
| | | if (!InsertOrUpdateBatch(db,depotsGroup.Value)) // 批量插入或更新仓库 |
| | | throw new NotImplementedException("同步失败"); |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{depotsGroup.Key}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{depotsGroup.Key}这个类型的参数"); |
| | | } |
| | | |
| | | return 1; |
| | |
| | | List<MesDepots> depotList, string status) |
| | | { |
| | | var ids = depotList.Select(it => it.DepotId).ToArray(); |
| | | var result = db.Updateable<MesDepots>() |
| | | .SetColumns(s => s.IsNg == status) |
| | | .Where(s => ids.Contains(s.DepotId)).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | var result = db.Updateable<MesDepots>().SetColumns(s => s.IsNg == status).Where(s => ids.Contains(s.DepotId)).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | // 批量插入仓库的方法 |
| | | private bool InsertDepotBatch(SqlSugarScope db, |
| | | List<MesDepots> depotList) |
| | | private bool InsertDepotBatch(SqlSugarScope db,List<MesDepots> depotList) |
| | | { |
| | | var insertRange = db.Insertable(depotList).ExecuteCommand(); |
| | | if (insertRange > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("审核失败"); |
| | | } |
| | | |
| | | // 批量删除仓库的方法 |
| | | private bool DeleteDepotBatch(SqlSugarScope db, |
| | | List<MesDepots> depotList) |
| | | { |
| | | var ids = depotList.Select(it => it.DepotId).ToArray(); |
| | | var deleteByIds = |
| | | db.Deleteable<MesDepots>().In(ids).ExecuteCommand(); |
| | | if (deleteByIds > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("反审核失败"); |
| | | return true; |
| | | } |
| | | |
| | | // 批量插入或更新仓库的方法 |
| | | private bool InsertOrUpdateBatch(SqlSugarScope db, |
| | | List<MesDepots> depotList) |
| | | private bool InsertOrUpdateBatch(SqlSugarScope db,List<MesDepots> depotList) |
| | | { |
| | | foreach (var entity in depotList) |
| | | { |
| | | if (!InsertOrUpdate(db, entity)) |
| | | { |
| | | return false; |
| | | |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | |
| | | { |
| | | public MesItems GetItemQcPrint(WarehouseQuery query) |
| | | { |
| | | return Db.Queryable<MesItems>() |
| | | .Where(c => c.Factory == query.Factory |
| | | && c.Company == query.Company |
| | | && c.ItemNo == query.ItemNo).First(); |
| | | return Db.Queryable<MesItems>().Where(c => c.Factory == query.Factory && c.Company == query.Company && c.ItemNo == query.ItemNo).First(); |
| | | } |
| | | |
| | | |
| | |
| | | return 1; |
| | | break; |
| | | case "3": |
| | | if (DeleteItem(db, entity.Id)) |
| | | if (UpdateItemStatus(db, entity.Id, "B")) |
| | | return 1; |
| | | break; |
| | | case "4": |
| | |
| | | return 1; |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{item.Type}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{item.Type}这个类型的参数"); |
| | | } |
| | | |
| | | throw new NotImplementedException("操作失败"); |
| | |
| | | public bool SaveList(List<ErpItems> items) |
| | | { |
| | | var list = items.Select(GetMesItems).ToList(); |
| | | var groupBy = list.GroupBy(s => s.Type) |
| | | .ToDictionary(g => g.Key, g => g.ToList()); |
| | | var groupBy = list.GroupBy(s => s.Type).ToDictionary(g => g.Key, g => g.ToList()); |
| | | |
| | | return UseTransaction(db => |
| | | { |
| | |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteItemBatch(db, itemGroup.Value)) |
| | | if (!UpdateItemStatusBatch(db, itemGroup.Value, "B")) |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "4": |
| | |
| | | throw new NotImplementedException("同步失败"); |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{itemGroup.Key}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{itemGroup.Key}这个类型的参数"); |
| | | } |
| | | |
| | | return 1; |
| | | }) > 0; |
| | | } |
| | | |
| | | private bool UpdateItemStatus(SqlSugarScope db, decimal itemId, |
| | | string status) |
| | | private bool UpdateItemStatus(SqlSugarScope db, decimal itemId,string status) |
| | | { |
| | | var result = db.Updateable<MesItems>() |
| | | .SetColumns(s => s.Fforbidstatus == status) |
| | | .Where(s => s.Id == itemId).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | var result = db.Updateable<MesItems>().SetColumns(s => s.Fforbidstatus == status).Where(s => s.Id == itemId).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | private bool InsertItem(SqlSugarScope db, MesItems entity) |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | var exists = db.Queryable<MesItems>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var result = db.Updateable<MesItems>().ExecuteCommand(); |
| | | return true; |
| | | |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private bool DeleteItem(SqlSugarScope db, decimal itemId) |
| | | private bool InsertOrUpdate(SqlSugarScope db, MesItems entity) |
| | | { |
| | | var deleteById = db.Deleteable<MesItems>().In(itemId).ExecuteCommand(); |
| | | if (deleteById > 0) |
| | | var exists = db.Queryable<Organize>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | return true; |
| | | |
| | | throw new NotImplementedException("删除失败"); |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private MesItems GetMesItems(ErpItems item) |
| | |
| | | }; |
| | | } |
| | | |
| | | private bool UpdateItemStatusBatch(SqlSugarScope db, |
| | | List<MesItems> itemList, string status) |
| | | private bool UpdateItemStatusBatch(SqlSugarScope db,List<MesItems> itemList, string status) |
| | | { |
| | | var ids = itemList.Select(it => it.Id).ToArray(); |
| | | var result = db.Updateable<MesItems>() |
| | | .SetColumns(s => s.Fforbidstatus == status) |
| | | .Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | var result = db.Updateable<MesItems>().SetColumns(s => s.Fforbidstatus == status).Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | private bool InsertItemBatch(SqlSugarScope db, List<MesItems> itemList) |
| | | { |
| | | var insertRange = db.Insertable(itemList).ExecuteCommand(); |
| | | if (insertRange > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | |
| | | private bool DeleteItemBatch(SqlSugarScope db, List<MesItems> itemList) |
| | | { |
| | | var ids = itemList.Select(it => it.Id).ToArray(); |
| | | var deleteByIds = db.Deleteable<MesItems>().In(ids).ExecuteCommand(); |
| | | if (deleteByIds > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("删除失败"); |
| | | } |
| | | |
| | | private bool InsertOrUpdate(SqlSugarScope db, MesItems entity) |
| | | { |
| | | var exists = db.Queryable<MesItems>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | foreach (var entity in itemList) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | if (update > 0) |
| | | return true; |
| | | if (!InsertItem(db, entity)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | return true; |
| | | } |
| | | |
| | | private bool InsertOrUpdateBatch(SqlSugarScope db, List<MesItems> itemList) |
| | | { |
| | | foreach (var entity in itemList) |
| | | { |
| | | if (!InsertOrUpdate(db, entity)) |
| | | { |
| | | return false; |
| | | |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | |
| | | |
| | | public class MesPositionManager : Repository<MesPosition> |
| | | { |
| | | // 当前类已经继承了 Repository 增、删、查、改的方法 |
| | | |
| | | // Save 方法用于保存单个岗位记录,根据类型执行不同的操作 |
| | | public bool Save(ErpPosition unit) |
| | | { |
| | | var entity = GetMesPosition(unit); // 将 ErpPosition 转换为 MesPosition |
| | |
| | | return 1; |
| | | break; |
| | | case "3": |
| | | if (DeletePosition(db, entity.Id)) // 删除岗位 |
| | | if (UpdatePositionStatus(db, entity.Id, "B")) // 删除岗位 |
| | | return 1; |
| | | break; |
| | | case "4": |
| | |
| | | return 1; |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{unit.Type}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{unit.Type}这个类型的参数"); |
| | | } |
| | | |
| | | throw new NotImplementedException("操作失败"); |
| | |
| | | } |
| | | |
| | | // 更新岗位状态的方法 |
| | | private bool UpdatePositionStatus(SqlSugarScope db, decimal positionId, |
| | | string status) |
| | | private bool UpdatePositionStatus(SqlSugarScope db, decimal positionId , string status) |
| | | { |
| | | var result = db.Updateable<MesPosition>() |
| | | .SetColumns(s => s.Fforbidstatus == status) |
| | | .Where(s => s.Id == positionId).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | var result = db.Updateable<MesPosition>().SetColumns(s => s.Fforbidstatus == status).Where(s => s.Id == positionId).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | // 插入或更新岗位的方法 |
| | |
| | | if (exists) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | if (update > 0) |
| | | return true; |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | // 删除岗位的方法 |
| | | private bool DeletePosition(SqlSugarScope db, decimal positionId) |
| | | { |
| | | var deleteById = db.Deleteable<MesPosition>().In(positionId) |
| | | .ExecuteCommand(); |
| | | if (deleteById > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("删除失败"); |
| | | } |
| | | |
| | | // 将 ErpPosition 对象转换为 MesPosition 对象的方法 |
| | |
| | | Department = position.FDept, |
| | | Fforbidstatus = position.FForbidStatus, |
| | | CreationDate = DateTime.Now, |
| | | DisabledBy = position.FForbidderId, |
| | | DisabledDate = position.FForbidDate != null? DateTime.ParseExact(position.FForbidDate, "yyyy-MM-dd HH:mm:ss", null) : null |
| | | FCreateOrgId = position.FCreateOrgId, |
| | | FUserOrgId = position.FUseOrgId |
| | | |
| | | }; |
| | | } |
| | | |
| | |
| | | public bool SaveList(List<ErpPosition> positions) |
| | | { |
| | | var list = new List<MesPosition>(); |
| | | positions.ForEach(s => |
| | | { |
| | | var entity = GetMesPosition(s); // 将 ErpPosition 转换为 MesPosition |
| | | entity.Type = s.Type; |
| | | list.Add(entity); |
| | | }); |
| | | |
| | | var groupBy = list.GroupBy(s => s.Type) |
| | | .ToDictionary(g => g.Key, g => g.ToList()); |
| | | var groupBy = list.GroupBy(s => s.Type).ToDictionary(g => g.Key, g => g.ToList()); |
| | | return UseTransaction(db => |
| | | { |
| | | foreach (var positionGroup in groupBy) |
| | | switch (positionGroup.Key) |
| | | { |
| | | case "0": |
| | | if (!UpdatePositionStatusBatch(db, positionGroup.Value, |
| | | "A")) // 批量启用岗位 |
| | | if (!UpdatePositionStatusBatch(db, positionGroup.Value,"A")) // 批量启用岗位 |
| | | throw new NotImplementedException("启用失败"); |
| | | break; |
| | | case "1": |
| | | if (!UpdatePositionStatusBatch(db, positionGroup.Value, |
| | | "B")) // 批量禁用岗位 |
| | | if (!UpdatePositionStatusBatch(db, positionGroup.Value,"B")) // 批量禁用岗位 |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (!InsertPositionBatch(db, |
| | | positionGroup.Value)) // 批量插入岗位 |
| | | if (!InsertOrUpdatePositionBatch(db, positionGroup.Value)) // 批量插入或更新岗位 |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeletePositionBatch(db, |
| | | positionGroup.Value)) // 批量删除岗位 |
| | | if (!UpdatePositionStatusBatch(db, positionGroup.Value, "B")) // 批量禁用岗位 |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "4": |
| | | if (!InsertOrUpdatePositionBatch(db, |
| | | positionGroup.Value)) // 批量插入或更新岗位 |
| | | if (!InsertOrUpdatePositionBatch(db,positionGroup.Value)) // 批量插入或更新岗位 |
| | | throw new NotImplementedException("同步失败"); |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{positionGroup.Key}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{positionGroup.Key}这个类型的参数"); |
| | | } |
| | | |
| | | return 1; |
| | |
| | | } |
| | | |
| | | // 批量更新岗位状态的方法 |
| | | private bool UpdatePositionStatusBatch(SqlSugarScope db, |
| | | List<MesPosition> positionList, string status) |
| | | private bool UpdatePositionStatusBatch(SqlSugarScope db,List<MesPosition> positionList, string status) |
| | | { |
| | | var ids = positionList.Select(it => it.Id).ToArray(); |
| | | var result = db.Updateable<MesPosition>() |
| | | .SetColumns(s => s.Fforbidstatus == status) |
| | | .Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | var result = db.Updateable<MesPosition>().SetColumns(s => s.Fforbidstatus == status).Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | return true; |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | } |
| | | |
| | | // 批量插入岗位的方法 |
| | | private bool InsertPositionBatch(SqlSugarScope db, |
| | | List<MesPosition> positionList) |
| | | { |
| | | var insertRange = db.Insertable(positionList).ExecuteCommand(); |
| | | if (insertRange > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | |
| | | // 批量删除岗位的方法 |
| | | private bool DeletePositionBatch(SqlSugarScope db, |
| | | List<MesPosition> positionList) |
| | | { |
| | | var ids = positionList.Select(it => it.Id).ToArray(); |
| | | var deleteByIds = db.Deleteable<MesPosition>().In(ids).ExecuteCommand(); |
| | | if (deleteByIds > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("删除失败"); |
| | | } |
| | | |
| | | // 批量插入或更新岗位的方法 |
| | | private bool InsertOrUpdatePositionBatch(SqlSugarScope db, |
| | | List<MesPosition> positionList) |
| | | private bool InsertOrUpdatePositionBatch(SqlSugarScope db,List<MesPosition> positionList) |
| | | { |
| | | foreach (var entity in positionList) |
| | | { |
| | | if (!InsertOrUpdatePosition(db, entity)) |
| | | { |
| | | return false; |
| | | |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | |
| | | public class MesRohInManager : Repository<MesRohIn> |
| | | { |
| | | private readonly MesRohInDataManager rohInDataManager = new(); |
| | | |
| | | // Save 方法用于保存单个 RohIn 记录,根据类型执行不同的操作 |
| | | public bool Save(RohIn rohIn) |
| | | { |
| | | var rohInErpRohIn = rohIn.ErpRohIn; |
| | |
| | | { |
| | | switch (rohInErpRohIn.Type) |
| | | { |
| | | // case "2": |
| | | // return InsertData(db, mesRohIn, mesRohInDatas, |
| | | // rohInErpRohIn.FBILLTYPE) |
| | | // ? 1 |
| | | // : 0; |
| | | case "3": |
| | | return UpdateData(db, mesRohIn, mesRohInDatas) ? 1 : 0; |
| | | case "2": |
| | | case "4": |
| | | case "5": |
| | | case "B": |
| | | return SaveOrUpdateData(db, mesRohIn, mesRohInDatas) |
| | | ? 1 |
| | | : 0; |
| | | return SaveOrUpdateData(db, mesRohIn, mesRohInDatas) ? 1 : 0; |
| | | default: |
| | | throw new NotImplementedException( |
| | | $"type没有{rohInErpRohIn.Type}这个类型"); |
| | | throw new NotImplementedException($"type没有{rohInErpRohIn.Type}这个类型"); |
| | | } |
| | | }) > 0; |
| | | } |
| | | |
| | | // 插入数据的方法 |
| | | private bool InsertData(SqlSugarScope db, MesRohIn mesRohIn, |
| | | List<MesRohInData> mesRohInDatas, string FBILLTYPE) |
| | | { |
| | | switch (FBILLTYPE) |
| | | { |
| | | case "A": |
| | | { |
| | | var decimals = mesRohInDatas.Select(s => s.Id).ToArray(); |
| | | |
| | | if (mesRohIn.Id != null) base.DeleteById(mesRohIn.Id); |
| | | |
| | | if (decimals.Length > 0) |
| | | db.Deleteable<MesRohInData>().In(decimals).ExecuteCommand(); |
| | | |
| | | var insert = base.Insert(mesRohIn); |
| | | var insertRange = |
| | | rohInDataManager.InsertRange(mesRohInDatas); |
| | | |
| | | if (insert && insertRange) return true; |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | case "B": |
| | | { |
| | | var decimals = mesRohInDatas.Select(s => s.Id).ToArray(); |
| | | if (base.DeleteById(mesRohIn.Id) && db |
| | | .Deleteable<MesRohInData>().In(decimals) |
| | | .ExecuteCommand() > 0) |
| | | { |
| | | var insert = base.Insert(mesRohIn); |
| | | var insertRange = |
| | | rohInDataManager.InsertRange(mesRohInDatas); |
| | | |
| | | if (insert && insertRange) return true; |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | throw new NotImplementedException("采购订单类型错误"); |
| | | } |
| | | |
| | | |
| | | // 更新数据的方法 |
| | | private bool UpdateData(SqlSugarScope db, MesRohIn mesRohIn, |
| | | List<MesRohInData> mesRohInDatas) |
| | | private bool UpdateData(SqlSugarScope db, MesRohIn mesRohIn,List<MesRohInData> mesRohInDatas) |
| | | { |
| | | var decimals = mesRohInDatas.Select(s => s.Id).ToArray(); |
| | | var update = base.DeleteById(mesRohIn.Id); |
| | | var insertOrUpdate = db |
| | | .Deleteable<MesRohInData>().In(decimals) |
| | | .ExecuteCommand() > 0; |
| | | var insertOrUpdate = db.Deleteable<MesRohInData>().In(decimals).ExecuteCommand() > 0; |
| | | |
| | | if (update && insertOrUpdate) return true; |
| | | if (update && insertOrUpdate) |
| | | { |
| | | return true; |
| | | } |
| | | throw new NotImplementedException("更新失败"); |
| | | } |
| | | |
| | | // 插入或更新数据的方法 |
| | | private bool SaveOrUpdateData(SqlSugarScope db, MesRohIn mesRohIn, |
| | | List<MesRohInData> mesRohInDatas) |
| | | private bool SaveOrUpdateData(SqlSugarScope db, MesRohIn mesRohIn,List<MesRohInData> mesRohInDatas) |
| | | { |
| | | if (mesRohIn.Id != null) base.DeleteById(mesRohIn.Id); |
| | | if (mesRohIn.Id != null) |
| | | { |
| | | base.DeleteById(mesRohIn.Id); |
| | | } |
| | | |
| | | if (mesRohInDatas.Count > 0) |
| | | db.Deleteable<MesRohInData>() |
| | | .Where(s => s.ErpId == mesRohIn.EbelnK3id).ExecuteCommand(); |
| | | |
| | | { |
| | | db.Deleteable<MesRohInData>().Where(s => s.ErpId == mesRohIn.EbelnK3id).ExecuteCommand(); |
| | | } |
| | | var orUpdate = base.Insert(mesRohIn); |
| | | var baOrUpdate = rohInDataManager.InsertRange(mesRohInDatas); |
| | | if (orUpdate && baOrUpdate) return true; |
| | |
| | | var mesRohIn = new MesRohIn(); |
| | | |
| | | var single = base.GetSingle(it => it.EbelnK3id == eid); |
| | | if (single != null) mesRohIn.Id = single.Id; |
| | | if (single != null) |
| | | { |
| | | mesRohIn.Id = single.Id; |
| | | } |
| | | |
| | | mesRohIn.EbelnK3id = eid; |
| | | mesRohIn.BillNo = rohIn.FBillNo; |
| | |
| | | mesRohIn.DocumentType = rohIn.FBillTypeID; |
| | | mesRohIn.BusinessType = rohIn.FBusinessType; |
| | | if (rohIn.FDate != null) |
| | | mesRohIn.PurchaseDate = DateTime.ParseExact(rohIn.FDate,"yyyy-MM-dd HH:mm:ss", null); |
| | | { |
| | | mesRohIn.PurchaseDate = DateTime.ParseExact(rohIn.FDate, "yyyy-MM-dd HH:mm:ss", null); |
| | | } |
| | | mesRohIn.Supplier = rohIn.FSupplierId; |
| | | mesRohIn.CloseStatus = rohIn.FCloseStatus; |
| | | mesRohIn.PurchaseOrg = rohIn.FPurchaseOrgId; |
| | |
| | | mesRohIn.CancellationPerson = rohIn.FCancellerId; |
| | | |
| | | if (rohIn.FCancelDate != null) |
| | | mesRohIn.CancellationDate = |
| | | DateTime.ParseExact(rohIn.FCancelDate, |
| | | "yyyy-MM-dd HH:mm:ss", null); |
| | | |
| | | { |
| | | mesRohIn.CancellationDate = DateTime.ParseExact(rohIn.FCancelDate, "yyyy-MM-dd HH:mm:ss", null); |
| | | } |
| | | mesRohIn.CreateBy = rohIn.FCreatorId; |
| | | mesRohIn.LastupdateBy = rohIn.FModifierId; |
| | | |
| | | if (rohIn.FModifyDate != null) |
| | | mesRohIn.LastupdateDate = DateTime.ParseExact(rohIn.FModifyDate, |
| | | "yyyy-MM-dd HH:mm:ss", null); |
| | | |
| | | { |
| | | mesRohIn.LastupdateDate = DateTime.ParseExact(rohIn.FModifyDate, "yyyy-MM-dd HH:mm:ss", null); |
| | | } |
| | | mesRohIn.ErpCheckBy = rohIn.FApproverId; |
| | | mesRohIn.ErpCheckDate = rohIn.FApproveDate; |
| | | mesRohIn.Changereason = rohIn.FChangeReason; |
| | |
| | | } |
| | | |
| | | // 将 ErpRohinData 对象转换为 MesRohInData 对象的方法 |
| | | public List<MesRohInData> GetMesRohInDatas( |
| | | List<ErpRohinData> erpRohinDatas, string type) |
| | | public List<MesRohInData> GetMesRohInDatas(List<ErpRohinData> erpRohinDatas, string type) |
| | | { |
| | | return erpRohinDatas.Select(s => |
| | | { |
| | |
| | | InventoryUnit = s.FStockUnitID, |
| | | PricingUnit = s.FPriceUnitId, |
| | | PricingQty = Convert.ToDecimal(s.FPriceUnitQty), |
| | | DeliveryDate = s.FDeliveryDate != null |
| | | ? DateTime.ParseExact(s.FDeliveryDate, |
| | | "yyyy-MM-dd HH:mm:ss", null) |
| | | : null, |
| | | EarliestDeliveryDate = s.FDeliveryEarlyDate != null |
| | | ? DateTime.ParseExact(s.FDeliveryEarlyDate, |
| | | "yyyy-MM-dd HH:mm:ss", null) |
| | | : null, |
| | | LatestDeliveryDate = s.FDeliveryLastDate != null |
| | | ? DateTime.ParseExact(s.FDeliveryLastDate, |
| | | "yyyy-MM-dd HH:mm:ss", null) |
| | | : null, |
| | | DeliveryDate = s.FDeliveryDate != null ? DateTime.ParseExact(s.FDeliveryDate,"yyyy-MM-dd HH:mm:ss", null) : null, |
| | | EarliestDeliveryDate = s.FDeliveryEarlyDate != null ? DateTime.ParseExact(s.FDeliveryEarlyDate,"yyyy-MM-dd HH:mm:ss", null) : null, |
| | | LatestDeliveryDate = s.FDeliveryLastDate != null ? DateTime.ParseExact(s.FDeliveryLastDate, "yyyy-MM-dd HH:mm:ss", null) : null, |
| | | IsGift = s.FGiveAway, |
| | | Remarks = s.FNote, |
| | | SupplierItemCode = s.FSupMatId, |
| | |
| | | BusinessClose = s.FMRPCloseStatus, |
| | | BusinessFreeze = s.FMRPFreezeStatus, |
| | | Freezer = s.FFreezerId, |
| | | FreezeTime = s.FFreezeDate != null |
| | | ? DateTime.ParseExact(s.FFreezeDate, |
| | | "yyyy-MM-dd HH:mm:ss", null) |
| | | : null, |
| | | FreezeTime = s.FFreezeDate != null ? DateTime.ParseExact(s.FFreezeDate,"yyyy-MM-dd HH:mm:ss", null) : null, |
| | | BusinessTerminate = s.FMRPTerminateStatus, |
| | | Terminator = s.FTerminaterId, |
| | | TerminateTime = s.FTerminateDate != null |
| | | ? DateTime.ParseExact(s.FTerminateDate, |
| | | "yyyy-MM-dd HH:mm:ss", null) |
| | | : null, |
| | | TerminateTime = s.FTerminateDate != null ? DateTime.ParseExact(s.FTerminateDate,"yyyy-MM-dd HH:mm:ss", null) : null, |
| | | TotalReceivedQty = Convert.ToDecimal(s.FQty)-Convert.ToDecimal(s.FRemainReceiveQty), |
| | | RemainingReceivedQty = Convert.ToDecimal(s.FRemainReceiveQty), |
| | | TotalStoredQty = Convert.ToDecimal(s.FQty) - Convert.ToDecimal(s.FRemainStockINQty), |
| | | RemainingStoredQty = Convert.ToDecimal(s.FRemainStockINQty), |
| | | TotalReturnedQty = Convert.ToDecimal(s.FMrbQty), |
| | | ReturnableReceivedQty = Convert.ToDecimal(s.FBaseCheckRetQty), |
| | | ReturnableStoredQty = Convert.ToDecimal(s.FBaseStockRetQty), |
| | | ReturnableReceivedQty = Convert.ToDecimal(s.Fcheckretqty), |
| | | ReturnableStoredQty = Convert.ToDecimal(s.Fstockretqty), |
| | | SourceDocumentType = s.FSrcBillTypeId, |
| | | SourceDocumentId = s.FSrcBillNo, |
| | | DemandTrackingId = s.FReqTraceNo, |
| | |
| | | DemandOrg = s.FRequireOrgId, |
| | | Receiving = s.FReceiveOrgId, |
| | | ReceivingOrg = s.FReceiveOrgId, |
| | | Settlement = s.FEntrySettleOrgId, |
| | | SettlementOrg = s.FEntrySettleOrgId, |
| | | Settlement = s.Fsettleorgid, |
| | | SettlementOrg = s.Fsettleorgid, |
| | | DemandDept = s.FRequireDeptId, |
| | | ReceivingDept = s.FReceiveDeptId |
| | | }; |
| | | |
| | | var single = rohInDataManager.GetSingle(it => |
| | | it.EbelnK3id == entity.EbelnK3id); |
| | | if (single != null) entity.Id = single.Id; |
| | | var single = rohInDataManager.GetSingle(it =>it.EbelnK3id == entity.EbelnK3id); |
| | | if (single != null) |
| | | { |
| | | entity.Id = single.Id; |
| | | } |
| | | |
| | | return entity; |
| | | }).ToList(); |
| | |
| | | return 1; |
| | | break; |
| | | case "3": |
| | | if (DeleteStaff(db, entity.Id)) // 删除员工 |
| | | if (UpdateStaffStatus(db, entity.Id, "B")) // 禁用员工 |
| | | return 1; |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{unit.Type}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{unit.Type}这个类型的参数"); |
| | | } |
| | | |
| | | throw new NotImplementedException("操作失败"); |
| | |
| | | private bool UpdateStaffStatus(SqlSugarScope db, decimal staffId,string status) |
| | | { |
| | | var result = db.Updateable<MesStaff>().SetColumns(s => s.FforbidStatus == status).Where(s => s.Id == staffId).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | { |
| | | return true; |
| | | } |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | return true; |
| | | } |
| | | |
| | | // 插入或更新员工的方法 |
| | | private bool InsertOrUpdateStaff(SqlSugarScope db,MesStaff entity) |
| | | { |
| | | var exists = db.Queryable<MesStaff>().Any(u => u.StaffNo == entity.StaffNo); |
| | | var exists = db.Queryable<MesStaff>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var updateStaff = db.Updateable(entity).ExecuteCommand(); |
| | | if (updateStaff > 0) |
| | | { |
| | | return true; |
| | | } |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | var insertStaff = db.Insertable(entity).ExecuteCommand(); |
| | | if (insertStaff > 0) |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | // 删除员工的方法 |
| | | private bool DeleteStaff(SqlSugarScope db,decimal staffId) |
| | | { |
| | | var deleteStaff =db.Deleteable<MesStaff>().In(staffId).ExecuteCommand(); |
| | | if (deleteStaff > 0) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | throw new NotImplementedException("反审核失败"); |
| | | } |
| | | |
| | | // 将 ErpStaff 对象转换为 MesStaff 对象的方法 |
| | |
| | | } |
| | | |
| | | // SaveList 方法用于保存多个员工记录,根据类型批量执行不同的操作 |
| | | public bool SaveList(List<ErpStaff> departments) |
| | | public bool SaveList(List<ErpStaff> staffs) |
| | | { |
| | | var list = new List<MesStaff>(); |
| | | |
| | | departments.ForEach(s => |
| | | { |
| | | var entity = GetMesStaff(s); |
| | | entity.Type = s.Type; |
| | | list.Add(entity); |
| | | |
| | | }); |
| | | |
| | | var list = staffs.Select(GetMesStaff).ToList(); |
| | | var groupBy = list.GroupBy(s => s.Type).ToDictionary(g => g.Key, g => g.ToList()); |
| | | return UseTransaction(db => |
| | | { |
| | |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteStaffBatch(db,staffGroup.Value)) // 批量删除员工 |
| | | if (!UpdateStaffStatusBatch(db, staffGroup.Value, "B")) // 批量禁用员工 |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "4": |
| | |
| | | { |
| | | var ids = staffList.Select(it => it.Id).ToArray(); |
| | | var result = db.Updateable<MesStaff>().SetColumns(s => s.FforbidStatus == status).Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | return true; |
| | | |
| | | } |
| | | |
| | | // 批量插入员工的方法 |
| | | private bool InsertStaffBatch(SqlSugarScope db,List<MesStaff> staffList) |
| | | { |
| | | var userInsert = staffList.FindAll(s => s.Type == "INSERT"); |
| | | var executeCommand = db.Insertable(userInsert).ExecuteCommand(); |
| | | if (executeCommand > 0) |
| | | if (db.Insertable(staffList).ExecuteCommand() > 0) |
| | | return true; |
| | | |
| | | throw new ArgumentNullException("审核失败"); |
| | | } |
| | | |
| | | // 批量删除员工的方法 |
| | | private bool DeleteStaffBatch(SqlSugarScope db, List<MesStaff> staffList) |
| | | { |
| | | var ids = staffList.Select(it => it.Id).ToArray(); |
| | | if (db.Deleteable<MesStaff>().In(ids).ExecuteCommand() > 0) |
| | | foreach (var entity in staffList) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | throw new ArgumentNullException("反审核失败"); |
| | | } |
| | | |
| | | // 批量插入或更新员工的方法 |
| | | private bool InsertOrUpdateBatch(SqlSugarScope db, List<MesStaff> staffList) |
| | | { |
| | | foreach (var staff in staffList) |
| | | { |
| | | var entity = staffList.First(s => s.StaffNo == staff.StaffNo); |
| | | if (!InsertOrUpdateStaff(db, entity)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | // 批量插入或更新员工的方法 |
| | | private bool InsertOrUpdateBatch(SqlSugarScope db, List<MesStaff> staffList) |
| | | { |
| | | foreach (var entity in staffList) |
| | | { |
| | | if (!InsertOrUpdateStaff(db, entity)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | |
| | | using MES.Service.Dto.webApi; |
| | | using MES.Service.Modes; |
| | | using SqlSugar; |
| | | using System.Collections.Generic; |
| | | |
| | | namespace MES.Service.service.BasicData; |
| | | |
| | |
| | | return 1; |
| | | break; |
| | | case "3": |
| | | if (DeleteSupplier(entity.Id)) |
| | | if (UpdateSupplierStatus(db, entity.Id, "B")) |
| | | return 1; |
| | | break; |
| | | case "4": |
| | |
| | | return 1; |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{unit.Type}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{unit.Type}这个类型的参数"); |
| | | } |
| | | |
| | | throw new NotImplementedException("操作失败"); |
| | | }) > 0; |
| | | } |
| | |
| | | public bool SaveList(List<ErpSupplier> suppliers) |
| | | { |
| | | var list = suppliers.Select(GetMesSupplier).ToList(); |
| | | var groupBy = list.GroupBy(s => s.Type) |
| | | .ToDictionary(g => g.Key, g => g.ToList()); |
| | | var groupBy = list.GroupBy(s => s.Type).ToDictionary(g => g.Key, g => g.ToList()); |
| | | |
| | | return UseTransaction(db => |
| | | { |
| | |
| | | switch (supplierGroup.Key) |
| | | { |
| | | case "0": |
| | | if (!UpdateSupplierStatusBatch(db, supplierGroup.Value, |
| | | "A")) |
| | | if (!UpdateSupplierStatusBatch(db, supplierGroup.Value,"A")) |
| | | throw new NotImplementedException("启用失败"); |
| | | break; |
| | | case "1": |
| | | if (!UpdateSupplierStatusBatch(db, supplierGroup.Value, |
| | | "B")) |
| | | if (!UpdateSupplierStatusBatch(db, supplierGroup.Value,"B")) |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteSupplierBatch(db, supplierGroup.Value)) |
| | | if (!UpdateSupplierStatusBatch(db, supplierGroup.Value, "B")) |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "4": |
| | |
| | | throw new NotImplementedException("同步失败"); |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{supplierGroup.Key}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{supplierGroup.Key}这个类型的参数"); |
| | | } |
| | | |
| | | return 1; |
| | | }) > 0; |
| | | } |
| | | |
| | | private bool UpdateSupplierStatus(SqlSugarScope db, decimal supplierId, |
| | | string status) |
| | | private bool UpdateSupplierStatus(SqlSugarScope db, decimal supplierId,string status) |
| | | { |
| | | var result = db.Updateable<MesSupplier>() |
| | | .SetColumns(s => s.Fforbidstatus == status) |
| | | .Where(s => s.Id == supplierId).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | var result = db.Updateable<MesSupplier>().SetColumns(s => s.Fforbidstatus == status).Where(s => s.Id == supplierId).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | private bool InsertSupplier(SqlSugarScope db, MesSupplier entity) |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | var exists = db.Queryable<MesSupplier>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var result = db.Updateable<MesSupplier>().ExecuteCommand(); |
| | | return true; |
| | | |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private bool DeleteSupplier(decimal supplierId) |
| | | private bool InsertOrUpdate(SqlSugarScope db, MesSupplier entity) |
| | | { |
| | | if (base.DeleteById(supplierId)) return true; |
| | | |
| | | throw new NotImplementedException("删除失败"); |
| | | var exists = db.Queryable<MesSupplier>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private MesSupplier GetMesSupplier(ErpSupplier supplier) |
| | |
| | | }; |
| | | } |
| | | |
| | | private bool UpdateSupplierStatusBatch(SqlSugarScope db, |
| | | List<MesSupplier> supplierList, string status) |
| | | private bool UpdateSupplierStatusBatch(SqlSugarScope db,List<MesSupplier> supplierList, string status) |
| | | { |
| | | var ids = supplierList.Select(it => it.Id).ToArray(); |
| | | var result = db.Updateable<MesSupplier>() |
| | | .SetColumns(s => s.Fforbidstatus == status) |
| | | .Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | var result = db.Updateable<MesSupplier>().SetColumns(s => s.Fforbidstatus == status).Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | private bool InsertSupplierBatch(SqlSugarScope db, |
| | | List<MesSupplier> supplierList) |
| | | { |
| | | var insertRange = db.Insertable(supplierList).ExecuteCommand(); |
| | | if (insertRange > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | |
| | | private bool DeleteSupplierBatch(SqlSugarScope db, |
| | | List<MesSupplier> supplierList) |
| | | { |
| | | var ids = supplierList.Select(it => it.Id).ToArray(); |
| | | var deleteByIds = db.Deleteable<MesSupplier>().In(ids).ExecuteCommand(); |
| | | if (deleteByIds > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("删除失败"); |
| | | } |
| | | |
| | | private bool InsertOrUpdate(SqlSugarScope db, MesSupplier entity) |
| | | { |
| | | var exists = db.Queryable<MesSupplier>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | if (update > 0) |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | private bool InsertOrUpdateBatch(SqlSugarScope db, |
| | | List<MesSupplier> supplierList) |
| | | private bool InsertSupplierBatch(SqlSugarScope db,List<MesSupplier> supplierList) |
| | | { |
| | | foreach (var entity in supplierList) |
| | | if (!InsertOrUpdate(db, entity)) |
| | | { |
| | | if (!InsertSupplier(db, entity)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private bool InsertOrUpdateBatch(SqlSugarScope db,List<MesSupplier> supplierList) |
| | | { |
| | | foreach (var entity in supplierList) |
| | | { |
| | | if (!InsertOrUpdate(db, entity)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | |
| | | return 1; |
| | | break; |
| | | case "3": |
| | | if (DeleteUnit(db, entity.Id)) |
| | | if (UpdateUnitStatus(db, entity.Id, "B")) |
| | | return 1; |
| | | break; |
| | | case "4": |
| | |
| | | return 1; |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{unit.Type}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{unit.Type}这个类型的参数"); |
| | | } |
| | | |
| | | throw new NotImplementedException("操作失败"); |
| | |
| | | public bool SaveList(List<ErpUnit> units) |
| | | { |
| | | var list = units.Select(GetMesUnit).ToList(); |
| | | var groupBy = list.GroupBy(s => s.Type) |
| | | .ToDictionary(g => g.Key, g => g.ToList()); |
| | | var groupBy = list.GroupBy(s => s.Type).ToDictionary(g => g.Key, g => g.ToList()); |
| | | |
| | | return UseTransaction(db => |
| | | { |
| | |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteUnitBatch(db, unitGroup.Value)) |
| | | if (!UpdateUnitStatusBatch(db, unitGroup.Value, "B")) |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "4": |
| | |
| | | throw new NotImplementedException("同步失败"); |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{unitGroup.Key}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{unitGroup.Key}这个类型的参数"); |
| | | } |
| | | |
| | | return 1; |
| | | }) > 0; |
| | | } |
| | | |
| | | private bool UpdateUnitStatus(SqlSugarScope db, decimal unitId, |
| | | string status) |
| | | private bool UpdateUnitStatus(SqlSugarScope db, decimal unitId,string status) |
| | | { |
| | | var result = db.Updateable<MesUnit>() |
| | | .SetColumns(s => s.Fforbidstatus == status) |
| | | .Where(s => s.Id == unitId).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | var result = db.Updateable<MesUnit>().SetColumns(s => s.Fforbidstatus == status).Where(s => s.Id == unitId).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | private bool InsertUnit(SqlSugarScope db, MesUnit entity) |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | var exists = db.Queryable<MesUnit>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var result = db.Updateable<MesUnit>().ExecuteCommand(); |
| | | return true; |
| | | |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private bool DeleteUnit(SqlSugarScope db, decimal unitId) |
| | | private bool InsertOrUpdate(SqlSugarScope db, MesUnit entity) |
| | | { |
| | | var deleteById = db.Deleteable<MesUnit>().In(unitId).ExecuteCommand(); |
| | | if (deleteById > 0) |
| | | var exists = db.Queryable<MesUnit>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | return true; |
| | | |
| | | throw new NotImplementedException("删除失败"); |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private MesUnit GetMesUnit(ErpUnit unit) |
| | |
| | | string status) |
| | | { |
| | | var ids = unitList.Select(it => it.Id).ToArray(); |
| | | var result = db.Updateable<MesUnit>() |
| | | .SetColumns(s => s.Fforbidstatus == status) |
| | | .Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | var result = db.Updateable<MesUnit>().SetColumns(s => s.Fforbidstatus == status).Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | private bool InsertUnitBatch(SqlSugarScope db, List<MesUnit> unitList) |
| | | { |
| | | var insertRange = db.Insertable(unitList).ExecuteCommand(); |
| | | if (insertRange > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | |
| | | private bool DeleteUnitBatch(SqlSugarScope db, List<MesUnit> unitList) |
| | | { |
| | | var ids = unitList.Select(it => it.Id).ToArray(); |
| | | var deleteByIds = db.Deleteable<MesUnit>().In(ids).ExecuteCommand(); |
| | | return deleteByIds > 0; |
| | | } |
| | | |
| | | private bool InsertOrUpdate(SqlSugarScope db, MesUnit entity) |
| | | { |
| | | var exists = db.Queryable<MesUnit>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | foreach (var entity in unitList) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | if (update > 0) |
| | | return true; |
| | | if (!InsertUnit(db, entity)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | return true; |
| | | } |
| | | |
| | | private bool InsertOrUpdateBatch(SqlSugarScope db, List<MesUnit> unitList) |
| | | { |
| | | foreach (var entity in unitList) |
| | | { |
| | | if (!InsertOrUpdate(db, entity)) |
| | | { |
| | | return false; |
| | | |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | |
| | | using MES.Service.Dto.webApi; |
| | | using System.Xml.Linq; |
| | | |
| | | namespace MES.Service.service |
| | | { |
| | | namespace MES.Service.service; |
| | | |
| | | public class OrganizeManager : Repository<Organize> |
| | | { |
| | | |
| | | //当前类已经继承了 Repository 增、删、查、改的方法 |
| | | public bool Save(ErpOrganize item) |
| | | { |
| | | var entity = GetOrganize(item); |
| | | |
| | | //这里面写的代码不会给覆盖,如果要重新生成请删除 OrganizeManager.cs |
| | | public bool Save(ErpOrganize item) |
| | | return UseTransaction(db => |
| | | { |
| | | var entity = GetOrganize(item); |
| | | |
| | | return UseTransaction(db => |
| | | switch (item.Type) |
| | | { |
| | | switch (item.Type) |
| | | case "0": |
| | | if (UpdateOrganizetatus(db, entity.Id, "A")) //√ |
| | | return 1; |
| | | break; |
| | | case "1": |
| | | if (UpdateOrganizetatus(db, entity.Id, "B")) //√ |
| | | return 1; |
| | | break; |
| | | case "2": |
| | | if (InsertItem(db, entity)) //√ |
| | | return 1; |
| | | break; |
| | | case "3": |
| | | if (UpdateOrganizetatus(db, entity.Id, "B")) //√ |
| | | return 1; |
| | | break; |
| | | case "4": |
| | | if (InsertOrUpdate(db, entity)) //√ |
| | | return 1; |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException($"type没有{item.Type}这个类型的参数"); |
| | | } |
| | | |
| | | throw new NotImplementedException("操作失败"); |
| | | }) > 0; |
| | | } |
| | | |
| | | public bool SaveList(List<ErpOrganize> Organize) |
| | | { |
| | | var list = Organize.Select(GetOrganize).ToList(); |
| | | var groupBy = list.GroupBy(s => s.Type).ToDictionary(g => g.Key, g => g.ToList()); |
| | | |
| | | return UseTransaction(db => |
| | | { |
| | | foreach (var itemGroup in groupBy) |
| | | switch (itemGroup.Key) |
| | | { |
| | | case "0": |
| | | if (UpdateOrganizetatus(db, entity.Id, "A")) |
| | | return 1; |
| | | if (!UpdateOrganizetatusBatch(db, itemGroup.Value, "A")) |
| | | throw new NotImplementedException("启用失败"); |
| | | break; |
| | | case "1": |
| | | if (UpdateOrganizetatus(db, entity.Id, "B")) |
| | | return 1; |
| | | if (!UpdateOrganizetatusBatch(db, itemGroup.Value, "B")) |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (InsertItem(db, entity)) |
| | | return 1; |
| | | if (!InsertItemBatch(db, itemGroup.Value)) |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (DeleteItem(db, Convert.ToDecimal(entity.Id))) |
| | | return 1; |
| | | if (!UpdateOrganizetatusBatch(db, itemGroup.Value, "B")) |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "4": |
| | | if (InsertOrUpdate(db, entity)) |
| | | return 1; |
| | | if (!InsertOrUpdateBatch(db, itemGroup.Value)) |
| | | throw new NotImplementedException("同步失败"); |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{item.Type}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{itemGroup.Key}这个类型的参数"); |
| | | } |
| | | |
| | | throw new NotImplementedException("操作失败"); |
| | | }) > 0; |
| | | } |
| | | return 1; |
| | | }) > 0; |
| | | } |
| | | |
| | | public bool SaveList(List<ErpOrganize> Organize) |
| | | private bool UpdateOrganizetatus(SqlSugarScope db, decimal itemId,string status) |
| | | { |
| | | var result = db.Updateable<Organize>().SetColumns(s => s.Fforbidstatus == status).Where(s => s.Id == itemId).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | private bool InsertItem(SqlSugarScope db, Organize entity) |
| | | { |
| | | var exists = db.Queryable<Organize>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var list = Organize.Select(GetOrganize).ToList(); |
| | | var groupBy = list.GroupBy(s => s.Type) |
| | | .ToDictionary(g => g.Key, g => g.ToList()); |
| | | |
| | | return UseTransaction(db => |
| | | { |
| | | foreach (var itemGroup in groupBy) |
| | | switch (itemGroup.Key) |
| | | { |
| | | case "0": |
| | | if (!UpdateOrganizetatusBatch(db, itemGroup.Value, "A")) |
| | | throw new NotImplementedException("启用失败"); |
| | | break; |
| | | case "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 "4": |
| | | if (!InsertOrUpdateBatch(db, itemGroup.Value)) |
| | | throw new NotImplementedException("同步失败"); |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{itemGroup.Key}这个类型的参数"); |
| | | } |
| | | |
| | | return 1; |
| | | }) > 0; |
| | | var result = db.Updateable<Organize>().ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | private bool UpdateOrganizetatus(SqlSugarScope db, decimal itemId, |
| | | string status) |
| | | { |
| | | var result = db.Updateable<Organize>() |
| | | .SetColumns(s => s.Fforbidstatus == status) |
| | | .Where(s => s.Id == itemId).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | } |
| | | |
| | | private bool InsertItem(SqlSugarScope db, Organize entity) |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | |
| | | private bool DeleteItem(SqlSugarScope db, decimal itemId) |
| | | { |
| | | var deleteById = db.Deleteable<Organize>().In(itemId).ExecuteCommand(); |
| | | if (deleteById > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("删除失败"); |
| | | } |
| | | |
| | | private Organize GetOrganize(ErpOrganize Organize) |
| | | { |
| | | return new Organize |
| | | { |
| | | |
| | | Id = Convert.ToDecimal(Organize.Id), |
| | | Fnumber = Organize.FNumber, |
| | | Fname = Organize.FName, |
| | | Fforbidstatus = Organize.FForbidStatus, |
| | | Type = Organize.Type, |
| | | Fparentid=Organize.FParentID, |
| | | Fcreatedate=DateTime.Now |
| | | }; |
| | | } |
| | | |
| | | private bool UpdateOrganizetatusBatch(SqlSugarScope db, |
| | | List<Organize> itemList, string status) |
| | | { |
| | | var ids = itemList.Select(it => it.Id).ToArray(); |
| | | var result = db.Updateable<Organize>() |
| | | .SetColumns(s => s.Fforbidstatus == status) |
| | | .Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | } |
| | | |
| | | private bool InsertItemBatch(SqlSugarScope db, List<Organize> itemList) |
| | | { |
| | | var insertRange = db.Insertable(itemList).ExecuteCommand(); |
| | | if (insertRange > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | |
| | | private bool DeleteItemBatch(SqlSugarScope db, List<Organize> itemList) |
| | | { |
| | | var ids = itemList.Select(it => it.Id).ToArray(); |
| | | var deleteByIds = db.Deleteable<Organize>().In(ids).ExecuteCommand(); |
| | | if (deleteByIds > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("删除失败"); |
| | | } |
| | | |
| | | private bool InsertOrUpdate(SqlSugarScope db, Organize entity) |
| | | { |
| | | var exists = db.Queryable<Organize>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | if (update > 0) |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | return true; |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | private bool InsertOrUpdateBatch(SqlSugarScope db, List<Organize> itemList) |
| | | private bool InsertOrUpdate(SqlSugarScope db, Organize entity) |
| | | { |
| | | var exists = db.Queryable<Organize>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | foreach (var entity in itemList) |
| | | if (!InsertOrUpdate(db, entity)) |
| | | return false; |
| | | |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | #region 教学方法 |
| | | /// <summary> |
| | | /// 仓储方法满足不了复杂业务需求,业务代码请在这里面定义方法 |
| | | /// </summary> |
| | | public void Study() |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private Organize GetOrganize(ErpOrganize Organize) |
| | | { |
| | | |
| | | /*********查询*********/ |
| | | return new Organize |
| | | { |
| | | |
| | | var data1 = base.GetById(1);//根据ID查询 |
| | | var data2 = base.GetList();//查询所有 |
| | | var data3 = base.GetList(it => 1 == 1); //根据条件查询 |
| | | //var data4 = base.GetSingle(it => 1 == 1);//根据条件查询一条,如果超过一条会报错 |
| | | |
| | | var p = new PageModel() { PageIndex = 1, PageSize = 2 };// 分页查询 |
| | | var data5 = base.GetPageList(it => 1 == 1, p); |
| | | Console.Write(p.TotalCount);//返回总数 |
| | | |
| | | var data6 = base.GetPageList(it => 1 == 1, p, it => SqlFunc.GetRandom(), OrderByType.Asc);// 分页查询加排序 |
| | | Console.Write(p.TotalCount);//返回总数 |
| | | |
| | | List<IConditionalModel> conModels = new List<IConditionalModel>(); //组装条件查询作为条件实现 分页查询加排序 |
| | | conModels.Add(new ConditionalModel() { FieldName= typeof(Organize).GetProperties()[0].Name, ConditionalType = ConditionalType.Equal, FieldValue = "1" });//id=1 |
| | | var data7 = base.GetPageList(conModels, p, it => SqlFunc.GetRandom(), OrderByType.Asc); |
| | | |
| | | base.AsQueryable().Where(x => 1 == 1).ToList();//支持了转换成queryable,我们可以用queryable实现复杂功能 |
| | | |
| | | |
| | | |
| | | /*********插入*********/ |
| | | var insertData = new Organize() { };//测试参数 |
| | | var insertArray = new Organize[] { insertData }; |
| | | base.Insert(insertData);//插入 |
| | | base.InsertRange(insertArray);//批量插入 |
| | | var id = base.InsertReturnIdentity(insertData);//插入返回自增列 |
| | | base.AsInsertable(insertData).ExecuteCommand();//我们可以转成 Insertable实现复杂插入 |
| | | |
| | | |
| | | |
| | | /*********更新*********/ |
| | | var updateData = new Organize() { };//测试参数 |
| | | var updateArray = new Organize[] { updateData };//测试参数 |
| | | base.Update(updateData);//根据实体更新 |
| | | base.UpdateRange(updateArray);//批量更新 |
| | | //base.Update(it => new Organize() { ClassName = "a", CreateTime = DateTime.Now }, it => it.id==1);// 只更新ClassName列和CreateTime列,其它列不更新,条件id=1 |
| | | base.AsUpdateable(updateData).ExecuteCommand(); //转成Updateable可以实现复杂的插入 |
| | | |
| | | |
| | | |
| | | /*********删除*********/ |
| | | var deldata = new Organize() { };//测试参数 |
| | | base.Delete(deldata);//根据实体删除 |
| | | base.DeleteById(1);//根据主键删除 |
| | | base.DeleteById(new int[] { 1,2});//根据主键数组删除 |
| | | base.Delete(it=>1==2);//根据条件删除 |
| | | base.AsDeleteable().Where(it=>1==2).ExecuteCommand();//转成Deleteable实现复杂的操作 |
| | | Id = Convert.ToDecimal(Organize.Id), |
| | | Fnumber = Organize.FNumber, |
| | | Fname = Organize.FName, |
| | | Fforbidstatus = Organize.FForbidStatus, |
| | | Type = Organize.Type, |
| | | Fparentid=Organize.FParentID, |
| | | Fcreatedate=DateTime.Now |
| | | }; |
| | | } |
| | | #endregion |
| | | |
| | | private bool UpdateOrganizetatusBatch(SqlSugarScope db,List<Organize> itemList, string status) |
| | | { |
| | | var ids = itemList.Select(it => it.Id).ToArray(); |
| | | var result = db.Updateable<Organize>().SetColumns(s => s.Fforbidstatus == status).Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | private bool InsertItemBatch(SqlSugarScope db, List<Organize> itemList) |
| | | { |
| | | foreach (var entity in itemList) |
| | | { |
| | | if (!InsertItem(db, entity)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private bool InsertOrUpdateBatch(SqlSugarScope db, List<Organize> itemList) |
| | | { |
| | | foreach (var entity in itemList) |
| | | { |
| | | if (!InsertOrUpdate(db, entity)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | } |
| | |
| | | using MES.Service.DB; |
| | | using Castle.Core.Resource; |
| | | using MES.Service.DB; |
| | | using MES.Service.Dto.webApi; |
| | | using MES.Service.Modes; |
| | | using SqlSugar; |
| | |
| | | return 1; |
| | | break; |
| | | case "3": |
| | | if (DeleteDepartment(db, entity.Id)) // 删除部门 |
| | | if (UpdateDepartmentStatus(db, entity.Id, "B")) // 禁用部门 |
| | | return 1; |
| | | break; |
| | | case "4": |
| | |
| | | return 1; |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{department.Type}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{department.Type}这个类型的参数"); |
| | | } |
| | | |
| | | throw new NotImplementedException("操作失败"); |
| | |
| | | } |
| | | |
| | | // 更新部门状态的方法 |
| | | private bool UpdateDepartmentStatus(SqlSugarScope db, decimal departmentId, |
| | | string status) |
| | | private bool UpdateDepartmentStatus(SqlSugarScope db, decimal departmentId,string status) |
| | | { |
| | | var result = db.Updateable<SysDepartment>() |
| | | .SetColumns(s => s.Depextr4 == status) |
| | | .Where(s => s.Id == departmentId).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | var result = db.Updateable<SysDepartment>().SetColumns(s => s.Depextr4 == status).Where(s => s.Id == departmentId).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | // 插入新部门的方法 |
| | | private bool InsertDepartment(SqlSugarScope db, SysDepartment entity) |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | |
| | | // 删除部门的方法 |
| | | private bool DeleteDepartment(SqlSugarScope db, decimal departmentId) |
| | | { |
| | | var deleteById = db.Deleteable<SysDepartment>().In(departmentId) |
| | | .ExecuteCommand(); |
| | | if (deleteById > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("删除失败"); |
| | | } |
| | | |
| | | // 插入或更新部门的方法 |
| | | private bool InsertOrUpdateDepartment(SqlSugarScope db, |
| | | SysDepartment entity) |
| | | { |
| | | var exists = db.Queryable<SysDepartment>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | if (update > 0) |
| | | return true; |
| | | var result = db.Updateable<SysDepartment>().ExecuteCommand(); |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | // 插入或更新部门的方法 |
| | | private bool InsertOrUpdateDepartment(SqlSugarScope db,SysDepartment entity) |
| | | { |
| | | var exists = db.Queryable<SysDepartment>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 将 ErpDepartment 对象转换为 SysDepartment 对象的方法 |
| | |
| | | // SaveList 方法用于保存多个部门记录,根据类型批量执行不同的操作 |
| | | public bool SaveList(List<ErpDepartment> departments) |
| | | { |
| | | var list = new List<SysDepartment>(); |
| | | departments.ForEach(s => |
| | | { |
| | | var entity = |
| | | GetSysDepartment(s); // 将 ErpDepartment 转换为 SysDepartment |
| | | entity.Type = s.Type; |
| | | list.Add(entity); |
| | | }); |
| | | var list = departments.Select(GetSysDepartment).ToList(); |
| | | |
| | | var groupBy = list.GroupBy(s => s.Type) |
| | | .ToDictionary(g => g.Key, g => g.ToList()); |
| | | var groupBy = list.GroupBy(s => s.Type).ToDictionary(g => g.Key, g => g.ToList()); |
| | | |
| | | return UseTransaction(db => |
| | | { |
| | | foreach (var departmentGroup in groupBy) |
| | | switch (departmentGroup.Key) |
| | | { |
| | | case "0": |
| | | if (!UpdateDepartmentStatusBatch(db, |
| | | departmentGroup.Value, "A")) // 批量启用部门 |
| | | if (!UpdateDepartmentStatusBatch(db,departmentGroup.Value, "A")) // 批量启用部门 |
| | | throw new NotImplementedException("启用失败"); |
| | | break; |
| | | case "1": |
| | | if (!UpdateDepartmentStatusBatch(db, |
| | | departmentGroup.Value, "B")) // 批量禁用部门 |
| | | if (!UpdateDepartmentStatusBatch(db,departmentGroup.Value, "B")) // 批量禁用部门 |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (!InsertDepartmentBatch(db, |
| | | departmentGroup.Value)) // 批量插入部门 |
| | | if (!InsertDepartmentBatch(db,departmentGroup.Value)) // 批量插入部门 |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteDepartmentBatch(db, |
| | | departmentGroup.Value)) // 批量删除部门 |
| | | if (!UpdateDepartmentStatusBatch(db, departmentGroup.Value, "B")) // 批量禁用部门 |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "4": |
| | | if (!InsertOrUpdateDepartmentBatch(db, |
| | | departmentGroup.Value)) // 批量插入或更新部门 |
| | | if (!InsertOrUpdateDepartmentBatch(db,departmentGroup.Value)) // 批量插入或更新部门 |
| | | throw new NotImplementedException("同步失败"); |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{departmentGroup.Key}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{departmentGroup.Key}这个类型的参数"); |
| | | } |
| | | |
| | | return 1; |
| | |
| | | } |
| | | |
| | | // 批量更新部门状态的方法 |
| | | private bool UpdateDepartmentStatusBatch(SqlSugarScope db, |
| | | List<SysDepartment> departmentList, string status) |
| | | private bool UpdateDepartmentStatusBatch(SqlSugarScope db,List<SysDepartment> departmentList, string status) |
| | | { |
| | | var ids = departmentList.Select(it => it.Id).ToArray(); |
| | | var result = db.Updateable<SysDepartment>() |
| | | .SetColumns(s => s.Depextr4 == status) |
| | | .Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException(status == "A" ? "启用失败" : "禁用失败"); |
| | | var result = db.Updateable<SysDepartment>().SetColumns(s => s.Depextr4 == status).Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | return true; |
| | | } |
| | | |
| | | // 批量插入部门的方法 |
| | | private bool InsertDepartmentBatch(SqlSugarScope db, |
| | | List<SysDepartment> departmentList) |
| | | private bool InsertDepartmentBatch(SqlSugarScope db,List<SysDepartment> departmentList) |
| | | { |
| | | var insertRange = db.Insertable(departmentList).ExecuteCommand(); |
| | | if (insertRange > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | |
| | | // 批量删除部门的方法 |
| | | private bool DeleteDepartmentBatch(SqlSugarScope db, |
| | | List<SysDepartment> departmentList) |
| | | { |
| | | var ids = departmentList.Select(it => it.Id).ToArray(); |
| | | var deleteByIds = |
| | | db.Deleteable<SysDepartment>().In(ids).ExecuteCommand(); |
| | | if (deleteByIds > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("删除失败"); |
| | | foreach (var entity in departmentList) |
| | | { |
| | | if (!InsertDepartment(db, entity)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | // 批量插入或更新部门的方法 |
| | | private bool InsertOrUpdateDepartmentBatch(SqlSugarScope db, |
| | | List<SysDepartment> departmentList) |
| | | private bool InsertOrUpdateDepartmentBatch(SqlSugarScope db,List<SysDepartment> departmentList) |
| | | { |
| | | foreach (var entity in departmentList) |
| | | { |
| | | if (!InsertOrUpdateDepartment(db, entity)) |
| | | { |
| | | return false; |
| | | |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | } |