20023-08-10

This commit is contained in:
2023-08-10 11:40:02 +08:00
parent c41b3b9777
commit 02fcf5be10
82 changed files with 9031 additions and 2997 deletions
@@ -323,12 +323,12 @@ namespace BLL
public static void StatisticalData(string projectid, CQMSDateType cQMSDateType)
{
string thisUnitId = string.Empty;
var thisUnit = Const.UnitId_CWCEC;
var thisUnit = CommonService.GetIsThisUnit();
if (thisUnit != null)
{
thisUnitId = thisUnit;
thisUnitId = thisUnit.UnitId;
}
var base_Unit = BLL.UnitService.GetUnitByUnitId(thisUnitId);
var baseUnit = BLL.UnitService.GetUnitByUnitId(thisUnitId);
Model.Project_CQMSData_CQMS table = new Model.Project_CQMSData_CQMS();
if (IsReportByToday(projectid))
@@ -340,8 +340,8 @@ namespace BLL
table.Id = SQLHelper.GetNewID();
}
table.UnitId = thisUnitId;
table.CollCropCode = base_Unit.CollCropCode;
table.UnitName = base_Unit.UnitName;
table.CollCropCode = baseUnit.CollCropCode;
table.UnitName = baseUnit.UnitName;
table.ProjectId = projectid;
table.ReportDate = DateTime.Now.Date;
if (cQMSDateType == CQMSDateType.QualityTraining || cQMSDateType == CQMSDateType.All)
@@ -352,7 +352,7 @@ namespace BLL
if (cQMSDateType == CQMSDateType.MeasuringInstruments || cQMSDateType == CQMSDateType.All)
{
table.UseNum = GetUseNum(projectid);
table.OKNum = GetOKNum(projectid);
table.OKNum = GetOkNum(projectid);
}
if (cQMSDateType == CQMSDateType.ManagerData || cQMSDateType == CQMSDateType.All)
{
@@ -376,11 +376,11 @@ namespace BLL
if (cQMSDateType == CQMSDateType.QualityAcceptance || cQMSDateType == CQMSDateType.All)
{
table.KeyProcessNum = GetKeyProcessNum(projectid);
table.KeyProcessOKNum = GetKeyProcessOKNum(projectid);
table.KeyProcessOKNum = GetKeyProcessOkNum(projectid);
table.SpecialProcessNum = GetSpecialProcessNum(projectid);
table.SpecialProcessOKNum = GetSpecialProcessOKNum(projectid);
table.SpecialProcessOKNum = GetSpecialProcessOkNum(projectid);
table.ConcealedWorksNum = GetConcealedWorksNum(projectid);
table.ConcealedWorksOKNum = GetConcealedWorksOKNum(projectid);
table.ConcealedWorksOKNum = GetConcealedWorksOkNum(projectid);
table.UnitProjectOnesNum = GetUnitProjectOnesNum(projectid);
table.UnitProjectOnesOKNum = GetUnitProjectOnesOKNum(projectid);
table.MaterialInRecheckNum = GetMaterialInRecheckNum(projectid);
@@ -411,8 +411,8 @@ namespace BLL
/// <returns></returns>
public static int GetTrainPersonNum(string projectid)
{
int result = (from x in Funs.DB.Comprehensive_InspectionPerson
where x.ProjectId == projectid && x.IsTrain == true
var result = (from x in Funs.DB.Comprehensive_InspectionPerson
where x.ProjectId == projectid && x.IsTrain == true && x.CompileDate>Const.DtmarkTime
select x).Count();
return result;
}
@@ -422,8 +422,8 @@ namespace BLL
/// <returns></returns>
public static int GetTechnicalDisclosePersonNum(string projectid)
{
var result = (from x in Funs.DB.Comprehensive_DesignDetails
where x.ProjectId == projectid
var result = (from x in Funs.DB.Comprehensive_DesignDetails
where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime
select x.JoinPersonNum).ToList().Sum(x => x.Value);
var q = Funs.GetNewIntOrZero(result.ToString());
return q;
@@ -436,6 +436,7 @@ namespace BLL
{
int result = (from x in Funs.DB.Comprehensive_InspectionMachine
where x.ProjectId == projectid && x.IsOnSite == true && x.InspectionType.Contains("计量")
&& x.CompileDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -443,10 +444,11 @@ namespace BLL
/// 获取校准合格数
/// </summary>
/// <returns></returns>
public static int GetOKNum(string projectid)
public static int GetOkNum(string projectid)
{
int result = (from x in Funs.DB.Comprehensive_InspectionMachine
where x.ProjectId == projectid && x.IsOnSite == true && x.InspectionType.Contains("计量") && x.IsCheckOK == true
&& x.CompileDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -474,9 +476,9 @@ namespace BLL
/// <returns></returns>
public static int GetProjectPersonNum(string projectid)
{
int result = (from x in Funs.DB.Comprehensive_InspectionPerson
join y in Funs.DB.Base_WorkPost on x.PostId equals y.WorkPostId
where x.ProjectId == projectid && y.IsCQMS == true && x.IsOnSite == true
int result = (from x in Funs.DB.SitePerson_Person
join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId
where x.ProjectId == projectid && y.IsCQMS == true && x.IsUsed == true
select x).Count();
return result;
}
@@ -486,8 +488,8 @@ namespace BLL
/// <returns></returns>
public static int GetProblemNum(string projectid)
{
int result = (from x in Funs.DB.Check_CheckControl
where x.ProjectId == projectid && x.CheckDate <= DateTime.Now
int result = (from x in Funs.DB.Check_CheckControl
where x.ProjectId == projectid && x.CheckDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -498,7 +500,7 @@ namespace BLL
public static int GetProblemCompletedNum(string projectid)
{
int result = (from x in Funs.DB.Check_CheckControl
where x.ProjectId == projectid && x.CheckDate <= DateTime.Now && x.State == "7"
where x.ProjectId == projectid && x.CheckDate > Const.DtmarkTime && x.State == "7"
select x).Count();
return result;
}
@@ -509,7 +511,7 @@ namespace BLL
public static int GetProblemNotCompletedNum(string projectid)
{
int result = (from x in Funs.DB.Check_CheckControl
where x.ProjectId == projectid && x.CheckDate <= DateTime.Now && x.State != "7"
where x.ProjectId == projectid && x.CheckDate > Const.DtmarkTime && x.State != "7"
select x).Count();
return result;
}
@@ -520,7 +522,7 @@ namespace BLL
public static int GetSNum(string projectid)
{
int result = (from x in Funs.DB.WBS_BreakdownProject
where x.ProjectId == projectid && x.Class.Contains("S") && x.IsSelected == true
where x.ProjectId == projectid && x.Class.Contains("S") && x.IsSelected == true && x.CompileDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -531,7 +533,7 @@ namespace BLL
public static int GetANum(string projectid)
{
int result = (from x in Funs.DB.WBS_BreakdownProject
where x.ProjectId == projectid && x.Class.Contains("A") && x.IsSelected == true
where x.ProjectId == projectid && x.Class.Contains("A") && x.IsSelected == true && x.CompileDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -542,7 +544,7 @@ namespace BLL
public static int GetBNum(string projectid)
{
int result = (from x in Funs.DB.WBS_BreakdownProject
where x.ProjectId == projectid && x.Class.Contains("B") && x.IsSelected == true
where x.ProjectId == projectid && x.Class.Contains("B") && x.IsSelected == true && x.CompileDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -553,7 +555,7 @@ namespace BLL
public static int GetCNum(string projectid)
{
int result = (from x in Funs.DB.WBS_BreakdownProject
where x.ProjectId == projectid && x.Class.Contains("C") && x.IsSelected == true
where x.ProjectId == projectid && x.Class.Contains("C") && x.IsSelected == true && x.CompileDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -565,7 +567,7 @@ namespace BLL
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
where y.ProjectId == projectid && y.CheckAcceptType == "1"
where y.ProjectId == projectid && y.CheckAcceptType == "1" && x.CreateDate> Const.DtmarkTime
select x).Count();
return result;
}
@@ -573,12 +575,12 @@ namespace BLL
/// 获取关键工序验收合格数
/// </summary>
/// <returns></returns>
public static int GetKeyProcessOKNum(string projectid)
public static int GetKeyProcessOkNum(string projectid)
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId
where y.ProjectId == projectid && y.CheckAcceptType == "1" && z.IsOnceQualified == true
where y.ProjectId == projectid && y.CheckAcceptType == "1" && z.IsOnceQualified == true && x.CreateDate>Const.DtmarkTime
select x).Count();
return result;
}
@@ -590,7 +592,7 @@ namespace BLL
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
where y.ProjectId == projectid && y.CheckAcceptType == "2"
where y.ProjectId == projectid && y.CheckAcceptType == "2" && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -598,12 +600,12 @@ namespace BLL
/// 获取特殊过程验收合格数
/// </summary>
/// <returns></returns>
public static int GetSpecialProcessOKNum(string projectid)
public static int GetSpecialProcessOkNum(string projectid)
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId
where y.ProjectId == projectid && y.CheckAcceptType == "2" && z.IsOnceQualified == true
where y.ProjectId == projectid && y.CheckAcceptType == "2" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -615,7 +617,7 @@ namespace BLL
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
where y.ProjectId == projectid && y.CheckAcceptType == "3"
where y.ProjectId == projectid && y.CheckAcceptType == "3" && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -623,12 +625,12 @@ namespace BLL
/// 获取隐蔽工程验收合格数
/// </summary>
/// <returns></returns>
public static int GetConcealedWorksOKNum(string projectid)
public static int GetConcealedWorksOkNum(string projectid)
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId
where y.ProjectId == projectid && y.CheckAcceptType == "3" && z.IsOnceQualified == true
where y.ProjectId == projectid && y.CheckAcceptType == "3" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -640,7 +642,7 @@ namespace BLL
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
where y.ProjectId == projectid && y.CheckAcceptType == "4"
where y.ProjectId == projectid && y.CheckAcceptType == "4" && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -653,7 +655,7 @@ namespace BLL
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId
where y.ProjectId == projectid && y.CheckAcceptType == "4" && z.IsOnceQualified == true
where y.ProjectId == projectid && y.CheckAcceptType == "4" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -665,7 +667,7 @@ namespace BLL
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
where y.ProjectId == projectid && y.CheckAcceptType == "5"
where y.ProjectId == projectid && y.CheckAcceptType == "5" && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -678,7 +680,7 @@ namespace BLL
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId
where y.ProjectId == projectid && y.CheckAcceptType == "5" && z.IsOnceQualified == true
where y.ProjectId == projectid && y.CheckAcceptType == "5" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -689,7 +691,7 @@ namespace BLL
public static int GetSingleProjectNum(string projectid)
{
int result = (from x in Funs.DB.Project_Installation
where x.ProjectId == projectid && x.SuperInstallationId == "0"
where x.ProjectId == projectid && x.SuperInstallationId == "0"
select x).Count();
return result;
}
@@ -733,7 +735,7 @@ namespace BLL
public static int GetInspectionLotNum(string projectid)
{
int result = (from x in Funs.DB.WBS_BreakdownProject
where x.ProjectId == projectid && x.IsSelected == true
where x.ProjectId == projectid && x.IsSelected == true
select x).Count();
return result;
}
@@ -1,38 +1,39 @@
using FineUIPro;
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();
}
@@ -42,53 +43,51 @@ 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)
{
Model.Project_HJGLData_Defect table = new Model.Project_HJGLData_Defect
var table = new Project_HJGLData_Defect
{
Id = newtable.Id,
ProjectId = newtable.ProjectId,
@@ -97,16 +96,21 @@ namespace BLL
UnitName = newtable.UnitName,
ReportDate = newtable.ReportDate,
DefectName = newtable.DefectName,
DefectNum = newtable.DefectNum,
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)
{
db.Project_HJGLData_Defect.InsertAllOnSubmit(newtables);
db.SubmitChanges();
}
Model.Project_HJGLData_Defect table = db.Project_HJGLData_Defect.FirstOrDefault(x => x.Id == newtable.Id);
public static void UpdateProject_HJGLData_Defect(Project_HJGLData_Defect newtable)
{
var table = db.Project_HJGLData_Defect.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
{
table.Id = newtable.Id;
@@ -119,31 +123,40 @@ namespace BLL
table.DefectNum = newtable.DefectNum;
db.SubmitChanges();
}
}
public static void DeleteProject_HJGLData_DefectById(string Id)
{
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)
{
var table = db.Project_HJGLData_Defect.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0 && x.ProjectId == projectid);
public static void DeleteProject_HJGLData_DefectByDate(DateTime? reportDate)
{
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)
{
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>
@@ -152,73 +165,110 @@ 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;
}
/// <summary>
/// 统计所有在建项目数据
/// </summary>
public static void StatisticalAllProjectData()
{
var projectlist = ProjectService.GetProjectWorkList();
foreach (var item in projectlist)
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
)
{
StatisticalData(item.ProjectId);
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 = string.Empty;
var thisUnit = Const.UnitId_CWCEC;
if (thisUnit != null)
{
thisUnitId = thisUnit;
}
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.CH_CheckItem
join y in db.CH_Check on x.CHT_CheckID equals y.CHT_CheckID
where y.ProjectId == projectid
select x;
join y in db.CH_Check on x.CHT_CheckID equals y.CHT_CheckID
where y.ProjectId == projectid
select x;
var types = (from x in list select x.Defects_Definition).Distinct().ToList();
foreach (var t in types)
{
if (!string.IsNullOrEmpty(t))
{
Model.Project_HJGLData_Defect table = new Model.Project_HJGLData_Defect
var table = new Project_HJGLData_Defect
{
UnitId = thisUnitId,
CollCropCode = base_Unit.CollCropCode,
@@ -226,7 +276,7 @@ namespace BLL
ProjectId = projectid,
ReportDate = DateTime.Now.Date,
DefectName = t,
DefectNum = list.Count(x => x.Defects_Definition == t),
DefectNum = list.Count(x => x.Defects_Definition == t)
};
if (IsReportByToday(projectid, t))
{
@@ -239,27 +289,26 @@ namespace BLL
AddProject_HJGLData_Defect(table);
}
}
}
}
/// <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;
}
}
}
@@ -229,10 +229,10 @@ namespace BLL
public static void StatisticalData(string projectid,HJGLDateType hJGLDateType)
{
string thisUnitId = string.Empty;
var thisUnit = Const.UnitId_CWCEC;
var thisUnit = CommonService.GetIsThisUnit();
if (thisUnit != null)
{
thisUnitId = thisUnit;
thisUnitId = thisUnit.UnitId;
}
var base_Unit = BLL.UnitService.GetUnitByUnitId(thisUnitId);
Model.Project_HJGLData_HJGL table = new Model.Project_HJGLData_HJGL();
@@ -270,7 +270,7 @@ namespace BLL
}
if (hJGLDateType == HJGLDateType.DefectAnalysis || hJGLDateType == HJGLDateType.All)
{
Project_HJGLData_DefectService.StatisticalData(projectid);
// Project_HJGLData_DefectService.StatisticalData(projectid);
}
if (IsReportByToday(projectid))
@@ -367,31 +367,10 @@ namespace BLL
/// <returns></returns>
public static int GetTotalFilmNum(string projectid)
{
int result = 0;
if (projectid != null)
{
var getD1 = from x in Funs.DB.HJGL_FL_NdtList
where x.ProjectId == projectid.ToString()
select x;
if (getD1.Count() > 0)
{
foreach (var item in getD1)
{
result += Funs.GetNewIntOrZero(item.OneTimeFilmAmount.Split('.')[0]);
}
}
else
{
var getD2 = (from x in Funs.DB.HJGL_FL_Data
where x.ProjectId == projectid.ToString()
orderby x.CompileDate descending
select x).FirstOrDefault();
if (getD2 != null)
{
result = Funs.GetNewIntOrZero(getD2.OneTimeFilmAmount.Split('.')[0]);
}
}
}
int result = Convert.ToInt32((from x in Funs.DB.CH_CheckItem
join y in Funs.DB.CH_Check on x.CHT_CheckID equals y.CHT_CheckID
where y.ProjectId == projectid
select x.CHT_TotalFilm ).ToList().Sum());
return result;
}
/// <summary>
@@ -400,31 +379,10 @@ namespace BLL
/// <returns></returns>
public static int GetOKFilmNum(string projectid)
{
int result = 0;
if (projectid != null)
{
var getD1 = from x in Funs.DB.HJGL_FL_NdtList
where x.ProjectId == projectid.ToString()
select x;
if (getD1.Count() > 0)
{
foreach (var item in getD1)
{
result += Funs.GetNewIntOrZero(item.OneTimeFilmQualifiedAmount.Split('.')[0]);
}
}
else
{
var getD2 = (from x in Funs.DB.HJGL_FL_Data
where x.ProjectId == projectid.ToString()
orderby x.CompileDate descending
select x).FirstOrDefault();
if (getD2 != null)
{
result = Funs.GetNewIntOrZero(getD2.OneTimeFilmQualifiedAmount.Split('.')[0]);
}
}
}
int result = Convert.ToInt32((from x in Funs.DB.CH_CheckItem
join y in Funs.DB.CH_Check on x.CHT_CheckID equals y.CHT_CheckID
where y.ProjectId == projectid
select x.CHT_PassFilm).ToList().Sum());
return result;
}
File diff suppressed because it is too large Load Diff
@@ -1,5 +1,6 @@
using FineUIPro;
using Microsoft.SqlServer.Dts.Runtime;
using Model;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -83,59 +84,73 @@ namespace BLL
/// <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();
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
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
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
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();
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)
public static void AddBulkProject_HSSEData_HiddenDangerDetails(List<Model.Project_HSSEData_HiddenDangerDetail> newtables)
{
Model.Project_HSSEData_HiddenDangerDetail table = db.Project_HSSEData_HiddenDangerDetail.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
db.Project_HSSEData_HiddenDangerDetail.InsertAllOnSubmit(newtables);
db.SubmitChanges();
}
public static void UpdateProject_HSSEData_HiddenDangerDetail(Model.Project_HSSEData_HiddenDangerDetail newtable)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
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();
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)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
db.Project_HSSEData_HiddenDangerDetail.DeleteOnSubmit(table);
db.SubmitChanges();
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和日期删除隐患类别数据
@@ -144,14 +159,24 @@ namespace BLL
/// <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)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var table = db.Project_HSSEData_HiddenDangerDetail.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0 && x.ProjectId == projectid);
db.Project_HSSEData_HiddenDangerDetail.DeleteAllOnSubmit(table);
db.SubmitChanges();
}
}
public static void DeleteProject_HSSEData_HiddenDangerDetailByDate(DateTime? reportDate)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var table = db.Project_HSSEData_HiddenDangerDetail.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0 );
db.Project_HSSEData_HiddenDangerDetail.DeleteAllOnSubmit(table);
db.SubmitChanges();
}
}
/// <summary>
/// 根据projectid判断当天项目是否已统计数据
@@ -198,59 +223,57 @@ namespace BLL
}
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)
{
string thisUnitId = string.Empty;
var thisUnit = Const.UnitId_CWCEC;
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;
thisUnitId = thisUnit.UnitId;
}
var base_Unit = BLL.UnitService.GetUnitByUnitId(thisUnitId);
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
var baseUnit = BLL.UnitService.GetUnitByUnitId(thisUnitId);
var list = from x in db.HSSE_Hazard_HazardRegister where projectids.Contains(x.ProjectId)
select x;
var data = (from x in list
join y in db.HSSE_Hazard_HazardRegisterTypes on x.RegisterTypesId equals y.RegisterTypesId
group x by new
{ x.ProjectId, x.RegisterTypesId ,y.RegisterTypesName}
into g
select new
{
UnitId = thisUnitId,
CollCropCode = base_Unit.CollCropCode,
UnitName = base_Unit.UnitName,
ProjectId = projectid,
CollCropCode = baseUnit.CollCropCode,
UnitName = baseUnit.UnitName,
ProjectId= g.Key.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)),
TypeName=g.Key.RegisterTypesName,
TotalNum = g.Count(),
NeedRectifyNum = g.Count(x => x.States == "1"),
}).ToList();
DeleteProject_HSSEData_HiddenDangerDetailByDate(DateTime.Now.Date);
var projectHsseDataHiddenDangerDetails = new List<Project_HSSEData_HiddenDangerDetail>();
foreach (var item in data)
{
Project_HSSEData_HiddenDangerDetail table = new Project_HSSEData_HiddenDangerDetail
{
Id = SQLHelper.GetNewID(),
UnitId = item.UnitId,
CollCropCode = item.CollCropCode,
UnitName = item.UnitName,
ProjectId = item.ProjectId,
ReportDate = item.ReportDate,
TypeName = item.TypeName,
TotalNum = item.TotalNum,
NeedRectifyNum = item.NeedRectifyNum,
};
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);
}
projectHsseDataHiddenDangerDetails.Add(table);
}
AddBulkProject_HSSEData_HiddenDangerDetails(projectHsseDataHiddenDangerDetails);
}
/// <summary>
/// 获取类别名称
/// </summary>
@@ -298,10 +298,10 @@ namespace BLL
public static void StatisticalData(string projectid,SYHSESDateType sYHSESDateType)
{
string thisUnitId = string.Empty;
var thisUnit = Const.UnitId_CWCEC;
var thisUnit = CommonService.GetIsThisUnit();
if (thisUnit != null)
{
thisUnitId = thisUnit;
thisUnitId = thisUnit.UnitId;
}
var base_Unit = BLL.UnitService.GetUnitByUnitId(thisUnitId);
Model.Project_SYHSEData_SYHSE table = new Model.Project_SYHSEData_SYHSE();