Merge branch 'dep' into wangsr

wangsr
wangsr 1 year ago
commit 72862134be

@ -0,0 +1,60 @@
using System.Collections.Generic;
using System.Linq;
using FreeSql.DataAnnotations;
using Mesnac.Action.ChemicalWeighing.FreeDb;
namespace Mesnac.Action.ChemicalWeighing.AutoControl.DB
{
public class DeviceMaterrial
{
[Column(IsPrimary = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 设备编号
/// </summary>
public int DeviceId { get; set; }
/// <summary>
/// 对应物料的Id
/// </summary>
public int MaterrialId { get; set; }
/// <summary>
/// 1 干混机 2 糊化机
/// </summary>
public int Type { get; set; }
}
public class DeviceMaterrialService
{
public void Save(List<DeviceMaterrial> materrials)
{
var deviceMaterrial = materrials.First();
FreeSqlUnit.Instance.Delete<DeviceMaterrial>()
.Where(x => x.Type == deviceMaterrial.Type && x.DeviceId == deviceMaterrial.DeviceId)
.ExecuteDeleted();
FreeSqlUnit.Instance.Insert(materrials).ExecuteAffrows();
}
public List<DeviceMaterrial> GetByTypeId(int type, int deviceId)
{
return FreeSqlUnit.Instance.Select<DeviceMaterrial>()
.Where(x => x.Type == type && x.DeviceId == deviceId)
.ToList();
}
}
}

@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Mesnac.Action.ChemicalWeighing.LjMaterial;
namespace Mesnac.Action.ChemicalWeighing.AutoControl.DB
{
public class StockMaterrialDbHelp
{
/// <summary>
/// 获取干混机物料
/// </summary>
/// <returns></returns>
public List<MyNameValue> GetDryerMaterrial()
{
var list = GetStockMaterrial(1);
list.RemoveAll(x => x.Id == 5);
list.RemoveAll(x => x.Id == 6);
return list;
}
/// <summary>
/// 获取糊化机物料
/// </summary>
/// <returns></returns>
public List<MyNameValue> GetSiloMaterrial()
{
var list1 = GetStockMaterrial(1);
list1 = list1.Where(x => x.Id == 5 || x.Id == 6).ToList();
return list1;
}
/// <summary>
/// 根据物料获取罐号
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public int GetCodeById(int id)
{
string sql = $"select Code from lj_stock_material where Id={id}";
var dataTable = DBHelp.GetTable(sql);
return Convert.ToInt16(dataTable.Rows[0][0]);
}
private List<MyNameValue> GetStockMaterrial(int mtypId)
{
string sql = "select Id, Code, StockName, MTypeId, MTypeName, MId, MName, Remark from lj_stock_material";
var dataTable = DBHelp.GetTable(sql);
List<MyNameValue> ls = new List<MyNameValue>();
ls.Add(new MyNameValue()
{
Id = -1,
Name = "请选择"
});
foreach (DataRow o in dataTable.Rows)
{
int tableMTypeId = Convert.ToInt32(o["MTypeId"]);
if (mtypId != 0)
{
if (tableMTypeId == mtypId)
{
ls.Add(new MyNameValue()
{
Id = (int)o["Id"],
Name = o["StockName"].ToString() + $"({o["MName"]})"
});
}
}
}
return ls;
}
}
}
Loading…
Cancel
Save