Commit 5e5cddb9 by 泽锋 李

fix

parent 4a31ba63
......@@ -230,16 +230,17 @@ namespace AutoTurnOver.DB
/// <param name="input_data"></param>
public static void BatchSet(batch_set_input_dto input_data, UserData user)
{
var mother_data = _connection.QueryFirstOrDefault<dc_base_mother_sku>(" select * from dc_base_mother_sku where id=@id ", new { id = input_data.mother_id });
var conn = MyMySqlConnection._connection;
conn.Open();
using (var t = conn.BeginTransaction())
{
try
{
var mother_data = conn.QueryFirstOrDefault<dc_base_mother_sku>(" select * from dc_base_mother_sku where id=@id ", new { id = input_data.mother_id });
foreach (var item in input_data.ids)
{
var trunData = conn.QueryFirstOrDefault<AutoTurnOver.Models.dc_auto_turnover>(" select * from dc_auto_turnover where id=@id ",new { id=item});
var trunData = conn.QueryFirstOrDefault<AutoTurnOver.Models.dc_auto_turnover>(" select * from dc_auto_turnover where id=@id ", new { id = item });
// 查询是否有旧记录
var oldLog = conn.QueryFirstOrDefault<dc_base_mother_sku_map>(" select * from dc_base_mother_sku_map where bailun_sku_warehouse_code=@bailun_sku_warehouse_code ", new
{
......@@ -292,16 +293,73 @@ namespace AutoTurnOver.DB
}
}
ResetStorageCapacity(mother_data.sku, mother_data.warehouse_code,user);
}
/// <summary>
/// 搜索母sku
/// </summary>
/// <returns></returns>
public static List<dc_base_mother_sku_dto> SearchSku(string name)
public static List<dc_base_mother_sku_dto> SearchSku(string name)
{
return _connection.Query<dc_base_mother_sku_dto>(" select t1.*,t2.warehouse_name from dc_base_mother_sku as t1 left join dc_base_warehouse as t2 on t1.warehouse_code=t2.warehouse_code where t1.sku like @name ", new { name= $"%{name}%"} ).ToList();
return _connection.Query<dc_base_mother_sku_dto>(" select t1.*,t2.warehouse_name from dc_base_mother_sku as t1 left join dc_base_warehouse as t2 on t1.warehouse_code=t2.warehouse_code where t1.sku like @name ", new { name = $"%{name}%" }).ToList();
}
/// <summary>
/// 刷新库容
/// </summary>
public static void ResetStorageCapacity(string mother_sku, string warehouse_code, UserData user)
{
var mother_sku_warehouse_code = $"{mother_sku}{warehouse_code}";
// 子sku
var skus = _connection.Query<dc_base_mother_sku_map>(" select * from dc_base_mother_sku_map where mother_sku_warehouse_code=@mother_sku_warehouse_code ", new
{
mother_sku_warehouse_code = mother_sku_warehouse_code
}).ToList();
var storage_capacity = 0;
if (skus != null && skus.Count >= 1)
{
storage_capacity = _connection.QueryFirstOrDefault<int?>(" select * from dc_base_storage_capacity where bailun_sku_warehouse_code in @bailun_sku_warehouse_codes ", new
{
bailun_sku_warehouse_codes = skus.Select(s => s.bailun_sku_warehouse_code).ToList()
}) ?? 0;
}
else
{
storage_capacity = 0;
}
_connection.Execute(" update dc_base_mother_sku set storage_capacity=@storage_capacity where sku_warehouse_code=@sku_warehouse_code ", new
{
storage_capacity = storage_capacity,
sku_warehouse_code = mother_sku_warehouse_code
});
// 新增日志
_connection.Insert(new dc_base_mother_sku_log
{
action = $"更新合并库容 {storage_capacity}",
create_date = DateTime.Now,
create_user = user.UserName,
sku = mother_sku,
sku_warehouse_code = mother_sku_warehouse_code,
warehouse_code = warehouse_code
});
}
/// <summary>
/// 更新合并库容
/// </summary>
public static void ResetStorageCapacityByMapSku(string bailun_sku, string warehouse_code, UserData user)
{
// 查询是否有母sku
var mother_sku_map_data = _connection.QueryFirstOrDefault<dc_base_mother_sku_map>(" select * from dc_base_mother_sku_map where bailun_sku_warehouse_code=@bailun_sku_warehouse_code ",new {
bailun_sku_warehouse_code = $"{bailun_sku}{warehouse_code}"
});
if (mother_sku_map_data != null)
{
ResetStorageCapacity(mother_sku_map_data.mother_sku, mother_sku_map_data.mother_warehouse_code,user);
}
}
}
}
......@@ -214,6 +214,9 @@ left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code where
}
}
//更新母sku库容
dc_base_mother_sku_dao.ResetStorageCapacityByMapSku(data.bailun_sku, data.warehouse_code,new UserData { UserName = data.create_user});
}
/// <summary>
......
......@@ -19,6 +19,11 @@ namespace AutoTurnOver.Models
/// 状态
/// </summary>
public int status { get; set; }
/// <summary>
/// 库容
/// </summary>
public int storage_capacity { get; set; }
}
public class dc_base_mother_sku_map
{
......
{
"ConnectionStrings": {
"Default": "server=10.0.8.15;port=3306;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;",
"ReadOnly": "server=10.0.8.21;port=3306;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
"ReadOnly": "server=10.0.8.21;port=3306;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;SslMode=None;"
},
"PPS_ShortagePush": "http://10.0.6.8:8002/api/EbayTask/PushSkuEditQtyTask",
"redis": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment