using DataEntity;
|
using DataRWDAL;
|
using DataRWDAL.Base;
|
using HxEnum;
|
using MySql.Data.MySqlClient;
|
using DataEntity;
|
using DataRWDAL;
|
using DataRWDAL.Base;
|
using HxEnum;
|
using MySql.Data.MySqlClient;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Collections.ObjectModel;
|
using System.Data;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using XCommon.Log;
|
using XCommon.MySql;
|
|
namespace XImagingXhandler.XDAL
|
{
|
/// <summary>
|
/// 台面模板与夹爪关联操作类
|
/// </summary>
|
public class TabletopRelGripperDB:BaseDB
|
{
|
#region 删除某台面模板内的所有夹爪板位数据
|
/// <summary>
|
/// 删除某台面模板内的所有夹爪板位数据
|
/// </summary>
|
/// <param name="tabletopid">台面模板Id</param>
|
/// <returns>1成功;0:失败;</returns>
|
public static int DeleteTabletopRelGripperIntodb(string tabletopid)
|
{
|
using (var db = GetInstance())
|
{
|
var query = db.Queryable<TabletopRelGripper>().Where(it => it.tabletopid.Equals(tabletopid)).ToList();
|
if (query != null && query.Count() > 0)
|
{
|
foreach (var item in query)
|
{
|
DeleteGripperLatticeFromdb(item.gripper_lattice_id);
|
}
|
}
|
|
return db.Deleteable<TabletopRelGripper>(new TabletopRelGripper() { tabletopid = tabletopid }).ExecuteCommand();
|
}
|
}
|
#endregion
|
|
#region 删除指定的台面模板内的夹爪数据
|
/// <summary>
|
/// 删除指定的台面模板内的夹爪数据
|
/// </summary>
|
/// <param name="gripper_lattice_id">夹爪板位 Id</param>
|
/// <returns>1:成功;0:失败;</returns>
|
public static int DeleteGripperLatticeFromdb(int gripper_lattice_id)
|
{
|
using (var db = GetInstance())
|
{
|
return db.Deleteable<GripperCoordinate>(new GripperCoordinate() { gripper_lattice_id = gripper_lattice_id }).ExecuteCommand();
|
}
|
}
|
#endregion
|
|
#region 获取当前最大的台面夹爪板位Id
|
/// <summary>
|
/// 获取当前最大的台面夹爪板位Id
|
/// </summary>
|
/// <returns>最大板位Id</returns>
|
public static int GetMaxGripperLattceId()
|
{
|
using (var db = GetInstance())
|
{
|
return db.Queryable<GripperCoordinate>().ToList().Count;
|
}
|
}
|
#endregion
|
|
#region 批量添加夹爪板位数据
|
/// <summary>
|
/// 批量添加夹爪板位数据
|
/// </summary>
|
/// <param name="gripperCoordinates">夹爪板位对象集</param>
|
/// <param name="startGripperLatticeid">开始夹爪板位Id</param>
|
/// <param name="tabletopId">台面模板Id</param>
|
/// <returns></returns>
|
public static int AddGripperLatticeIntodb(List<GripperCoordinate> gripperCoordinates, int startGripperLatticeid, string tabletopId)
|
{
|
using (var db = GetInstance())
|
{
|
int sum = 0;//执行的总数
|
for (int i = 0; i < gripperCoordinates.Count; i++)
|
{
|
|
gripperCoordinates[i].gripper_lattice_id = startGripperLatticeid + i;
|
db.Insertable<Lattice>(gripperCoordinates[i]).ExecuteCommand();
|
db.Insertable<TabletopRelGripper>(new TabletopRelGripper() { gripper_lattice_id = (startGripperLatticeid + i), tabletopid = tabletopId }).ExecuteCommand();
|
sum++;
|
}
|
|
if (sum == gripperCoordinates.Count)
|
{
|
return 1;
|
}
|
|
return 0;
|
}
|
}
|
#endregion
|
}
|
}
|