提交代码
This commit is contained in:
@@ -1,39 +1,39 @@
|
||||
using FineUIPro;
|
||||
using Model;
|
||||
using Microsoft.SqlServer.Dts.Runtime;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Model;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
|
||||
public static class Project_HJGLData_DefectService
|
||||
{
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
public static SGGLDB db = Funs.DB;
|
||||
|
||||
|
||||
#region 获取列表
|
||||
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
public static int count
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static List<Model.Project_HJGLData_Defect> GetProject_HJGLData_DefectByModle(Model.Project_HJGLData_Defect table)
|
||||
public static int count { get; set; }
|
||||
|
||||
public static List<Project_HJGLData_Defect> GetProject_HJGLData_DefectByModle(Project_HJGLData_Defect table)
|
||||
{
|
||||
var q = from x in db.Project_HJGLData_Defect
|
||||
where
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
(string.IsNullOrEmpty(table.ProjectId) || x.Id.Contains(table.ProjectId)) &&
|
||||
(string.IsNullOrEmpty(table.UnitId) || x.UnitId.Contains(table.UnitId)) &&
|
||||
(string.IsNullOrEmpty(table.CollCropCode) || x.CollCropCode.Contains(table.CollCropCode)) &&
|
||||
(string.IsNullOrEmpty(table.UnitName) || x.UnitName.Contains(table.UnitName)) &&
|
||||
(string.IsNullOrEmpty(table.DefectName) || x.DefectName.Contains(table.DefectName))
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
(string.IsNullOrEmpty(table.ProjectId) || x.Id.Contains(table.ProjectId)) &&
|
||||
(string.IsNullOrEmpty(table.UnitId) || x.UnitId.Contains(table.UnitId)) &&
|
||||
(string.IsNullOrEmpty(table.CollCropCode) || x.CollCropCode.Contains(table.CollCropCode)) &&
|
||||
(string.IsNullOrEmpty(table.UnitName) || x.UnitName.Contains(table.UnitName)) &&
|
||||
(string.IsNullOrEmpty(table.DefectName) || x.DefectName.Contains(table.DefectName))
|
||||
select x
|
||||
;
|
||||
;
|
||||
|
||||
return q.ToList();
|
||||
}
|
||||
@@ -43,76 +43,83 @@ namespace BLL
|
||||
/// <param name="PageIndex">页码</param>
|
||||
/// <param name="PageSize">每页数量</param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable getListData(Model.Project_HJGLData_Defect table, Grid Grid1)
|
||||
public static IEnumerable getListData(Project_HJGLData_Defect table, Grid Grid1)
|
||||
{
|
||||
var q = GetProject_HJGLData_DefectByModle(table);
|
||||
count = q.Count();
|
||||
if (count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (count == 0) return null;
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return from x in q
|
||||
select new
|
||||
{
|
||||
x.Id,
|
||||
x.ProjectId,
|
||||
x.UnitId,
|
||||
x.CollCropCode,
|
||||
x.UnitName,
|
||||
x.ReportDate,
|
||||
x.DefectName,
|
||||
x.DefectNum,
|
||||
|
||||
};
|
||||
select new
|
||||
{
|
||||
x.Id,
|
||||
x.ProjectId,
|
||||
x.UnitId,
|
||||
x.CollCropCode,
|
||||
x.UnitName,
|
||||
x.ReportDate,
|
||||
x.DefectName,
|
||||
x.DefectNum
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static Model.Project_HJGLData_Defect GetProject_HJGLData_DefectById(string Id)
|
||||
public static Project_HJGLData_Defect GetProject_HJGLData_DefectById(string Id)
|
||||
{
|
||||
return db.Project_HJGLData_Defect.FirstOrDefault(x => x.Id == Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取项目该日期的缺陷分析数据
|
||||
/// </summary>
|
||||
/// <param name="reportDate"></param>
|
||||
/// <param name="projectid"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Model.Project_HJGLData_Defect> GetProject_HJGLData_DefectByDate(DateTime? reportDate, string projectid)
|
||||
public static List<Project_HJGLData_Defect> GetProject_HJGLData_DefectByDate(DateTime? reportDate,
|
||||
string projectid)
|
||||
{
|
||||
var q = from x in db.Project_HJGLData_Defect
|
||||
where x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0 && x.ProjectId == projectid
|
||||
select x;
|
||||
where x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0 && x.ProjectId == projectid
|
||||
select x;
|
||||
return q.ToList();
|
||||
}
|
||||
|
||||
public static void AddProject_HJGLData_Defect(Model.Project_HJGLData_Defect newtable)
|
||||
public static void AddProject_HJGLData_Defect(Project_HJGLData_Defect newtable)
|
||||
{
|
||||
using (var db = new SGGLDB(Funs.ConnString))
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
Model.Project_HJGLData_Defect table = new Model.Project_HJGLData_Defect
|
||||
{
|
||||
Id = newtable.Id,
|
||||
ProjectId = newtable.ProjectId,
|
||||
UnitId = newtable.UnitId,
|
||||
CollCropCode = newtable.CollCropCode,
|
||||
UnitName = newtable.UnitName,
|
||||
ReportDate = newtable.ReportDate,
|
||||
DefectName = newtable.DefectName,
|
||||
DefectNum = newtable.DefectNum,
|
||||
};
|
||||
db.Project_HJGLData_Defect.InsertOnSubmit(table);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
var table = new Project_HJGLData_Defect
|
||||
{
|
||||
Id = newtable.Id,
|
||||
ProjectId = newtable.ProjectId,
|
||||
UnitId = newtable.UnitId,
|
||||
CollCropCode = newtable.CollCropCode,
|
||||
UnitName = newtable.UnitName,
|
||||
ReportDate = newtable.ReportDate,
|
||||
DefectName = newtable.DefectName,
|
||||
DefectNum = newtable.DefectNum
|
||||
};
|
||||
db.Project_HJGLData_Defect.InsertOnSubmit(table);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
public static void UpdateProject_HJGLData_Defect(Model.Project_HJGLData_Defect newtable)
|
||||
public static void AddBulkProject_HJGLData_Defect(List<Project_HJGLData_Defect> newtables)
|
||||
{
|
||||
using (var db = new SGGLDB(Funs.ConnString))
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
Model.Project_HJGLData_Defect table = db.Project_HJGLData_Defect.FirstOrDefault(x => x.Id == newtable.Id);
|
||||
}
|
||||
db.Project_HJGLData_Defect.InsertAllOnSubmit(newtables);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
public static void UpdateProject_HJGLData_Defect(Project_HJGLData_Defect newtable)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var table = db.Project_HJGLData_Defect.FirstOrDefault(x => x.Id == newtable.Id);
|
||||
if (table != null)
|
||||
{
|
||||
table.Id = newtable.Id;
|
||||
@@ -125,39 +132,50 @@ namespace BLL
|
||||
table.DefectNum = newtable.DefectNum;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteProject_HJGLData_DefectById(string Id)
|
||||
{
|
||||
using (var db = new SGGLDB(Funs.ConnString))
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
Model.Project_HJGLData_Defect table = db.Project_HJGLData_Defect.FirstOrDefault(x => x.Id == Id);
|
||||
var table = db.Project_HJGLData_Defect.FirstOrDefault(x => x.Id == Id);
|
||||
if (table != null)
|
||||
{
|
||||
db.Project_HJGLData_Defect.DeleteOnSubmit(table);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
public static void DeleteProject_HJGLData_DefectByDate(DateTime? reportDate, string projectid)
|
||||
|
||||
public static void DeleteProject_HJGLData_DefectByDate(DateTime? reportDate)
|
||||
{
|
||||
using (var db = new SGGLDB(Funs.ConnString))
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var table = db.Project_HJGLData_Defect.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0 && x.ProjectId == projectid);
|
||||
var table = db.Project_HJGLData_Defect.Where(x =>
|
||||
x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0);
|
||||
if (table != null)
|
||||
{
|
||||
db.Project_HJGLData_Defect.DeleteAllOnSubmit(table);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void DeleteProject_HJGLData_DefectByDate(DateTime? reportDate, string projectid)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var table = db.Project_HJGLData_Defect.Where(x =>
|
||||
x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0 && x.ProjectId == projectid);
|
||||
if (table != null)
|
||||
{
|
||||
db.Project_HJGLData_Defect.DeleteAllOnSubmit(table);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断当天是否已统计数据
|
||||
/// </summary>
|
||||
@@ -166,37 +184,76 @@ namespace BLL
|
||||
{
|
||||
var result = false;
|
||||
var q = (from x in Funs.DB.Project_HJGLData_Defect
|
||||
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date && x.ProjectId == projectid && x.DefectName == type
|
||||
select x).ToList();
|
||||
if (q != null && q.Count > 0)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date &&
|
||||
x.ProjectId == projectid && x.DefectName == type
|
||||
select x).ToList();
|
||||
if (q != null && q.Count > 0) result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据projectid,获取当天的统计后的数据
|
||||
/// </summary>
|
||||
/// <param name="projectid"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.Project_HJGLData_Defect getTodayProject_HJGLData_Defect(string projectid, string type)
|
||||
public static Project_HJGLData_Defect getTodayProject_HJGLData_Defect(string projectid, string type)
|
||||
{
|
||||
var q = (from x in Funs.DB.Project_HJGLData_Defect
|
||||
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date && x.ProjectId == projectid && x.DefectName == type
|
||||
select x).FirstOrDefault();
|
||||
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date &&
|
||||
x.ProjectId == projectid && x.DefectName == type
|
||||
select x).FirstOrDefault();
|
||||
return q;
|
||||
}
|
||||
public static List<Model.HJGLDataDefectItems> getTodayProject_HJGLData_Defect()
|
||||
|
||||
public static List<HJGLDataDefectItems> getTodayProject_HJGLData_Defect()
|
||||
{
|
||||
var q = (from x in Funs.DB.Project_HJGLData_Defect
|
||||
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
|
||||
group x by x.DefectName into g
|
||||
select new Model.HJGLDataDefectItems
|
||||
{
|
||||
Id = SQLHelper.GetNewID(),
|
||||
DefectName = g.Key,
|
||||
DefectNum=g.Sum (p=>p.DefectNum)
|
||||
}).ToList();
|
||||
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
|
||||
group x by x.DefectName
|
||||
into g
|
||||
select new HJGLDataDefectItems
|
||||
{
|
||||
Id = SQLHelper.GetNewID(),
|
||||
DefectName = g.Key,
|
||||
DefectNum = g.Sum(p => p.DefectNum)
|
||||
}).ToList();
|
||||
return q;
|
||||
}
|
||||
public static List<HJGLDataDefectItems> GetModelByUnitIdAndReportDate(string Unitid, DateTime? reportdate)
|
||||
{
|
||||
if (!reportdate.HasValue)
|
||||
{
|
||||
return new List<HJGLDataDefectItems>();
|
||||
}
|
||||
var projectlist = BLL.ProjectService.GetProjectWorkList();
|
||||
var q = (from x in Funs.DB.Project_HJGLData_Defect
|
||||
where x.ReportDate == reportdate && projectlist.Select(e => e.ProjectId).Contains(x.ProjectId)
|
||||
group x by x.DefectName
|
||||
into g
|
||||
select new HJGLDataDefectItems
|
||||
{
|
||||
Id = SQLHelper.GetNewID(),
|
||||
DefectName = g.Key,
|
||||
DefectNum = g.Sum(p => p.DefectNum)
|
||||
}).ToList();
|
||||
return q;
|
||||
}
|
||||
public static List<HJGLDataDefectItems> GetModelByReportDate( DateTime? reportdate)
|
||||
{
|
||||
if (!reportdate.HasValue)
|
||||
{
|
||||
return new List<HJGLDataDefectItems>();
|
||||
}
|
||||
var q = (from x in Funs.DB.Project_HJGLData_Defect
|
||||
where x.ReportDate == reportdate
|
||||
group x by x.DefectName
|
||||
into g
|
||||
select new HJGLDataDefectItems
|
||||
{
|
||||
Id = SQLHelper.GetNewID(),
|
||||
DefectName = g.Key,
|
||||
DefectNum = g.Sum(p => p.DefectNum)
|
||||
}).ToList();
|
||||
return q;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -209,15 +266,60 @@ namespace BLL
|
||||
{
|
||||
StatisticalData(item.ProjectId);
|
||||
}
|
||||
//var db = Funs.DB;
|
||||
|
||||
//var projectids = ProjectService.GetProjectWorkList().Select(x => x.ProjectId).ToList();
|
||||
//var thisUnitId = string.Empty;
|
||||
//var thisUnit = CommonService.GetIsThisUnit();
|
||||
//if (thisUnit != null) thisUnitId = thisUnit.UnitId;
|
||||
//var baseUnit = UnitService.GetUnitByUnitId(thisUnitId);
|
||||
//var data = (from x in db.CH_CheckItem
|
||||
// join y in db.CH_Check on x.CHT_CheckID equals y.CHT_CheckID
|
||||
// where projectids.Contains(y.ProjectId)
|
||||
// group x by new { x.Defects_Definition, y.ProjectId }
|
||||
// into g
|
||||
// select new
|
||||
// {
|
||||
// UnitId = thisUnitId,
|
||||
// CollCropCode = baseUnit.CollCropCode,
|
||||
// UnitName = baseUnit.UnitName,
|
||||
// ProjectId = g.Key.ProjectId,
|
||||
// ReportDate = DateTime.Now.Date,
|
||||
// DefectName = g.Key.Defects_Definition,
|
||||
// DefectNum = g.Count(x => x.Defects_Definition == g.Key.Defects_Definition)
|
||||
// }).ToList();
|
||||
//DeleteProject_HJGLData_DefectByDate(DateTime.Now.Date); //删除当前所有
|
||||
//var projectHjglDataDefect = new List<Project_HJGLData_Defect>();
|
||||
//foreach (var item in data
|
||||
// )
|
||||
//{
|
||||
// var table = new Project_HJGLData_Defect
|
||||
// {
|
||||
// Id = SQLHelper.GetNewID(),
|
||||
// UnitId = item.UnitId,
|
||||
// CollCropCode = item.CollCropCode,
|
||||
// UnitName = item.UnitName,
|
||||
// ProjectId = item.ProjectId,
|
||||
// ReportDate = item.ReportDate,
|
||||
// DefectName = item.DefectName,
|
||||
// DefectNum = item.DefectNum
|
||||
// };
|
||||
// projectHjglDataDefect.Add(table);
|
||||
//}
|
||||
|
||||
//AddBulkProject_HJGLData_Defect(projectHjglDataDefect); //批量增加
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 统计数据
|
||||
/// </summary>
|
||||
/// <param name="projectid"></param>
|
||||
public static void StatisticalData(string projectid)
|
||||
{
|
||||
string thisUnitId = BLL.Const.UnitId_SEDIN;
|
||||
var base_Unit = BLL.UnitService.GetUnitByUnitId(thisUnitId);
|
||||
var thisUnitId = string.Empty;
|
||||
var thisUnit = CommonService.GetIsThisUnit();
|
||||
if (thisUnit != null) thisUnitId = thisUnit.UnitId;
|
||||
var base_Unit = UnitService.GetUnitByUnitId(thisUnitId);
|
||||
var list = from x in db.HJGL_Batch_NDEItem
|
||||
join y in db.HJGL_Batch_NDE on x.NDEID equals y.NDEID
|
||||
where y.ProjectId == projectid
|
||||
@@ -250,25 +352,25 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取缺陷名称
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetDefectName(string projectid)
|
||||
{
|
||||
string result = "";
|
||||
var result = "";
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取缺陷数量
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static int GetDefectNum(string projectid)
|
||||
{
|
||||
int result = 0;
|
||||
var result = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user