MES.Service/service/BasicData/MesDepotsManager.cs
@@ -4,7 +4,9 @@
using SqlSugar;
namespace MES.Service.service.BasicData;
/// <summary>
/// 仓库信息
/// </summary>
public class MesDepotsManager : Repository<MesDepots>
{
    // Save 方法用于保存单个仓库记录,根据类型执行不同的操作
@@ -77,7 +79,7 @@
    }
    /// <summary>
    /// 同步物料信息new_0/4
    /// 同步仓库信息new_0/4
    /// </summary>
    /// <param name="db"></param>
    /// <param name="entity"></param>
@@ -157,8 +159,8 @@
            Depottype = depots.FStockProperty,
            IsNg = depots.FForbidStatus,
            Zuid = depots.FGroup,
            FSubsidiary = depots.FUseOrgId,
            Fumbrella = depots.FCreateOrgId,
            //FSubsidiary = depots.FUseOrgId,
            //Fumbrella = depots.FCreateOrgId,
            // 如果存在,使用现有的CreateDate,后续将删除后重新插入
            // 如果不存在,设为当前时间
            CreateDate = existingCustomer?.CreateDate ?? DateTime.Now,
@@ -168,22 +170,26 @@
            Department = depots.Fdeptid,
            Phone = depots.Phone,
            Company = "1000",
            Factory = depots.Factory??"1000",
            Remark3 = depots.remark3,
            Factory = depots.Factory,
            factory_name = depots.factory_name,
            Remark4 = depots.remark4,
            Remark5 = depots.remark5,
            FSubsidiary = string.IsNullOrEmpty(depots.FUseOrgId) ? "1" : depots.FUseOrgId,
            Fumbrella = string.IsNullOrEmpty(depots.FCreateOrgId) ? "1" : depots.FCreateOrgId,
        };
        // ERP: 0=未禁用, 1=禁用
        // MES: A=未禁用, B=禁用
        //传入0、1或者A、B时都会转为A、B,其他情况为A
        if (string.IsNullOrEmpty(depots.FForbidStatus))
        {
            entity.IsNg = "A";
        }
        else
        {
            //我期望的值是A=否,B=是
            //实际给我的值是0或1,我希望为我转换从A和B的方式
            entity.IsNg = depots.FForbidStatus == "1" ? "B" : "A";
            // 回传B或1时写入B,其它写A
            entity.IsNg = (depots.FForbidStatus == "1" || depots.FForbidStatus == "B")
                ? "B"
                : "A";
        }
        return entity;
@@ -238,8 +244,7 @@
    }
    // 批量更新仓库状态的方法
    private bool UpdateDepotStatusBatch(SqlSugarScope db,
        List<MesDepots> depotList, string status)
    private bool UpdateDepotStatusBatch(SqlSugarScope db,List<MesDepots> depotList, string status)
    {
        var ids = depotList.Select(it => it.DepotId).ToArray();
        var result = db.Updateable<MesDepots>()
@@ -253,8 +258,7 @@
    }
    // 批量插入仓库的方法
    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)
@@ -278,8 +282,7 @@
    }
    // 批量插入或更新仓库的方法
    private bool InsertOrUpdateBatch(SqlSugarScope db,
        List<MesDepots> depotList)
    private bool InsertOrUpdateBatch(SqlSugarScope db,List<MesDepots> depotList)
    {
        return depotList.All(entity => InsertOrUpdate(db, entity));
    }