123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using Cksoft.Data;
- using Cksoft.Data.Repository;
- using Cksoft.Unity;
- using Cksoft.Unity.Log4NetConfig;
- using DllEapDal.OFILM;
- using Microsoft.Extensions.Configuration;
- using System;
- namespace DllEapBll.Services
- {
- public class MacStatusService
- {
- private readonly IConfiguration configuration;
- public MacStatusService(IConfiguration configuration)
- {
- this.configuration = configuration;
- }
- public EapResponse GetTotalInfo(string filter, string recipe, string date, string type, int count = 0)
- {
- var res = new EapResponse { Code = 1, Msg = string.Empty };
- try
- {
- string errorinfo = string.Empty;
- using (IDatabase db = DbFactory.Base("eapslave"))
- {
- db.BeginTrans();
- var dal = new MacStatusTotalDal(db);
- var entity = dal.GetTotalInfo(filter, recipe, date, type, ref errorinfo);
- if (entity == null)
- {
- res.Code = -1;
- res.Msg = errorinfo;
- return res;
- }
- res.Data = entity;
- return res;
- }
- }
- catch (Exception ex)
- {
- LogHelper<MacStatusService>.LogError("查询机台看板数据错误,错误为:" + ex.ToString(),
- string.Empty, string.Empty);
- return res;
- }
-
- }
- public EapResponse GetProcessRunRate(string filter, string recipe, string date, string type)
- {
- var res = new EapResponse() { Code = 1, Msg = string.Empty };
- DateTime dateNow = DateTime.Now;
- DateTime dateStart;
- DateTime dateEnd;
- if (string.IsNullOrEmpty(date) || Convert.ToDateTime(date).ToString("yyyy-MM-dd") == dateNow.ToString("yyyy-MM-dd"))
- {
- if (dateNow <= new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 20, 30, 0)
- && dateNow > new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 8, 30, 0))
- {
- dateStart = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 8, 30, 0);
- }
- else
- {
- var yesterday = dateNow.AddDays(-1);
- dateStart = new DateTime(yesterday.Year, yesterday.Month, yesterday.Day, 20, 30, 0);
- }
- dateEnd = dateNow;
- }
- else
- {
- dateNow = Convert.ToDateTime(date);
- if (type == "1")//白班
- {
- dateStart = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 8, 30, 0);
- dateEnd = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 20, 30, 0);
- }
- else if (type == "2")//夜班
- {
- var tomorrow = dateNow.AddDays(1);
- dateStart = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 20, 30, 0);
- dateEnd = new DateTime(tomorrow.Year, tomorrow.Month, tomorrow.Day, 8, 30, 0);
- }
- else//整天
- {
- var tomorrow = dateNow.AddDays(1);
- dateStart = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 8, 30, 0);
- dateEnd = new DateTime(tomorrow.Year, tomorrow.Month, tomorrow.Day, 8, 30, 0);
- }
- }
- string errorinfo = string.Empty;
- using (IDatabase db = DbFactory.Base("eapslave"))
- {
- //db.BeginTrans();
- var dal = new MacStatusTotalDal(db, configuration);
- var dto = dal.GetProcessRunRate(filter, date, type, recipe, ref errorinfo);
- if (dto == null)
- {
- res.Code = -1;
- res.Msg = errorinfo;
- return res;
- }
- //db.Commit();
- res.Data = dto;
- return res;
- }
- }
- }
- }
|