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.

782 lines
31 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using DevExpress.Skins;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using ZJ_BYD.Common;
using ZJ_BYD.Model;
using ZJ_BYD.Untils;
using ZJ_BYD.ViewModel;
namespace ZJ_BYD.DB
{
public class MskCodeHelper
{
public MskCodeHelper() : base()
{
}
/// <summary>
/// 查询所有掩码表
/// </summary>
/// <returns></returns>
public static ISugarQueryable<T_MaskCode> QueryMskCodes()
{
try
{
return DBHelper.sqlSugarDb.Queryable<T_MaskCode>();
}
catch (Exception ex)
{
var msg = ex == null ? "执行QueryMskCodes方法时异常" : ex.Message;
LogHelper.WriteLog($"执行QueryMskCodes方法时异常{msg}");
return null;
}
}
/// <summary>
/// 根据机型查询条码字符
/// </summary>
/// <param name="productSfcCode"></param>
/// <returns></returns>
public static string QueryBarCodeChar(string stationCode, string productSfcCode)
{
try
{
if (string.IsNullOrWhiteSpace(productSfcCode))
{
LogHelper.WriteLog($"执行QueryBarCodeChar方法时productSfcCode参数为空");
return "";
}
return DBHelper.sqlSugarDb.Queryable<T_MaskCode>()
.First(m => m.StationCode == stationCode && SqlFunc.Replace(m.ProductSfcCode, "*", "") == SqlFunc.Substring(productSfcCode, 0, SqlFunc.Length(SqlFunc.Replace(m.ProductSfcCode, "*", ""))))?.BarCodeChar;
}
catch (Exception ex)
{
var msg = ex == null ? "执行QueryBarCodeChar方法时异常" : ex.Message;
LogHelper.WriteLog($"执行QueryBarCodeChar方法时异常{msg}");
return null;
}
}
/// <summary>
/// 根据主条码查询描述
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public static string QueryMskCodeDesc(string code)
{
try
{
if (string.IsNullOrWhiteSpace(code))
{
LogHelper.WriteLog($"执行QueryMskCodeDesc方法时参数code为空");
return null;
}
return DBHelper.sqlSugarDb.Queryable<T_MaskCode>().First(m => SqlFunc.Replace(m.ProductSfcCode, "*", "") == code)?.SfcDsp;
}
catch (Exception ex)
{
var msg = ex == null ? "执行QueryMskCodeDesc方法时异常" : ex.Message;
LogHelper.WriteLog($"执行QueryMskCodeDesc方法时异常{msg}");
return null;
}
}
/// <summary>
/// 查询机型对应工位数据
/// </summary>
/// <param name="machineTypeCode"></param>
/// <returns></returns>
public static ISugarQueryable<MaChineTypeStationVM> QueryMaChineTypeStationVM(string machineTypeCode)
{
try
{
return DBHelper.sqlSugarDb.Queryable<T_MaskCode>()
.InnerJoin<T_Station>((a, b) => a.StationCode == b.StationCode && a.LineCode == Program.CurrentLineCode && !b.IsDeleted)
.Where(a => a.ProductSfcCode == machineTypeCode && a.StationCode != Program.ActiveStatinCode)
.Select((a, b) => new MaChineTypeStationVM
{
Id = a.Id,
MachineTypeCode = a.ProductSfcCode,
StationCode = a.StationCode,
StationName = b.StationName,
StrIsUsed = a.IsUsed ? "是" : "否",
Category = a.Category,
}).Distinct();
}
catch (Exception ex)
{
var msg = ex == null ? "执行QueryMaChineTypeStationVM方法时异常" : ex.Message;
LogHelper.WriteLog($"执行QueryMaChineTypeStationVM方法时异常{msg}");
return null;
}
}
/// <summary>
/// 根据工位和排序索引查询掩码表
/// </summary>
/// <param name="stationCode"></param>
/// <param name="sortIndex"></param>
/// <returns></returns>
public static T_MaskCode QueryMskCode(string stationCode, int sortIndex)
{
try
{
return DBHelper.sqlSugarDb.Queryable<T_MaskCode>().First(m => m.StationCode == stationCode && m.SortIndex == sortIndex);
}
catch (Exception ex)
{
var msg = ex == null ? "执行QueryMskCode方法时异常" : ex.Message;
LogHelper.WriteLog($"执行QueryMskCode方法时异常{msg}");
return null;
}
}
/// <summary>
/// 根据工位编码和排序索引查询掩码表记录
/// </summary>
/// <param name="stationCode"></param>
/// <param name="sortIndex"></param>
/// <returns></returns>
public static T_MaskCode QueryMakCodeByStationCodeSort(string stationCode, int sortIndex)
{
try
{
return Program.t_MaskCodes.First(m => m.StationCode == stationCode && m.SortIndex == sortIndex);
}
catch (Exception ex)
{
var msg = ex == null ? "执行QueryMakCodeByStationCodeSort方法时异常" : ex.Message;
LogHelper.WriteLog($"执行QueryMakCodeByStationCodeSort方法时异常{msg}");
return null;
}
}
/// <summary>
/// 根据组件条码查询描述
/// </summary>
/// <param name="subCode"></param>
/// <returns></returns>
public static string QuerySubCodeDesc(string subCode)
{
try
{
if (string.IsNullOrWhiteSpace(subCode))
{
LogHelper.WriteLog($"执行QuerySubCodeDesc方法时参数subCode为空");
return "";
}
var model = new T_MaskCode();
var maskCodes = DBHelper.sqlSugarDb.Queryable<T_MaskCode>();
model = maskCodes.First(m => SqlFunc.Replace(m.Sub1SfcCode, "*", "") == subCode);
if (model != null)
{
return model.Sub1SfcDsp;
}
model = maskCodes.First(m => SqlFunc.Replace(m.Sub2SfcCode, "*", "") == subCode);
if (model != null)
{
return model.Sub2SfcDsp;
}
model = maskCodes.First(m => SqlFunc.Replace(m.Sub3SfcCode, "*", "") == subCode);
if (model != null)
{
return model.Sub3SfcDsp;
}
model = maskCodes.First(m => SqlFunc.Replace(m.Sub4SfcCode, "*", "") == subCode);
if (model != null)
{
return model.Sub4SfcDsp;
}
model = maskCodes.First(m => SqlFunc.Replace(m.Sub5SfcCode, "*", "") == subCode);
if (model != null)
{
return model.Sub5SfcDsp;
}
return "";
}
catch (Exception ex)
{
var msg = ex == null ? "执行QuerySubCodeDesc方法时异常" : ex.Message;
LogHelper.WriteLog($"执行QuerySubCodeDesc方法时异常{msg}");
return null;
}
}
/// <summary>
/// 根据Ids删除掩码表
/// 物理删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public static int DelMaskCodeByIds(int id)
{
return DBHelper.sqlSugarDb.Deleteable<T_MaskCode>().Where(m => m.Id == id).ExecuteCommand();
}
/// <summary>
/// 批量新增掩码表
/// </summary>
/// <param name="models"></param>
/// <returns></returns>
public static bool AddMaskCodes(List<T_MaskCode> models)
{
var result = DBHelper.sqlSugarDb.UseTran(() =>
{
DBHelper.sqlSugarDb.Insertable(models).ExecuteCommand();
});
return result.IsSuccess;
}
/// <summary>
/// 新增掩码表
/// </summary>
/// <param name="models"></param>
/// <returns></returns>
public static int AddMaskCode(T_MaskCode t_MaskCode)
{
return DBHelper.sqlSugarDb.Insertable(t_MaskCode).ExecuteCommand();
}
/// <summary>
/// 修改掩码表
/// </summary>
/// <param name="t_CurrentConfig"></param>
/// <returns></returns>
public static int UpdateMakCode(T_MaskCode t_MaskCode)
{
return DBHelper.sqlSugarDb.Updateable(t_MaskCode).ExecuteCommand();
}
/// <summary>
/// 查询表中最大索引
/// </summary>
/// <returns></returns>
public static int GetMaxSortIndex()
{
return DBHelper.sqlSugarDb.Queryable<T_MaskCode>().Max(m => m.SortIndex);
}
/// <summary>
/// 从掩码表校验主条码
/// </summary>
/// <param name="stationCode"></param>
/// <param name="mskCode"></param>
/// <param name="machineType"></param>
/// <returns></returns>
public static bool CheckCodeByMakCode(string stationCode, string mskCode, string machineType)
{
try
{
if (string.IsNullOrWhiteSpace(mskCode))
{
LogHelper.WriteLog($"执行CheckCodeByMakCode方法时参数mskCode为空");
return false;
}
if (machineType.Contains("."))
{
machineType = machineType.Substring(0, machineType.LastIndexOf("."));
}
int.TryParse(machineType, out int intMachineType);
var model = Program.t_MaskCodes.FirstOrDefault(m => m.StationCode == stationCode && m.IsUsed && m.SortIndex == intMachineType);
if (model != null)
{
var code = model.ProductSfcCode.TrimEnd('*');
int codeLen = code.Length;
if (mskCode.Length < codeLen)
{
LogHelper.WriteLog($"执行CheckCodeByMakCode方法时参数mskCode长度异常");
return false;
}
if (code == mskCode.Substring(0, codeLen))
{
return true;
}
}
return false;
}
catch (Exception ex)
{
var msg = ex == null ? "执行CheckCodeByMakCode方法时异常" : ex.Message;
LogHelper.WriteLog($"执行CheckCodeByMakCode方法时异常{msg}");
return false;
}
}
/// <summary>
/// 从掩码表校验转子主条码
/// </summary>
/// <param name="stationCode"></param>
/// <param name="mskCode"></param>
/// <param name="machineType"></param>
/// <returns></returns>
public static bool CheckCodeByMakCode_ZZCC(string stationCode, string mskCode, string machineType)
{
try
{
if (string.IsNullOrWhiteSpace(mskCode))
{
LogHelper.WriteLog($"执行CheckCodeByMakCode方法时参数mskCode为空");
return false;
}
if (machineType.Contains("."))
{
machineType = machineType.Substring(0, machineType.LastIndexOf("."));
}
int.TryParse(machineType, out int intMachineType);
var model = Program.t_MaskCodes.FirstOrDefault(m => m.StationCode == stationCode && m.IsUsed && m.SortIndex == intMachineType);
if (model != null)
{
var code = model.ProductSfcCode.Trim('*');
int codeLen = code.Length;
if (mskCode.Length < codeLen)
{
LogHelper.WriteLog($"执行CheckCodeByMakCode方法时参数mskCode长度异常");
return false;
}
if (code == mskCode.Substring(0, codeLen))
{
return true;
}
}
return false;
}
catch (Exception ex)
{
var msg = ex == null ? "执行CheckCodeByMakCode方法时异常" : ex.Message;
LogHelper.WriteLog($"执行CheckCodeByMakCode方法时异常{msg}");
return false;
}
}
/// <summary>
/// 校验组件条码
/// </summary>
/// <param name="stationCode"></param>
/// <param name="subCodeVms"></param>
/// <param name="machineType"></param>
/// <returns></returns>
public static (bool isok, string msg) CheckSubCode(T_MaskCode mskCode, List<SubCodeVM> subCodeVms)
{
try
{
if (subCodeVms.Count <= 0)
{
return (false, "");
}
if (mskCode == null)
{
return (false, "");
}
int len;
string subCode;
for (int i = 0; i < subCodeVms.Count; i++)
{
switch (subCodeVms[i].SortIndex)
{
case 1:
if (string.IsNullOrWhiteSpace(mskCode.Sub1SfcCode))
{
return (false, "");
}
len = mskCode.Sub1SfcCode.Replace("*", "").Length;
subCode = subCodeVms[i].SubCode.Substring(0, len);
if (mskCode.Sub1SfcCode.Replace("*", "") != subCode)
{
return (false, subCode);
}
break;
case 2:
if (string.IsNullOrWhiteSpace(mskCode.Sub2SfcCode))
{
return (false, "");
}
len = mskCode.Sub2SfcCode.Replace("*", "").Length;
subCode = subCodeVms[i].SubCode.Substring(0, len);
if (mskCode.Sub2SfcCode.Replace("*", "") != subCode)
{
return (false, subCode);
}
break;
case 3:
if (string.IsNullOrWhiteSpace(mskCode.Sub3SfcCode))
{
return (false, "");
}
len = mskCode.Sub3SfcCode.Replace("*", "").Length;
subCode = subCodeVms[i].SubCode.Substring(0, len);
if (mskCode.Sub3SfcCode.Replace("*", "") != subCode)
{
return (false, subCode);
}
break;
case 4:
if (string.IsNullOrWhiteSpace(mskCode.Sub4SfcCode))
{
return (false, "");
}
len = mskCode.Sub4SfcCode.Replace("*", "").Length;
subCode = subCodeVms[i].SubCode.Substring(0, len);
if (mskCode.Sub4SfcCode.Replace("*", "") != subCode)
{
return (false, subCode);
}
break;
case 5:
if (string.IsNullOrWhiteSpace(mskCode.Sub5SfcCode))
{
return (false, "");
}
len = mskCode.Sub5SfcCode.Replace("*", "").Length;
subCode = subCodeVms[i].SubCode.Substring(0, len);
if (mskCode.Sub5SfcCode.Replace("*", "") != subCode)
{
return (false, subCode);
}
break;
default:
break;
}
}
return (true, "");
}
catch (Exception ex)
{
var msg = ex == null ? "执行CheckSubCode方法时异常" : ex.Message;
LogHelper.WriteLog($"执行CheckSubCode方法时异常{msg}");
return (false, "");
}
}
/// <summary>
/// 查询使用中的机型信息
/// </summary>
public static ISugarQueryable<StationInfo> QueryUsingMaChineTypeVM()
{
var maskcodes = DBHelper.sqlSugarDb.Queryable<T_MaskCode>().ToList();
if (maskcodes.Count <= 0)
{
return DBHelper.sqlSugarDb.Queryable<T_Station>()
.LeftJoin<T_MaskCode>((a, b) => a.LineCode == b.LineCode && a.StationCode == b.StationCode && a.Category == b.Category && b.IsUsed && !a.IsDeleted)
.Select((a, b) => new StationInfo
{
IpcId = a.IpcId,
StationCode = a.StationCode,
StationName = a.StationName,
IsShowOrderBtn = a.IsShowOrderBtn,
IsShowPrintBtn = a.IsShowPrintBtn,
MachineType = b.ProductSfcCode,
MachineTypeIndex = b.SortIndex,
IsSearchAssemble = a.IsSearchAssemble,
IsBindAssembleCode = a.IsBindAssembleCode,
IsSearchLastStation = a.IsSearchLastStation,
IsBranch = a.IsBranch,
IsSfcCodeRepeat = a.IsSfcCodeRepeat,
DatabaseIp = a.DatabaseIp,
Site = b.Site,
Resource = b.Resource,
Procedure = b.Procedure,
NgCode = b.NgCode,
Sub1SfcCode = b.Sub1SfcCode,
Sub2SfcCode = b.Sub2SfcCode,
Sub3SfcCode = b.Sub3SfcCode,
Sub4SfcCode = b.Sub4SfcCode,
Sub5SfcCode = b.Sub5SfcCode,
Category = a.Category,
SortIndex = a.SortIndex,
SoftVersionLen = b.SoftVersionLen
});
}
else
{
return DBHelper.sqlSugarDb.Queryable<T_Station>()
.InnerJoin<T_MaskCode>((a, b) => a.LineCode == b.LineCode && a.StationCode == b.StationCode && a.Category == b.Category && b.IsUsed && !a.IsDeleted)
.Select((a, b) => new StationInfo
{
IpcId = a.IpcId,
StationCode = a.StationCode,
StationName = a.StationName,
IsShowOrderBtn = a.IsShowOrderBtn,
IsShowPrintBtn = a.IsShowPrintBtn,
MachineType = b.ProductSfcCode,
MachineTypeIndex = b.SortIndex,
IsSearchAssemble = a.IsSearchAssemble,
IsBindAssembleCode = a.IsBindAssembleCode,
IsSearchLastStation = a.IsSearchLastStation,
IsBranch = a.IsBranch,
IsSfcCodeRepeat = a.IsSfcCodeRepeat,
DatabaseIp = a.DatabaseIp,
Site = b.Site,
Resource = b.Resource,
Procedure = b.Procedure,
NgCode = b.NgCode,
Sub1SfcCode = b.Sub1SfcCode,
Sub2SfcCode = b.Sub2SfcCode,
Sub3SfcCode = b.Sub3SfcCode,
Sub4SfcCode = b.Sub4SfcCode,
Sub5SfcCode = b.Sub5SfcCode,
Category = a.Category,
SortIndex = a.SortIndex,
SoftVersionLen = b.SoftVersionLen
});
}
}
/// <summary>
/// 查询当前产线的所有工位及对应机型
/// </summary>
/// <returns></returns>
public static ISugarQueryable<LineStationVM> QueryLocalLineStation()
{
return DBHelper.sqlSugarDb.Queryable<T_CurrentConfig>()
.LeftJoin<T_Station>((a, b) => a.LineCode == b.LineCode && !b.IsDeleted)
.LeftJoin<T_MaskCode>((a, b, c) => a.LineCode == c.LineCode && b.StationCode == c.StationCode && b.Category == c.Category)
.Where(a => a.LineCode == Program.CurrentLineCode)
.Select((a, b, c) => new LineStationVM
{
Id = a.Id,
Ipc = b.IpcId,
LineCode = a.LineCode,
MachineTypeName = c.ProductSfcCode,
StationCode = b.StationCode,
StationName = b.StationName,
IsUsed = c.IsUsed,
SortIndex = c.SortIndex,
StrIsUsed = c.IsUsed ? "是" : "否",
Category = b.Category
});
}
/// <summary>
/// 更新使用中机型
/// </summary>
/// <param name="sortIndex"></param>
/// <returns></returns>
public static int UpdateMskCodeIsUsedBySortIndex(int sortIndex)
{
//先全部切换成False
var sql = $"update T_MaskCode set IsUsed=false,UpdatedTime='{DateTime.Now}',UpdatedBy='{CurrentUser.UserName}'";
DBHelper.sqlSugarDb.Ado.ExecuteCommand(sql);
var maskIds = DBHelper.sqlSugarDb.Queryable<T_MaskCode>()
.InnerJoin<T_Station>((a, b) => a.LineCode == b.LineCode && a.StationCode == b.StationCode && a.Category == b.Category)
.Where((a, b) => a.SortIndex == sortIndex)
.Select((a, b) => a.Id).ToList();
if (maskIds.Count > 0)
{
return DBHelper.sqlSugarDb.Updateable<T_MaskCode>()
.SetColumns(m => m.IsUsed == true)
.SetColumns(m => m.UpdatedTime == DateTime.Now)
.SetColumns(m => m.UpdatedBy == CurrentUser.UserName)
.Where(m => maskIds.Contains(m.Id)).ExecuteCommand();
}
return 0;
}
/// <summary>
/// 修改是否启用定子支线查询
/// </summary>
/// <param name="id"></param>
/// <param name="isUseStator"></param>
/// <returns></returns>
public static int UpdateMskCodeIsUsedStator(int id, bool isUseStator)
{
try
{
return DBHelper.sqlSugarDb.Updateable<T_MaskCode>()
.SetColumns(m => m.IsUseStator == isUseStator)
.SetColumns(m => m.UpdatedTime == DateTime.Now)
.SetColumns(m => m.UpdatedBy == CurrentUser.UserName)
.Where(m => m.Id == id).ExecuteCommand();
}
catch (Exception ex)
{
var msg = ex == null ? "执行UpdateMskCodeIsUsedStator方法时异常" : ex.Message;
LogHelper.WriteLog($"执行UpdateMskCodeIsUsedStator方法时异常{msg}");
return 0;
}
}
/// <summary>
/// 根据工位查询掩码表
/// </summary>
/// <param name="stationCode"></param>
/// <returns></returns>
public static T_MaskCode QueryMask_code(string stationCode)
{
return DBHelper.sqlSugarDb.Queryable<T_MaskCode>().First(m => m.StationCode == stationCode && m.IsUsed);
}
/// <summary>
/// 根据工位和机壳码查询掩码表
/// </summary>
/// <param name="stationCode"></param>
/// <param name="productSfcCode"></param>
/// <returns></returns>
public static T_MaskCode QueryMask_codeByStationAndSfcCode(string stationCode, string productSfcCode)
{
try
{
return Program.t_MaskCodes.FirstOrDefault(m => m.StationCode == stationCode && SqlFunc.Replace(m.ProductSfcCode, "*", "") == SqlFunc.Substring(productSfcCode, 0, SqlFunc.Length(SqlFunc.Replace(m.ProductSfcCode, "*", ""))));
}
catch (Exception ex)
{
var msg = ex == null ? "执行QueryMask_codeByStationAndSfcCode方法时异常" : ex.Message;
LogHelper.WriteLog($"执行QueryMask_codeByStationAndSfcCode方法时异常{msg}");
return null;
}
}
/// <summary>
/// 根据工位和线路查询掩码表
/// </summary>
/// <param name="stationCode"></param>
/// <param name="category"></param>
/// <returns></returns>
public static T_MaskCode QueryMask_codeByStationAndCategory(string stationCode, string category)
{
try
{
return Program.t_MaskCodes.FirstOrDefault(m => m.StationCode == stationCode && m.Category == category);
}
catch (Exception ex)
{
var msg = ex == null ? "执行QueryMask_codeByStationAndSfcCode方法时异常" : ex.Message;
LogHelper.WriteLog($"执行QueryMask_codeByStationAndSfcCode方法时异常{msg}");
return null;
}
}
/// <summary>
/// 用于查询上工位的资源和工序等信息
/// </summary>
/// <param name="stationCode"></param>
/// <param name="lastStationCode"></param>
/// <returns></returns>
public static T_MaskCode QueryMaskCodeByStationCodeAndLastStationCode(string stationCode, string lastStationCode)
{
var model = Program.t_MaskCodes.FirstOrDefault(m => m.StationCode == stationCode && m.IsUsed);
if (model != null)
{
return Program.t_MaskCodes.FirstOrDefault(m => m.StationCode == lastStationCode && m.Category == model.Category);
}
else
{
LogHelper.WriteLog($"查询{lastStationCode}工位的资源工序等信息时异常,工位{stationCode}的信息未查询到!");
}
return null;
}
/// <summary>
/// 根据工位编码和机壳码修改启用定子支线查询
/// </summary>
/// <param name="stationCode"></param>
/// <param name="productSfcCode"></param>
/// <param name="isUseStator"></param>
/// <returns></returns>
public static int UpdateMaskCodeIsUseStator(string stationCode, string productSfcCode, bool isUseStator)
{
try
{
return DBHelper.sqlSugarDb.Updateable<T_MaskCode>()
.SetColumns(m => m.IsUseStator == isUseStator)
.SetColumns(m => m.UpdatedTime == DateTime.Now)
.SetColumns(m => m.UpdatedBy == CurrentUser.UserName)
.Where(m => m.StationCode == stationCode && m.ProductSfcCode == productSfcCode).ExecuteCommand();
}
catch (Exception ex)
{
var msg = ex == null ? "执行UpdateMaskCodeIsUseStator方法时异常" : ex.Message;
LogHelper.WriteLog($"执行UpdateMaskCodeIsUseStator方法时异常{msg}");
return 0;
}
}
/// <summary>
/// 新增打印信息
/// </summary>
/// <param name="t_PrintInfo"></param>
/// <returns></returns>
public static int AddPrintInfo(T_PrintInfo t_PrintInfo)
{
try
{
return DBHelper.sqlSugarDb.Insertable(t_PrintInfo).ExecuteCommand();
}
catch (Exception ex)
{
var msg = ex == null ? "执行AddPrintInfo方法时异常" : ex.Message;
LogHelper.WriteLog($"执行AddPrintInfo方法时异常{msg}");
return 0;
}
}
public static T_PrintInfo QueryPrintInfo(string barCode)
{
try
{
return DBHelper.sqlSugarDb.Queryable<T_PrintInfo>().First(m => m.BarCode == barCode);
}
catch (Exception ex)
{
var msg = ex == null ? "执行QueryPrintInfo方法时异常" : ex.Message;
LogHelper.WriteLog($"执行QueryPrintInfo方法时异常{msg}");
return null;
}
}
/// <summary>
/// 删除昨天的记录
/// </summary>
/// <returns></returns>
public static int delPrintInfo()
{
try
{
var beginDate = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd") + " 00:00:00");
var endDate = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd") + " 23:59:59");
return DBHelper.sqlSugarDb.Deleteable<T_PrintInfo>().Where(m => m.CreatedTime >= beginDate && m.CreatedTime <= endDate).ExecuteCommand();
}
catch (Exception ex)
{
var msg = ex == null ? "执行delPrintInfo方法时异常" : ex.Message;
LogHelper.WriteLog($"执行delPrintInfo方法时异常{msg}");
return 0;
}
}
/// <summary>
/// 初始化机型
/// </summary>
/// <param name="sortInex"></param>
/// <returns></returns>
public static int InitMachineType()
{
try
{
//判断掩码表是否有启用中的机型
var maskcodes = DBHelper.sqlSugarDb.Queryable<T_MaskCode>().Where(m => m.IsUsed).ToList();
//如果没有则根据PLC中选中的机型值进行修改
if (maskcodes.Count <= 0)
{
return UpdateMskCodeIsUsedBySortIndex(1);
}
return 1;
}
catch (Exception ex)
{
var msg = ex == null ? "执行InitMachineType方法时异常" : ex.Message;
LogHelper.WriteLog($"执行InitMachineType方法时异常{msg}");
return 0;
}
}
}
}