You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
208 lines
7.7 KiB
208 lines
7.7 KiB
using MESClassLibrary.BLL.Log;
|
|
using MESClassLibrary.EFModel;
|
|
using MESClassLibrary.Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MESClassLibrary.BLL.Inspection
|
|
{
|
|
public class CommonlyInspectionVersionBLL
|
|
{
|
|
BasicBLL<tb_CommonlyInspectionVersion> db = new BasicBLL<tb_CommonlyInspectionVersion>();
|
|
/// <summary>
|
|
/// 查询信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string SearchInfo(string page, string pagesize,string deviceID)
|
|
{
|
|
try
|
|
{
|
|
|
|
BasicBLL<tb_Station> station_db = new BasicBLL<tb_Station>();
|
|
BasicBLL<tb_Device> device_db = new BasicBLL<tb_Device>();
|
|
|
|
var station_list = station_db.SearchAllInfo().ToList();
|
|
var device_list = device_db.SearchAllInfo().ToList();
|
|
|
|
|
|
string jsonStr = "[]";
|
|
int total = 0;//总行数
|
|
List<tb_CommonlyInspectionVersion> list = null;
|
|
|
|
list = db.SearchAllInfo().ToList();
|
|
|
|
|
|
if (deviceID != "")
|
|
{
|
|
list = list.Where(p => p.DeviceID.Equals(deviceID)).ToList();
|
|
}
|
|
|
|
List<CommonlyInspectionVersionModel> CommonlyInspectionVersionList = new List<CommonlyInspectionVersionModel>();
|
|
if (list.Count > 0)
|
|
{
|
|
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
|
|
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
|
|
|
|
total = list.Count;
|
|
|
|
#region 联查
|
|
|
|
|
|
foreach (var item in list)
|
|
{
|
|
CommonlyInspectionVersionModel dm = Tool.Mapper<CommonlyInspectionVersionModel, tb_CommonlyInspectionVersion>(item);
|
|
var info = device_list.FirstOrDefault(p => p.DeviceID.Equals(item.DeviceID));
|
|
if (info != null)
|
|
{
|
|
dm.DeviceID = info.DeviceID;
|
|
dm.DeviceName = info.DeviceNo + "----" + info.DeviceName;
|
|
}
|
|
if (item.IsUseing == 1)
|
|
{
|
|
dm.IsUseingName = "启用";
|
|
}
|
|
CommonlyInspectionVersionList.Add(dm);
|
|
}
|
|
#endregion
|
|
JsonDataModel<CommonlyInspectionVersionModel> md = new JsonDataModel<CommonlyInspectionVersionModel>();
|
|
md.total = total.ToString();
|
|
md.rows = CommonlyInspectionVersionList;
|
|
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<CommonlyInspectionVersionModel>>(md);
|
|
}
|
|
return jsonStr;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return "";
|
|
}
|
|
|
|
|
|
}
|
|
/// <summary>
|
|
/// 添加信息
|
|
/// </summary>
|
|
/// <param name="md">模型对象</param>
|
|
/// <returns></returns>
|
|
public bool AddInfo(tb_CommonlyInspectionVersion md, string s)
|
|
{
|
|
try
|
|
{
|
|
var list = db.SearchInfoByKey("DeviceID", md.DeviceID).Where(p => p.Version == md.Version).ToList();//判断是否有重复数据
|
|
if (list.Count > 0)
|
|
{
|
|
return false;
|
|
}
|
|
if (db.AddInfo(md))
|
|
{
|
|
BasicBLL<tb_CommonlyInspection> CommonlyInspection_db = new BasicBLL<tb_CommonlyInspection>();
|
|
string[] arry = s.Split(',');
|
|
for (int i = 0; i < arry.Length; i++)
|
|
{
|
|
tb_CommonlyInspection m = new tb_CommonlyInspection();
|
|
m.ID = Guid.NewGuid().ToString();
|
|
m.VersionID = md.ID;
|
|
m.InspectionContentID = arry[i];
|
|
m.CreateUserID = md.CreateUserID;
|
|
m.CreateTime = md.CreateTime;
|
|
m.IsUseing = 1;
|
|
CommonlyInspection_db.AddInfo(m);
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return false;
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 修改信息
|
|
/// </summary>
|
|
/// <param name="md">模型对象</param>
|
|
/// <returns></returns>
|
|
public bool UpdateInfo(tb_CommonlyInspectionVersion md)
|
|
{
|
|
try
|
|
{
|
|
//var list = db.SearchInfoByKey("ProductionLineID", md.ProductionLineID).Where(p => p.DeviceNo == md.DeviceNo).ToList();//判断是否有重复数据
|
|
//if (list.Count > 0)
|
|
//{
|
|
// return false;
|
|
//}
|
|
////初始化要更新的字段
|
|
//string[] proNames = new string[6];
|
|
//proNames[0] = "ProductionLineID";
|
|
//proNames[1] = "DeviceNo";
|
|
//proNames[2] = "DeviceName";
|
|
//proNames[3] = "Description";
|
|
//proNames[4] = "UpdateUserID";
|
|
//proNames[5] = "UpdateTime";
|
|
|
|
////必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
|
|
////如果没有初始化必填字段,更新会报错
|
|
//md.CreateUserID = "";
|
|
|
|
//return db.UpdateInfo(md, proNames);
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return false;
|
|
}
|
|
}
|
|
/// 删除生产线信息
|
|
public bool DelInfo(tb_CommonlyInspectionVersion md)
|
|
{
|
|
try
|
|
{
|
|
////初始化要更新的字段
|
|
//string[] proNames = new string[3];
|
|
//proNames[0] = "IsUseing";
|
|
//proNames[1] = "DisableTime";
|
|
//proNames[2] = "DisableUserID";
|
|
|
|
////必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
|
|
////如果没有初始化必填字段,更新会报错
|
|
//md.ProductionLineID = 0;
|
|
//md.DeviceNo = "";
|
|
//md.DeviceName = "";
|
|
//md.CreateUserID = "";
|
|
//return db.UpdateInfo(md, proNames);
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return false;
|
|
}
|
|
}
|
|
public string GetComboboxData(string deviceID)
|
|
{
|
|
try
|
|
{
|
|
string jsonStr = "[]";
|
|
var list = db.SearchInfoByKey("IsUseing", 1).ToList();//判断是否有重复数据
|
|
if (deviceID != null && deviceID != "")
|
|
{
|
|
list = list.Where(p => p.DeviceID.Equals(deviceID)).ToList();
|
|
}
|
|
jsonStr = JSONTools.ScriptSerialize<List<tb_CommonlyInspectionVersion>>(list);
|
|
return jsonStr;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return "";
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|