|
|
|
|
using Mesnac.Action.ChemicalWeighing.FreeDb;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.LjMaterial;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Report.Entity;
|
|
|
|
|
using Mesnac.Basic;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Report
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 配料日志
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class LjLogControl
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过内容查询日志
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="txt">查询关键字</param>
|
|
|
|
|
public static DataTable ManualLogSelect(string txt)
|
|
|
|
|
{
|
|
|
|
|
string sql;
|
|
|
|
|
if (!string.IsNullOrEmpty(txt))
|
|
|
|
|
{
|
|
|
|
|
sql = BaseSelect($"where logtext like '%{txt}%'");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sql = BaseSelect("");
|
|
|
|
|
}
|
|
|
|
|
return DBHelp.GetTable(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过内容和机台号查询日志
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="txt">查询关键字</param>
|
|
|
|
|
public static DataTable ManualLogSelect(string txt, int deviceNo)
|
|
|
|
|
{
|
|
|
|
|
string sql;
|
|
|
|
|
if (deviceNo == 0)
|
|
|
|
|
{
|
|
|
|
|
return ManualLogSelect(txt);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sql = BaseSelect($"where deviceNo = {deviceNo} and logtext like '%{txt}%'");
|
|
|
|
|
return DBHelp.GetTable(sql);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过时间查询日志
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="txt">查询关键字</param>
|
|
|
|
|
public static DataTable ManualLogSelect(string startTime, string endTime)
|
|
|
|
|
{
|
|
|
|
|
string sql = BaseSelect($"where logtime BETWEEN '{startTime}' AND '{endTime}'");
|
|
|
|
|
return DBHelp.GetTable(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string BaseSelect(string sql)
|
|
|
|
|
{
|
|
|
|
|
string s = "select top 500 id, logtext, logtime, value from Manual_Log " + sql +
|
|
|
|
|
" order by id desc";
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 完整手动日志插入
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="logName">日志内容</param>
|
|
|
|
|
/// <param name="value">值</param>
|
|
|
|
|
/// <param name="valuekind">值类型 0无 1水称设定值 2水称称量值 3螺旋设定值 4螺旋称量值</param>
|
|
|
|
|
/// <param name="deviceno">设备编号</param>
|
|
|
|
|
/// <param name="devicekind">设备类型 0无 1水称 2螺旋 3糊化</param>
|
|
|
|
|
public static void ManualLogControl(string logName, int value, int valuekind, int deviceno, int devicekind)
|
|
|
|
|
{
|
|
|
|
|
var Log = new LjLogEntity()
|
|
|
|
|
{
|
|
|
|
|
logtext = logName,
|
|
|
|
|
logtime = DateTime.Now,
|
|
|
|
|
userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
|
|
value = value,
|
|
|
|
|
deviceno = deviceno,
|
|
|
|
|
devicekind = devicekind,
|
|
|
|
|
valuekind = valuekind,
|
|
|
|
|
createdate = DateTime.Now.ToString("yyyyMMdd")
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(Log).ExecuteIdentity();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 无数值 有设备 日志记录
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="logName">日志内容</param>
|
|
|
|
|
/// <param name="deviceno">设备编号</param>
|
|
|
|
|
/// <param name="devicekind">设备类型</param>
|
|
|
|
|
public static void ManualLogControl(string logName, int deviceno, int devicekind)
|
|
|
|
|
{
|
|
|
|
|
var Log = new LjLogEntity()
|
|
|
|
|
{
|
|
|
|
|
logtext = logName,
|
|
|
|
|
logtime = DateTime.Now,
|
|
|
|
|
userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
|
|
value = 0,
|
|
|
|
|
deviceno = deviceno,
|
|
|
|
|
devicekind = devicekind,
|
|
|
|
|
valuekind = 0,
|
|
|
|
|
createdate = DateTime.Now.ToString("yyyyMMdd")
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(Log).ExecuteIdentity();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 无数值 无设备 日志记录
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="logName"></param>
|
|
|
|
|
public static void ManualLogControl(string logName)
|
|
|
|
|
{
|
|
|
|
|
var Log = new LjLogEntity()
|
|
|
|
|
{
|
|
|
|
|
logtext = logName,
|
|
|
|
|
logtime = DateTime.Now,
|
|
|
|
|
userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
|
|
value = 0,
|
|
|
|
|
deviceno = 0,
|
|
|
|
|
devicekind = 0,
|
|
|
|
|
valuekind = 0,
|
|
|
|
|
createdate = DateTime.Now.ToString("yyyyMMdd")
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(Log).ExecuteIdentity();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|