using Tiger.Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Rhea.Common;
using System.Net;
using System.Linq;
using Newtonsoft.Json;
using Tiger.IBusiness;
using Microsoft.AspNetCore.Http;
using Tiger.Model.Entitys.MES.BizMesWoBatch;
using Tiger.Model.Entitys.MES.BizMesWo;
using Tiger.Model.Entitys.MES.BizBasPkgRule;
namespace Tiger.Business.MES
{
public partial class BizBasRule : IBasRule
{
///
/// 保存物料条码规则
///
///
///
public async Task SaveBasItemRule(BizBasItemRuleInput input)
{
var result = new ApiAction();
try
{
var ItemCusts = input.ItemCusts.Select(q => q.ID).ToList();
List list = await Biz.Db.Queryable().Where(q => !SqlFunc.ContainsArray(ItemCusts, q.ID)).ToListAsync();
var db = Biz.Db;
var dbTran = db.UseTran(() =>
{
var z = db.Storageable(input.ItemCusts)
.WhereColumns(t => new { t.ID, t.GHOST_ROW })
.ToStorage();
z.AsInsertable.ExecuteCommand();
z.AsUpdateable.ExecuteCommand();
db.Deleteable(list).ExecuteCommand();
});
if (!dbTran.IsSuccess)
{
result.IsSuccessed = false;
result.Message = $"保存物料条码规则异常";
}
}
catch (Exception ex)
{
result.CatchExceptionWithLog(ex, "保存物料条码规则异常");
}
return result;
}
///
/// 保存包装规则,包括明细和重量范围
///
///
///
public async Task SaveBasPkgRule(BizBasPkgRuleInput input)
{
var result = new ApiAction();
try
{
var pkgProds = input.PkgProd.Select(q => q.ID).ToList();
List listPrd = await Biz.Db.Queryable().Where(q => !SqlFunc.ContainsArray(pkgProds, q.ID)).ToListAsync();
var db = Biz.Db;
var dbTran = db.UseTran(() =>
{
//if (input.PkgRule!=null)
//{
// var y = db.Storageable(input.PkgRule)
// .WhereColumns(t => new { t.ID, t.GHOST_ROW })
// .ToStorage();
// y.AsInsertable.ExecuteCommand();
// y.AsUpdateable.ExecuteCommand();
//}
var z = db.Storageable(input.PkgDtl)
.WhereColumns(t => new { t.ID, t.GHOST_ROW })
.ToStorage();
z.AsInsertable.ExecuteCommand();
z.AsUpdateable.ExecuteCommand();
var o = db.Storageable(input.PkgProd)
.WhereColumns(t => new { t.ID, t.GHOST_ROW })
.ToStorage();
o.AsInsertable.ExecuteCommand();
o.AsUpdateable.ExecuteCommand();
db.Deleteable(listPrd).ExecuteCommand();
});
if (!dbTran.IsSuccess)
{
result.IsSuccessed = false;
result.Message = $"保存包装规则异常";
}
}
catch (Exception ex)
{
result.CatchExceptionWithLog(ex, "保存包装规则异常");
}
return result;
}
}
}