You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.4 KiB
C#
60 lines
1.4 KiB
C#
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();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
} |