一厂MES,含注塑,喷涂,冲孔
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.

892 lines
34 KiB

3 months ago
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.Injection;
using MESClassLibrary.DAL.painting;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.Injection
{
public class InjectionDownRecordBLL
{
BBMPTEntities ef = new BBMPTEntities();
BasicBLL<tb_Injection_DownRecord> db = new BasicBLL<tb_Injection_DownRecord>();
InjectionDownRecordDAL dal = new InjectionDownRecordDAL();
public bool AddInfo(InjectionDownRecordModel md)
{
InjectionDownRecordDAL da = new InjectionDownRecordDAL();
try
{
return da.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateInfo(InjectionDownRecordModel md)
{
InjectionDownRecordDAL da = new InjectionDownRecordDAL();
try
{
return da.UpdateInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
#region web用方法
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize, string StartTime, string EndTime, string StationID)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
DateTime stime = Convert.ToDateTime(StartTime);
DateTime etime = Convert.ToDateTime(EndTime);
List<tb_Injection_DownRecord> list = ef.tb_Injection_DownRecord.Where(p => p.StartTime >= stime && p.EndTime <= etime && p.DownTime >= 60).ToList();
if (!String.IsNullOrEmpty(StationID))
{
list = list.Where(p => p.StationID.Equals(StationID)).ToList();
}
List<Injection_DownRecordModel> modelList = new List<Injection_DownRecordModel>();
if (list.Count > 0)
{
#region 联查
BasicBLL<tb_Station> machine_db = new BasicBLL<tb_Station>();
var machine_list = machine_db.SearchAllInfo();
BasicBLL<tb_Inhection_DownReason> DownReason_db = new BasicBLL<tb_Inhection_DownReason>();
var DownReason_list = DownReason_db.SearchAllInfo();
BasicBLL<tb_Injection_DownType> DownType_db = new BasicBLL<tb_Injection_DownType>();
var DownType_list = DownType_db.SearchAllInfo();
foreach (var item in list)
{
Injection_DownRecordModel dm = Tool.Mapper<Injection_DownRecordModel, tb_Injection_DownRecord>(item);
var machine_info = machine_list.FirstOrDefault(p => p.StationID == item.StationID);
if (machine_info != null)
{
dm.StationNo = machine_info.StationNo;
}
var DownReason = DownReason_list.FirstOrDefault(p => p.ID == item.DownReason);
if (DownReason != null)
{
dm.DownReasonName = DownReason.Reason;
}
var DownType = DownType_list.FirstOrDefault(p => p.ID == item.DownType);
if (DownType != null)
{
dm.DownTypeName = DownType.DownTypeName;
}
modelList.Add(dm);
}
#endregion
total = modelList.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
modelList = modelList.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<Injection_DownRecordModel> md = new JsonDataModel<Injection_DownRecordModel>();
md.total = total.ToString();
md.rows = modelList;
jsonStr = JSONTools.ScriptSerialize(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdateInfo(tb_Injection_DownRecord md)
{
try
{
//初始化要更新的字段
string[] proNames = new string[8];
proNames[0] = "StationID";
proNames[1] = "DownType";
proNames[2] = "DownReason";
proNames[3] = "Des";
proNames[4] = "StartTime";
proNames[5] = "EndTime";
proNames[6] = "DownTime";
proNames[7] = "Remark1";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string GetComboboxDataByDownType()
{
try
{
string jsonStr = "[]";
var list = ef.tb_Injection_DownType.ToList();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
public string GetComboboxDataByDownReason()
{
try
{
string jsonStr = "[]";
var list = ef.tb_Inhection_DownReason.ToList();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
public bool UpdateData(List<DownRecordVO> list, string DownRecordID)
{
try
{
foreach (var item in list)
{
tb_Injection_DownRecord md = new tb_Injection_DownRecord();
md.ID = Guid.NewGuid().ToString();
md.StationID = item.StationID;
md.PlanID = item.PlanID;
md.StartTime = Convert.ToDateTime(item.StartTime);
md.EndTime = Convert.ToDateTime(item.EndTime);
TimeSpan ts = md.EndTime.Value.Subtract(md.StartTime.Value);
md.DownTime = (int)ts.TotalSeconds;
md.DownType = item.DownType;
md.DownReason = item.DownReason;
md.Des = "";
md.Remark1 = item.Remark1;
md.Remark2 = "2";
db.AddInfo(md);
}
var info = ef.tb_Injection_DownRecord.FirstOrDefault(p => p.ID == DownRecordID);
info.Remark2 = "1";
ef.SaveChanges();
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
#endregion
#region 报表
//每日平均换膜次数
public string SearchDay(string StartTime)
{
try
{
DateTime sTime = Convert.ToDateTime(StartTime);
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(sTime.Year, sTime.Month);
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchByTime(Convert.ToDateTime(sTime.Year + "-" + sTime.Month + "-01 08:00:00").ToString("yyyy-MM-dd HH:mm:ss"), Convert.ToDateTime(sTime.Year + "-" + sTime.Month + "-" + days.ToString() + " 07:59:59").AddDays(1).ToString("yyyy-MM-dd HH:mm:ss"));
if (dt != null && dt.Rows.Count > 0)
{
List<string> titleList = new List<string>();
List<double> Day_totalList = new List<double>();
List<double> Night_totalList = new List<double>();
for (int i = 0; i < days; i++)
{
titleList.Add((i + 1).ToString());
DateTime dtime = Convert.ToDateTime(sTime.Year + "-" + sTime.Month + "-" + (i + 1));
//白班
var DayList = from myRow in dt.AsEnumerable()
where myRow.Field<DateTime>(5) >= Convert.ToDateTime(dtime.ToString("yyyy-MM-dd") + " 08:00:00.000") &&
myRow.Field<DateTime>(6) <= Convert.ToDateTime(dtime.ToString("yyyy-MM-dd") + " 19:59:59.999")
select myRow;
if (DayList.Count() > 0)
{
int Day_int = DayList.Sum(p => Convert.ToInt32(p.ItemArray[7]));
Day_totalList.Add(Math.Round((Day_int / (double)DayList.Count()) / 60, 2));
}
else
{
Day_totalList.Add(0);
}
//夜班
var NightList = from myRowNight in dt.AsEnumerable()
where myRowNight.Field<DateTime>(5) >= Convert.ToDateTime(dtime.ToString("yyyy-MM-dd") + " 20:00:00.000") &&
myRowNight.Field<DateTime>(6) <= Convert.ToDateTime(dtime.AddDays(1).ToString("yyyy-MM-dd") + " 07:59:59.999")
select myRowNight;
if (NightList.Count() > 0)
{
int Night_int = NightList.Sum(p => Convert.ToInt32(p.ItemArray[7]));
Night_totalList.Add(Math.Round((Night_int / (double)NightList.Count()) / 60, 2));
}
else
{
Night_totalList.Add(0);
}
}
sb.Append("<table border='1'>");
sb.Append("<tr>");
sb.Append("<td width='50'>班次/日期</td>");
foreach (var item in titleList)
{
sb.Append("<td width='50'>" + item + "</td>");
}
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td width='100'>白班</td>");
foreach (var item in Day_totalList)
{
sb.Append("<td width='50'>" + item + "</td>");
}
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td width='100'>夜班</td>");
foreach (var item in Night_totalList)
{
sb.Append("<td width='50'>" + item + "</td>");
}
sb.Append("</tr>");
sb.Append("</table>");
}
return sb.ToString();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
//每日平均换膜次数导出excel
public List<List<string>> SearchDayForExcel(string StartTime)
{
try
{
List<List<string>> list = new List<List<string>>();
DateTime sTime = Convert.ToDateTime(StartTime);
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(sTime.Year, sTime.Month);
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchByTime(Convert.ToDateTime(sTime.Year + "-" + sTime.Month + "-01 08:00:00").ToString("yyyy-MM-dd HH:mm:ss"), Convert.ToDateTime(sTime.Year + "-" + sTime.Month + "-" + days.ToString() + " 07:59:59").AddDays(1).ToString("yyyy-MM-dd HH:mm:ss"));
if (dt != null && dt.Rows.Count > 0)
{
List<string> titleList = new List<string>();
List<double> Day_totalList = new List<double>();
List<double> Night_totalList = new List<double>();
for (int i = 0; i < days; i++)
{
titleList.Add((i + 1).ToString());
DateTime dtime = Convert.ToDateTime(sTime.Year + "-" + sTime.Month + "-" + (i + 1));
//白班
var DayList = from myRow in dt.AsEnumerable()
where myRow.Field<DateTime>(5) >= Convert.ToDateTime(dtime.ToString("yyyy-MM-dd") + " 08:00:00.000") &&
myRow.Field<DateTime>(6) <= Convert.ToDateTime(dtime.ToString("yyyy-MM-dd") + " 19:59:59.999")
select myRow;
if (DayList.Count() > 0)
{
int Day_int = DayList.Sum(p => Convert.ToInt32(p.ItemArray[7]));
Day_totalList.Add(Math.Round((Day_int / (double)DayList.Count()) / 60, 2));
}
else
{
Day_totalList.Add(0);
}
//夜班
var NightList = from myRowNight in dt.AsEnumerable()
where myRowNight.Field<DateTime>(5) >= Convert.ToDateTime(dtime.ToString("yyyy-MM-dd") + " 20:00:00.000") &&
myRowNight.Field<DateTime>(6) <= Convert.ToDateTime(dtime.AddDays(1).ToString("yyyy-MM-dd") + " 07:59:59.999")
select myRowNight;
if (NightList.Count() > 0)
{
int Night_int = NightList.Sum(p => Convert.ToInt32(p.ItemArray[7]));
Night_totalList.Add(Math.Round((Night_int / (double)NightList.Count()) / 60, 2));
}
else
{
Night_totalList.Add(0);
}
}
List<string> title_ = new List<string>();
title_.Add("班次/日期");
title_.AddRange(titleList);
list.Add(title_);
List<string> total_ = new List<string>();
total_.Add("白班");
foreach (var item in Day_totalList)
{
total_.Add(item.ToString());
}
list.Add(total_);
List<string> No_total_ = new List<string>();
No_total_.Add("夜班");
foreach (var item in Night_totalList)
{
No_total_.Add(item.ToString());
}
list.Add(No_total_);
}
return list;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
//每月平均换膜次数
public string SearchMonth(string StartTime)
{
try
{
DateTime sTime = Convert.ToDateTime(StartTime);
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchByTime(sTime.Year + "-01-01", sTime.Year + "-12-31");
if (dt != null && dt.Rows.Count > 0)
{
DateTime startT = Convert.ToDateTime(sTime.Year + "-01-01");
List<string> titleList = new List<string>();
List<double> Day_totalList = new List<double>();
for (int i = 0; i < 12; i++)
{
titleList.Add((i + 1) + "月");
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(startT.Year, (i + 1));
var DayList = from myRow in dt.AsEnumerable()
where myRow.Field<DateTime>(5) >= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-01") &&
myRow.Field<DateTime>(6) <= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-" + days)
select myRow;
if (DayList.Count() > 0)
{
int Day_int = DayList.Sum(p => Convert.ToInt32(p.ItemArray[7]));
Day_totalList.Add(Math.Round((Day_int / (double)DayList.Count()) / 60, 2));
}
else
{
Day_totalList.Add(0);
}
}
sb.Append("<table border='1'>");
sb.Append("<tr>");
sb.Append("<td width='50'>月份</td>");
foreach (var item in titleList)
{
sb.Append("<td width='50'>" + item + "</td>");
}
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td width='100'>平均换膜时间</td>");
foreach (var item in Day_totalList)
{
sb.Append("<td width='50'>" + item + "</td>");
}
sb.Append("</tr>");
sb.Append("</table>");
}
return sb.ToString();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public List<List<string>> SearchMonthForExcel(string StartTime)
{
try
{
List<List<string>> list = new List<List<string>>();
DateTime sTime = Convert.ToDateTime(StartTime);
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchByTime(sTime.Year + "-01-01", sTime.Year + "-12-31");
if (dt != null && dt.Rows.Count > 0)
{
DateTime startT = Convert.ToDateTime(sTime.Year + "-01-01");
List<string> titleList = new List<string>();
List<double> Day_totalList = new List<double>();
for (int i = 0; i < 12; i++)
{
titleList.Add((i + 1) + "月");
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(startT.Year, (i + 1));
var DayList = from myRow in dt.AsEnumerable()
where myRow.Field<DateTime>(5) >= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-01") &&
myRow.Field<DateTime>(6) <= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-" + days)
select myRow;
if (DayList.Count() > 0)
{
int Day_int = DayList.Sum(p => Convert.ToInt32(p.ItemArray[7]));
Day_totalList.Add(Math.Round((Day_int / (double)DayList.Count()) / 60, 2));
}
else
{
Day_totalList.Add(0);
}
}
List<string> title_ = new List<string>();
title_.Add("月份");
title_.AddRange(titleList);
list.Add(title_);
List<string> total_ = new List<string>();
total_.Add("平均换膜时间");
foreach (var item in Day_totalList)
{
total_.Add(item.ToString());
}
list.Add(total_);
}
return list;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
//每月换膜次数
public string SearchMonthTimes(string StartTime)
{
try
{
DateTime sTime = Convert.ToDateTime(StartTime);
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchByTime(sTime.Year + "-01-01", sTime.Year + "-12-31");
if (dt != null && dt.Rows.Count > 0)
{
DateTime startT = Convert.ToDateTime(sTime.Year + "-01-01");
List<string> titleList = new List<string>();
List<double> Day_totalList = new List<double>();
for (int i = 0; i < 12; i++)
{
titleList.Add((i + 1) + "月");
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(startT.Year, (i + 1));
var DayList = from myRow in dt.AsEnumerable()
where myRow.Field<DateTime>(5) >= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-01") &&
myRow.Field<DateTime>(6) <= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-" + days)
select myRow;
Day_totalList.Add(DayList.Count());
}
sb.Append("<table border='1'>");
sb.Append("<tr>");
sb.Append("<td width='50'>月份</td>");
foreach (var item in titleList)
{
sb.Append("<td width='50'>" + item + "</td>");
}
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td width='100'>换模次数</td>");
foreach (var item in Day_totalList)
{
sb.Append("<td width='50'>" + item + "</td>");
}
sb.Append("</tr>");
sb.Append("</table>");
}
return sb.ToString();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public List<List<string>> SearchMonthTimesForExcel(string StartTime)
{
try
{
List<List<string>> list = new List<List<string>>();
DateTime sTime = Convert.ToDateTime(StartTime);
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchByTime(sTime.Year + "-01-01", sTime.Year + "-12-31");
if (dt != null && dt.Rows.Count > 0)
{
DateTime startT = Convert.ToDateTime(sTime.Year + "-01-01");
List<string> titleList = new List<string>();
List<double> Day_totalList = new List<double>();
for (int i = 0; i < 12; i++)
{
titleList.Add((i + 1) + "月");
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(startT.Year, (i + 1));
var DayList = from myRow in dt.AsEnumerable()
where myRow.Field<DateTime>(5) >= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-01") &&
myRow.Field<DateTime>(6) <= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-" + days)
select myRow;
Day_totalList.Add(DayList.Count());
}
List<string> title_ = new List<string>();
title_.Add("月份");
title_.AddRange(titleList);
list.Add(title_);
List<string> total_ = new List<string>();
total_.Add("换模次数");
foreach (var item in Day_totalList)
{
total_.Add(item.ToString());
}
list.Add(total_);
}
return list;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
//换膜记录单
public string SearchChangeRecord(string StartTime, string EndTime, string ModelId)
{
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchChangeRecord(StartTime, EndTime, ModelId);
sb.Append("<table border='1'>");
sb.Append("<tr>");
sb.Append("<td width='50'>机台号</td>");
sb.Append("<td width='50'>日期</td>");
sb.Append("<td width='50'>起始时间</td>");
sb.Append("<td width='50'>总计时间</td>");
sb.Append("<td width='50'>累计合模数</td>");
sb.Append("<td width='50'>生产合模数</td>");
sb.Append("<td width='50'>日期章</td>");
sb.Append("<td width='50'>换膜人</td>");
sb.Append("</tr>");
for (int i = 0; i < dt.Rows.Count; i++)
{
sb.Append("<tr>");
sb.Append("<td width='50'>" + dt.Rows[i]["StationNo"] + "</td>");
sb.Append("<td width='50'>" + Convert.ToDateTime(dt.Rows[i]["PrintDate"]).ToString("yyyy-MM-dd") + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["StartTime"] + "</td>");
sb.Append("<td width='50'>" + Math.Round((Convert.ToDouble(dt.Rows[i]["DownTime"]) / 60), 2) + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["ModelSumCount"] + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["ModelPrintCount"] + "</td>");
sb.Append("<td width='50'>" + Convert.ToDateTime(dt.Rows[i]["PrintDate"]).Month + "月</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["remark1"] + "</td>");
sb.Append("</tr>");
}
sb.Append("</table>");
return sb.ToString();
}
public List<List<string>> SearchChangeRecordForExcel(string StartTime, string EndTime, string ModelId)
{
try
{
List<List<string>> list = new List<List<string>>();
DataTable dt = dal.SearchChangeRecord(StartTime, EndTime, ModelId);
List<string> titleList = new List<string>();
titleList.Add("机台号");
titleList.Add("日期");
titleList.Add("起始时间");
titleList.Add("总计时间");
titleList.Add("累计合模数");
titleList.Add("生产合模数");
titleList.Add("日期章");
titleList.Add("换膜人");
list.Add(titleList);
for (int i = 0; i < dt.Rows.Count; i++)
{
List<string> total_ = new List<string>();
total_.Add(dt.Rows[i]["StationNo"].ToString());
total_.Add(Convert.ToDateTime(dt.Rows[i]["PrintDate"]).ToString("yyyy-MM-dd"));
total_.Add(dt.Rows[i]["StartTime"].ToString());
total_.Add(Math.Round((Convert.ToDouble(dt.Rows[i]["DownTime"]) / 60), 2).ToString());
total_.Add(dt.Rows[i]["ModelSumCount"].ToString());
total_.Add(dt.Rows[i]["ModelPrintCount"].ToString());
total_.Add(Convert.ToDateTime(dt.Rows[i]["PrintDate"]).Month + "月</td>");
total_.Add(dt.Rows[i]["remark1"].ToString());
list.Add(total_);
}
return list;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
//维修记录
public string SearchRepairRecord(string StartTime, string EndTime)
{
try
{
DateTime sTime = Convert.ToDateTime(StartTime);
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchRepaorByTime(StartTime, EndTime);
sb.Append("<table border='1'>");
sb.Append("<tr>");
sb.Append("<td width='50'>序号</td>");
sb.Append("<td width='50'>日期</td>");
sb.Append("<td width='50'>班次</td>");
sb.Append("<td width='50'>设备名称</td>");
sb.Append("<td width='50'>故障现象</td>");
sb.Append("<td width='50'>维修时间</td>");
sb.Append("<td width='50'>故障原因</td>");
sb.Append("<td width='100'>维修内容及更换配件</td>");
sb.Append("<td width='50'>维修人</td>");
sb.Append("</tr>");
if (dt != null && dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
sb.Append("<tr>");
sb.Append("<td width='50'>" + (i + 1) + "</td>");
sb.Append("<td width='50'>" + Convert.ToDateTime(dt.Rows[i]["StartTime"]).ToString("yyyy-MM-dd") + "</td>");
sb.Append("<td width='50'>" + CheckWorkClass(dt.Rows[i]["StartTime"].ToString()) + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["StationNo"] + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["Des"] + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["DownTime"] + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["Remark2"] + "</td>");
sb.Append("<td width='100'>" + dt.Rows[i]["Remark3"] + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["Remark1"] + "</td>");
sb.Append("</tr>");
}
}
sb.Append("</table>");
return sb.ToString();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public List<List<string>> SearchRepairRecordForExcel(string StartTime, string EndTime)
{
try
{
List<List<string>> list = new List<List<string>>();
DataTable dt = dal.SearchRepaorByTime(StartTime, EndTime);
List<string> titleList = new List<string>();
titleList.Add("序号");
titleList.Add("日期");
titleList.Add("班次");
titleList.Add("设备名称");
titleList.Add("故障现象");
titleList.Add("维修时间");
titleList.Add("故障原因");
titleList.Add("维修内容及更换配件");
titleList.Add("维修人");
list.Add(titleList);
for (int i = 0; i < dt.Rows.Count; i++)
{
List<string> total_ = new List<string>();
total_.Add((i + 1).ToString());
total_.Add(Convert.ToDateTime(dt.Rows[i]["StartTime"]).ToString("yyyy-MM-dd"));
total_.Add(CheckWorkClass(dt.Rows[i]["StartTime"].ToString()));
total_.Add(dt.Rows[i]["StationNo"].ToString());
total_.Add(dt.Rows[i]["Des"].ToString());
total_.Add(dt.Rows[i]["DownTime"].ToString());
total_.Add(dt.Rows[i]["Remark2"].ToString());
total_.Add(dt.Rows[i]["Remark3"].ToString());
total_.Add(dt.Rows[i]["Remark1"].ToString());
list.Add(total_);
}
return list;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
private string CheckWorkClass(string StartTime)
{
try
{
if (true)
{
string time = StartTime.Substring(0, StartTime.IndexOf(" "));
if (DateTime.Compare(Convert.ToDateTime(StartTime), Convert.ToDateTime(time + " 08:00:00")) > 0 && DateTime.Compare(Convert.ToDateTime(time + " 19:59:59"), Convert.ToDateTime(StartTime)) > 0)
{
return "A";
}
return "B";
}
}
catch (Exception ex)
{
}
return "";
}
#endregion
}
}