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.
167 lines
5.7 KiB
C#
167 lines
5.7 KiB
C#
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using ZJ_BYD.Common;
|
|
using ZJ_BYD.Model;
|
|
using ZJ_BYD.Untils;
|
|
using ZJ_BYD.ViewModel;
|
|
|
|
namespace ZJ_BYD.DB
|
|
{
|
|
public class StationHelper
|
|
{
|
|
public StationHelper() : base()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询所有工位
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static ISugarQueryable<T_Station> QueryStations()
|
|
{
|
|
return DBHelper.sqlSugarDb.Queryable<T_Station>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据工位编码查询工位
|
|
/// </summary>
|
|
/// <param name="stationCode"></param>
|
|
/// <returns></returns>
|
|
public static T_Station QueryStationByStationCode(string stationCode)
|
|
{
|
|
return DBHelper.sqlSugarDb.Queryable<T_Station>().First(m => m.StationCode == stationCode && !m.IsDeleted);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询未删除的工位
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static ISugarQueryable<T_Station> QueryActiveStations()
|
|
{
|
|
return DBHelper.sqlSugarDb.Queryable<T_Station>().Where(m => !m.IsDeleted);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据IPCID和机型查询未删除的工位
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static List<T_Station> QueryActiveStationsByIpcIdandCategory(string ipcId, string category)
|
|
{
|
|
return DBHelper.sqlSugarDb.Queryable<T_Station>().Where(m => m.IpcId == ipcId && m.Category == category && !m.IsDeleted).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询未删除的工位
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static ISugarQueryable<QueryStationVM> QueryActiveStationVMs()
|
|
{
|
|
return DBHelper.sqlSugarDb.Queryable<T_Station>().Where(m => !m.IsDeleted)
|
|
.Select(m => new QueryStationVM
|
|
{
|
|
Id = m.Id,
|
|
IpcId = m.IpcId,
|
|
LineCode = m.LineCode,
|
|
Category = m.Category,
|
|
StationCode = m.StationCode,
|
|
StationName = m.StationName,
|
|
StrIsBindAssembleCode = m.IsBindAssembleCode ? "是" : "否",
|
|
StrIsShowOrderBtn = m.IsShowOrderBtn ? "是" : "否",
|
|
StrIsShowPrintBtn = m.IsShowPrintBtn ? "是" : "否",
|
|
StrIsSearchAssemble = m.IsSearchAssemble ? "是" : "否",
|
|
StrIsSearchLastStation = m.IsSearchLastStation ? "是" : "否",
|
|
DatabaseIp = m.DatabaseIp,
|
|
SortIndex = m.SortIndex,
|
|
IsBranch = m.IsBranch,
|
|
StrIsBranch = m.IsBranch ? "是" : "否",
|
|
IsSfcCodeRepeat = m.IsSfcCodeRepeat,
|
|
StrIsSfcCodeRepeat= m.IsSfcCodeRepeat ? "是" : "否"
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 校验工位编码是否有效
|
|
/// true:存在
|
|
/// </summary>
|
|
/// <param name="stationCode"></param>
|
|
/// <returns></returns>
|
|
public static bool CheckStationCode(string stationCode)
|
|
{
|
|
return DBHelper.sqlSugarDb.Queryable<T_Station>().Where(m => !m.IsDeleted && m.StationCode == stationCode).ToList().Count > 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据Ids删除工位
|
|
/// 逻辑删除
|
|
/// </summary>
|
|
/// <param name="ids"></param>
|
|
/// <returns></returns>
|
|
public static int DelStationByIds(List<int> ids)
|
|
{
|
|
return DBHelper.sqlSugarDb.Updateable<T_Station>()
|
|
.SetColumns(m => m.IsDeleted == true)
|
|
.SetColumns(m => m.UpdatedTime == DateTime.Now)
|
|
.SetColumns(m => m.UpdatedBy == CurrentUser.UserName)
|
|
.Where(m => ids.Contains(m.Id)).ExecuteCommand();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据Ids物理删除工位
|
|
/// </summary>
|
|
/// <param name="ids"></param>
|
|
/// <returns></returns>
|
|
public static int DoDelStationByIds(List<int> ids)
|
|
{
|
|
return DBHelper.sqlSugarDb.Deleteable<T_Station>().Where(m => ids.Contains(m.Id)).ExecuteCommand();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增工位
|
|
/// </summary>
|
|
/// <param name="t_Station"></param>
|
|
/// <returns></returns>
|
|
public static int AddStation(T_Station t_Station)
|
|
{
|
|
return DBHelper.sqlSugarDb.Insertable(t_Station).ExecuteCommand();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 批量新增工位
|
|
/// </summary>
|
|
/// <param name="t_Stations"></param>
|
|
/// <returns></returns>
|
|
public static bool AddStations(List<T_Station> t_Stations)
|
|
{
|
|
var result = DBHelper.sqlSugarDb.UseTran(() =>
|
|
{
|
|
foreach (var item in t_Stations)
|
|
{
|
|
AddStation(item);
|
|
}
|
|
});
|
|
return result.IsSuccess;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改工位
|
|
/// </summary>
|
|
/// <param name="t_Station"></param>
|
|
/// <returns></returns>
|
|
public static int UpdateStation(T_Station t_Station)
|
|
{
|
|
return DBHelper.sqlSugarDb.Updateable(t_Station).ExecuteCommand();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询表中最大索引
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static int GetMaxSortIndex()
|
|
{
|
|
return DBHelper.sqlSugarDb.Queryable<T_Station>().Max(m => m.SortIndex);
|
|
}
|
|
}
|
|
}
|