修改集团客户化内容
This commit is contained in:
@@ -0,0 +1,277 @@
|
||||
using FineUIPro;
|
||||
using Microsoft.SqlServer.Dts.Runtime;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
|
||||
public static class Project_HSSEData_HiddenDangerDetailService
|
||||
{
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
|
||||
|
||||
#region 获取列表
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
public static int count
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static List<Model.Project_HSSEData_HiddenDangerDetail> GetProject_HSSEData_HiddenDangerDetailByModle(Model.Project_HSSEData_HiddenDangerDetail table)
|
||||
{
|
||||
var q = from x in db.Project_HSSEData_HiddenDangerDetail
|
||||
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.TypeName) || x.TypeName.Contains(table.TypeName))
|
||||
select x
|
||||
;
|
||||
|
||||
return q.ToList();
|
||||
}
|
||||
|
||||
/// 获取分页列表
|
||||
/// </summary>
|
||||
/// <param name="PageIndex">页码</param>
|
||||
/// <param name="PageSize">每页数量</param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable getListData(Model.Project_HSSEData_HiddenDangerDetail table, Grid Grid1)
|
||||
{
|
||||
var q = GetProject_HSSEData_HiddenDangerDetailByModle(table);
|
||||
count = q.Count();
|
||||
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.TypeName,
|
||||
x.TotalNum,
|
||||
x.NeedRectifyNum,
|
||||
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static Model.Project_HSSEData_HiddenDangerDetail GetModelById(string Id)
|
||||
{
|
||||
return db.Project_HSSEData_HiddenDangerDetail.FirstOrDefault(x => x.Id == Id);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取项目该日期的隐患类别数据
|
||||
/// </summary>
|
||||
/// <param name="reportDate"></param>
|
||||
/// <param name="projectid"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Model.Project_HSSEData_HiddenDangerDetail> GetProject_HSSEData_HiddenDangerDetailByDate(DateTime? reportDate, string projectid)
|
||||
{
|
||||
var q = from x in db.Project_HSSEData_HiddenDangerDetail
|
||||
where x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0 && x.ProjectId == projectid
|
||||
select x;
|
||||
return q.ToList();
|
||||
}
|
||||
public static void AddProject_HSSEData_HiddenDangerDetail(Model.Project_HSSEData_HiddenDangerDetail newtable)
|
||||
{
|
||||
|
||||
Model.Project_HSSEData_HiddenDangerDetail table = new Model.Project_HSSEData_HiddenDangerDetail
|
||||
{
|
||||
Id = newtable.Id,
|
||||
ProjectId = newtable.ProjectId,
|
||||
UnitId = newtable.UnitId,
|
||||
CollCropCode = newtable.CollCropCode,
|
||||
UnitName = newtable.UnitName,
|
||||
ReportDate = newtable.ReportDate,
|
||||
TypeName = newtable.TypeName,
|
||||
TotalNum = newtable.TotalNum,
|
||||
NeedRectifyNum = newtable.NeedRectifyNum,
|
||||
};
|
||||
db.Project_HSSEData_HiddenDangerDetail.InsertOnSubmit(table);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
public static void UpdateProject_HSSEData_HiddenDangerDetail(Model.Project_HSSEData_HiddenDangerDetail newtable)
|
||||
{
|
||||
|
||||
Model.Project_HSSEData_HiddenDangerDetail table = db.Project_HSSEData_HiddenDangerDetail.FirstOrDefault(x => x.Id == newtable.Id);
|
||||
if (table != null)
|
||||
{
|
||||
table.Id = newtable.Id;
|
||||
table.ProjectId = table.ProjectId;
|
||||
table.UnitId = newtable.UnitId;
|
||||
table.CollCropCode = newtable.CollCropCode;
|
||||
table.UnitName = newtable.UnitName;
|
||||
table.ReportDate = newtable.ReportDate;
|
||||
table.TypeName = newtable.TypeName;
|
||||
table.TotalNum = newtable.TotalNum;
|
||||
table.NeedRectifyNum = newtable.NeedRectifyNum;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
public static void DeleteProject_HSSEData_HiddenDangerDetailById(string Id)
|
||||
{
|
||||
|
||||
Model.Project_HSSEData_HiddenDangerDetail table = db.Project_HSSEData_HiddenDangerDetail.FirstOrDefault(x => x.Id == Id);
|
||||
if (table != null)
|
||||
{
|
||||
db.Project_HSSEData_HiddenDangerDetail.DeleteOnSubmit(table);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据项目id和日期删除隐患类别数据
|
||||
/// </summary>
|
||||
/// <param name="reportDate"></param>
|
||||
/// <param name="projectid"></param>
|
||||
public static void DeleteProject_HSSEData_HiddenDangerDetailByDate(DateTime? reportDate, string projectid)
|
||||
{
|
||||
|
||||
var table = db.Project_HSSEData_HiddenDangerDetail.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0 && x.ProjectId == projectid);
|
||||
if (table != null)
|
||||
{
|
||||
db.Project_HSSEData_HiddenDangerDetail.DeleteAllOnSubmit(table);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据projectid判断当天项目是否已统计数据
|
||||
/// </summary>
|
||||
/// <param name="projectid"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsReportByToday(string projectid, string type)
|
||||
{
|
||||
var result = false;
|
||||
var q = (from x in Funs.DB.Project_HSSEData_HiddenDangerDetail
|
||||
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date && x.ProjectId == projectid && x.TypeName == 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_HSSEData_HiddenDangerDetail GetTodayModelByProjectAndType(string projectid, string type)
|
||||
{
|
||||
var q = (from x in Funs.DB.Project_HSSEData_HiddenDangerDetail
|
||||
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date && x.ProjectId == projectid && x.TypeName == type
|
||||
select x).FirstOrDefault();
|
||||
return q;
|
||||
}
|
||||
public static List<Model.HSSEDataHiddenDangerDetailItem> GetTodayModel()
|
||||
{
|
||||
var q = (from x in Funs.DB.Project_HSSEData_HiddenDangerDetail
|
||||
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
|
||||
group x by x.TypeName into g
|
||||
select new Model.HSSEDataHiddenDangerDetailItem
|
||||
{
|
||||
Id = SQLHelper.GetNewID(),
|
||||
TypeName= g.Key,
|
||||
NeedRectifyNum= g.Sum(p => p.NeedRectifyNum),
|
||||
TotalNum= g.Sum(p => p.TotalNum)
|
||||
}).ToList();
|
||||
return q;
|
||||
}
|
||||
public static void StatisticalAllProjectData()
|
||||
{
|
||||
var projectlist = ProjectService.GetProjectWorkList();
|
||||
foreach (var item in projectlist)
|
||||
{
|
||||
StatisticalData(item.ProjectId);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 统计数据
|
||||
/// </summary>
|
||||
/// <param name="projectid"></param>
|
||||
public static void StatisticalData(string projectid)
|
||||
{
|
||||
//var base_Unit = BLL.UnitService.GetUnitByUnitId(BLL.Const.UnitId_SEDIN);
|
||||
//DateTime date = DateTime.Now;
|
||||
//Model.SGGLDB db = Funs.DB;
|
||||
//var list = from x in db.Check_RectifyNoticesItem
|
||||
// join y in db.Check_RectifyNotices on x.RectifyNoticesId equals y.RectifyNoticesId
|
||||
// where y.ProjectId == projectid && y.CheckedDate.Value.Year == date.Year && y.CheckedDate.Value.Month == date.Month && y.CheckedDate.Value.Day == date.Day
|
||||
// select x;
|
||||
//var types = (from x in db.Technique_Rectify
|
||||
// join y in list on x.RectifyId equals y.RectifyId
|
||||
// select new { x.RectifyId, x.RectifyName }).Distinct().ToList();
|
||||
//foreach (var type in types)
|
||||
//{
|
||||
// Model.Project_HSSEData_HiddenDangerDetail table = new Model.Project_HSSEData_HiddenDangerDetail
|
||||
// {
|
||||
// UnitId = BLL.Const.UnitId_SEDIN,
|
||||
// CollCropCode = base_Unit.CollCropCode,
|
||||
// UnitName = base_Unit.UnitName,
|
||||
// ProjectId = projectid,
|
||||
// ReportDate = DateTime.Now.Date,
|
||||
// TypeName = type.RectifyName,
|
||||
// TotalNum = list.Count(x => x.RectifyId == type.RectifyId),
|
||||
// NeedRectifyNum = list.Count(x => x.RectifyId == type.RectifyId && (x.IsRectify == null || x.IsRectify == false)),
|
||||
// };
|
||||
// if (IsReportByToday(projectid, type.RectifyName))
|
||||
// {
|
||||
// table.Id = GetTodayModelByProjectAndType(projectid, type.RectifyName).Id;
|
||||
// UpdateProject_HSSEData_HiddenDangerDetail(table);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// table.Id = SQLHelper.GetNewID();
|
||||
// AddProject_HSSEData_HiddenDangerDetail(table);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取类别名称
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetTypeName(string projectid)
|
||||
{
|
||||
string result = "";
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取全部数量
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static int GetTotalNum(string projectid)
|
||||
{
|
||||
int result = 0;
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取待整改数量
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static int GetNeedRectifyNum(string projectid)
|
||||
{
|
||||
int result = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user