提交代码

This commit is contained in:
2024-12-25 15:43:38 +08:00
parent 0a2f9ea3a7
commit c0b489aaf4
79 changed files with 8536 additions and 1546 deletions
+207 -150
View File
@@ -49,105 +49,157 @@ namespace BLL
// q= q.Take(Grid1.PageSize * Grid1.PageIndex).Skip(Grid1.PageSize * (Grid1.PageIndex)).ToList();
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
return from x in q
select new
{
x.Id,
x.UnitId,
x.CollCropCode,
x.UnitName,
x.ReportDate,
x.TrainPersonNum,
x.TechnicalDisclosePersonNum,
x.UseNum,
x.OKNum,
x.CompanyPersonNum,
x.BranchPersonNum,
x.ProjectPersonNum,
x.ProblemNum,
x.ProblemCompletedNum,
x.ProblemNotCompletedNum,
x.SNum,
x.ANum,
x.BNum,
x.CNum,
x.KeyProcessNum,
x.KeyProcessOKNum,
x.SpecialProcessNum,
x.SpecialProcessOKNum,
x.ConcealedWorksNum,
x.ConcealedWorksOKNum,
x.UnitProjectOnesNum,
x.UnitProjectOnesOKNum,
x.MaterialInRecheckNum,
x.MaterialInRecheckOKNum,
x.SingleProjectNum,
x.UnitProjectNum,
x.SubProjectNum,
x.SubdivisionalWorksNum,
x.InspectionLotNum,
x.State,
x.CreateDate,
x.CreateMan
};
select new
{
x.Id,
x.UnitId,
x.CollCropCode,
x.UnitName,
x.ReportDate,
x.TrainPersonNum,
x.TechnicalDisclosePersonNum,
x.UseNum,
x.OKNum,
x.CompanyPersonNum,
x.BranchPersonNum,
x.ProjectPersonNum,
x.ProblemNum,
x.ProblemCompletedNum,
x.ProblemNotCompletedNum,
x.SNum,
x.ANum,
x.BNum,
x.CNum,
x.KeyProcessNum,
x.KeyProcessOKNum,
x.SpecialProcessNum,
x.SpecialProcessOKNum,
x.ConcealedWorksNum,
x.ConcealedWorksOKNum,
x.UnitProjectOnesNum,
x.UnitProjectOnesOKNum,
x.MaterialInRecheckNum,
x.MaterialInRecheckOKNum,
x.SingleProjectNum,
x.UnitProjectNum,
x.SubProjectNum,
x.SubdivisionalWorksNum,
x.InspectionLotNum,
x.State,
x.CreateDate,
x.CreateMan
};
}
#endregion
public static void AddCQMSData_CQMS(CQMSData_CQMS newtable)
{
var db = Funs.DB;
var table = new CQMSData_CQMS
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Id = newtable.Id,
UnitId = newtable.UnitId,
CollCropCode = newtable.CollCropCode,
UnitName = newtable.UnitName,
ReportDate = newtable.ReportDate,
TrainPersonNum = newtable.TrainPersonNum,
TechnicalDisclosePersonNum = newtable.TechnicalDisclosePersonNum,
UseNum = newtable.UseNum,
OKNum = newtable.OKNum,
CompanyPersonNum = newtable.CompanyPersonNum,
BranchPersonNum = newtable.BranchPersonNum,
ProjectPersonNum = newtable.ProjectPersonNum,
ProblemNum = newtable.ProblemNum,
ProblemCompletedNum = newtable.ProblemCompletedNum,
ProblemNotCompletedNum = newtable.ProblemNotCompletedNum,
SNum = newtable.SNum,
ANum = newtable.ANum,
BNum = newtable.BNum,
CNum = newtable.CNum,
KeyProcessNum = newtable.KeyProcessNum,
KeyProcessOKNum = newtable.KeyProcessOKNum,
SpecialProcessNum = newtable.SpecialProcessNum,
SpecialProcessOKNum = newtable.SpecialProcessOKNum,
ConcealedWorksNum = newtable.ConcealedWorksNum,
ConcealedWorksOKNum = newtable.ConcealedWorksOKNum,
UnitProjectOnesNum = newtable.UnitProjectOnesNum,
UnitProjectOnesOKNum = newtable.UnitProjectOnesOKNum,
MaterialInRecheckNum = newtable.MaterialInRecheckNum,
MaterialInRecheckOKNum = newtable.MaterialInRecheckOKNum,
SingleProjectNum = newtable.SingleProjectNum,
UnitProjectNum = newtable.UnitProjectNum,
SubProjectNum = newtable.SubProjectNum,
SubdivisionalWorksNum = newtable.SubdivisionalWorksNum,
InspectionLotNum = newtable.InspectionLotNum,
State = newtable.State,
CreateDate = newtable.CreateDate,
CreateMan = newtable.CreateMan
};
db.CQMSData_CQMS.InsertOnSubmit(table);
db.SubmitChanges();
var table = new CQMSData_CQMS
{
Id = newtable.Id,
UnitId = newtable.UnitId,
CollCropCode = newtable.CollCropCode,
UnitName = newtable.UnitName,
ReportDate = newtable.ReportDate,
TrainPersonNum = newtable.TrainPersonNum,
TechnicalDisclosePersonNum = newtable.TechnicalDisclosePersonNum,
UseNum = newtable.UseNum,
OKNum = newtable.OKNum,
CompanyPersonNum = newtable.CompanyPersonNum,
BranchPersonNum = newtable.BranchPersonNum,
ProjectPersonNum = newtable.ProjectPersonNum,
ProblemNum = newtable.ProblemNum,
ProblemCompletedNum = newtable.ProblemCompletedNum,
ProblemNotCompletedNum = newtable.ProblemNotCompletedNum,
SNum = newtable.SNum,
ANum = newtable.ANum,
BNum = newtable.BNum,
CNum = newtable.CNum,
KeyProcessNum = newtable.KeyProcessNum,
KeyProcessOKNum = newtable.KeyProcessOKNum,
SpecialProcessNum = newtable.SpecialProcessNum,
SpecialProcessOKNum = newtable.SpecialProcessOKNum,
ConcealedWorksNum = newtable.ConcealedWorksNum,
ConcealedWorksOKNum = newtable.ConcealedWorksOKNum,
UnitProjectOnesNum = newtable.UnitProjectOnesNum,
UnitProjectOnesOKNum = newtable.UnitProjectOnesOKNum,
MaterialInRecheckNum = newtable.MaterialInRecheckNum,
MaterialInRecheckOKNum = newtable.MaterialInRecheckOKNum,
SingleProjectNum = newtable.SingleProjectNum,
UnitProjectNum = newtable.UnitProjectNum,
SubProjectNum = newtable.SubProjectNum,
SubdivisionalWorksNum = newtable.SubdivisionalWorksNum,
InspectionLotNum = newtable.InspectionLotNum,
State = newtable.State,
CreateDate = newtable.CreateDate,
CreateMan = newtable.CreateMan
};
db.CQMSData_CQMS.InsertOnSubmit(table);
db.SubmitChanges();
}
}
public static void UpdateCQMSData_CQMS(CQMSData_CQMS newtable)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var table = db.CQMSData_CQMS.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
{
table.Id = newtable.Id;
table.UnitId = newtable.UnitId;
table.CollCropCode = newtable.CollCropCode;
table.UnitName = newtable.UnitName;
table.ReportDate = newtable.ReportDate;
table.TrainPersonNum = newtable.TrainPersonNum;
table.TechnicalDisclosePersonNum = newtable.TechnicalDisclosePersonNum;
table.UseNum = newtable.UseNum;
table.OKNum = newtable.OKNum;
table.CompanyPersonNum = newtable.CompanyPersonNum;
table.BranchPersonNum = newtable.BranchPersonNum;
table.ProjectPersonNum = newtable.ProjectPersonNum;
table.ProblemNum = newtable.ProblemNum;
table.ProblemCompletedNum = newtable.ProblemCompletedNum;
table.ProblemNotCompletedNum = newtable.ProblemNotCompletedNum;
table.SNum = newtable.SNum;
table.ANum = newtable.ANum;
table.BNum = newtable.BNum;
table.CNum = newtable.CNum;
table.KeyProcessNum = newtable.KeyProcessNum;
table.KeyProcessOKNum = newtable.KeyProcessOKNum;
table.SpecialProcessNum = newtable.SpecialProcessNum;
table.SpecialProcessOKNum = newtable.SpecialProcessOKNum;
table.ConcealedWorksNum = newtable.ConcealedWorksNum;
table.ConcealedWorksOKNum = newtable.ConcealedWorksOKNum;
table.UnitProjectOnesNum = newtable.UnitProjectOnesNum;
table.UnitProjectOnesOKNum = newtable.UnitProjectOnesOKNum;
table.MaterialInRecheckNum = newtable.MaterialInRecheckNum;
table.MaterialInRecheckOKNum = newtable.MaterialInRecheckOKNum;
table.SingleProjectNum = newtable.SingleProjectNum;
table.UnitProjectNum = newtable.UnitProjectNum;
table.SubProjectNum = newtable.SubProjectNum;
table.SubdivisionalWorksNum = newtable.SubdivisionalWorksNum;
table.InspectionLotNum = newtable.InspectionLotNum;
table.State = newtable.State;
table.CreateMan = newtable.CreateMan;
table.CreateDate = newtable.CreateDate;
db.SubmitChanges();
}
}
}
public static void DeleteCQMSData_CQMSById(string id)
{
var db = Funs.DB;
var table = db.CQMSData_CQMS.FirstOrDefault(x => x.Id == id);
if (table != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
db.CQMSData_CQMS.DeleteOnSubmit(table);
db.SubmitChanges();
var table = db.CQMSData_CQMS.FirstOrDefault(x => x.Id == id);
if (table != null)
{
db.CQMSData_CQMS.DeleteOnSubmit(table);
db.SubmitChanges();
}
}
}
@@ -232,11 +284,63 @@ namespace BLL
public static CQMSData_CQMS GetTodayData()
{
var q = (from x in Funs.DB.CQMSData_CQMS
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
select x).FirstOrDefault();
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
select x).FirstOrDefault();
return q;
}
public static CQMSData_CQMS GetSubUnitCqmsDataByDate(string Unitid, DateTime? reportdate)
{
var result = new Model.CQMSData_CQMS();
if (reportdate == null)
{
return result;
}
var projectlist = BLL.ProjectService.GetProjectWorkList();
var base_Unit = UnitService.GetUnitByUnitId(Unitid);
var ProjectData = (from x in Funs.DB.Project_CQMSData_CQMS
where x.ReportDate == reportdate && projectlist.Select(e => e.ProjectId).Contains(x.ProjectId)
select x).ToList();
result = new CQMSData_CQMS
{
UnitId = Unitid,
CollCropCode = base_Unit.CollCropCode,
UnitName = base_Unit.UnitName,
ReportDate = DateTime.Now.Date,
TrainPersonNum = ProjectData.Sum(x => x.TrainPersonNum),
TechnicalDisclosePersonNum = ProjectData.Sum(x => x.TechnicalDisclosePersonNum),
UseNum = ProjectData.Sum(x => x.UseNum),
OKNum = ProjectData.Sum(x => x.OKNum),
CompanyPersonNum = GetCompanyPersonNum(),
BranchPersonNum = GetBranchPersonNum(),
ProjectPersonNum = ProjectData.Sum(x => x.ProjectPersonNum),
ProblemNum = ProjectData.Sum(x => x.ProblemNum),
ProblemCompletedNum = ProjectData.Sum(x => x.ProblemCompletedNum),
ProblemNotCompletedNum = ProjectData.Sum(x => x.ProblemNotCompletedNum),
SNum = ProjectData.Sum(x => x.SNum),
ANum = ProjectData.Sum(x => x.ANum),
BNum = ProjectData.Sum(x => x.BNum),
CNum = ProjectData.Sum(x => x.CNum),
KeyProcessNum = ProjectData.Sum(x => x.KeyProcessNum),
KeyProcessOKNum = ProjectData.Sum(x => x.KeyProcessOKNum),
SpecialProcessNum = ProjectData.Sum(x => x.SpecialProcessNum),
SpecialProcessOKNum = ProjectData.Sum(x => x.SpecialProcessOKNum),
ConcealedWorksNum = ProjectData.Sum(x => x.ConcealedWorksNum),
ConcealedWorksOKNum = ProjectData.Sum(x => x.ConcealedWorksOKNum),
UnitProjectOnesNum = ProjectData.Sum(x => x.UnitProjectOnesNum),
UnitProjectOnesOKNum = ProjectData.Sum(x => x.UnitProjectOnesOKNum),
MaterialInRecheckNum = ProjectData.Sum(x => x.MaterialInRecheckNum),
MaterialInRecheckOKNum = ProjectData.Sum(x => x.MaterialInRecheckOKNum),
SingleProjectNum = ProjectData.Sum(x => x.SingleProjectNum),
UnitProjectNum = ProjectData.Sum(x => x.UnitProjectNum),
SubProjectNum = ProjectData.Sum(x => x.SubProjectNum),
SubdivisionalWorksNum = ProjectData.Sum(x => x.SubdivisionalWorksNum),
InspectionLotNum = ProjectData.Sum(x => x.InspectionLotNum),
CreateMan = Const.sysglyId,
CreateDate = DateTime.Now
};
return result;
}
public static void UpdateTodyData_State()
{
var q = GetTodayData();
@@ -251,8 +355,8 @@ namespace BLL
{
var result = false;
var q = (from x in Funs.DB.CQMSData_CQMS
where x.ReportDate >= dateTime.Date && x.ReportDate < dateTime.Date.AddDays(1).Date
select x).ToList();
where x.ReportDate >= dateTime.Date && x.ReportDate < dateTime.Date.AddDays(1).Date
select x).ToList();
if (q.Count > 0) result = true;
return result;
}
@@ -265,8 +369,8 @@ namespace BLL
{
var result = false;
var q = (from x in Funs.DB.CQMSData_CQMS
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
select x).ToList();
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
select x).ToList();
if (q.Count > 0) result = true;
return result;
}
@@ -289,8 +393,8 @@ namespace BLL
Project_CQMSDataService.StatisticalAllProjectData();
var ProjectData = (from x in Funs.DB.Project_CQMSData_CQMS
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
select x).ToList();
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
select x).ToList();
var table = new CQMSData_CQMS
{
UnitId = thisUnitId,
@@ -396,52 +500,6 @@ namespace BLL
return data;
}
public static void UpdateCQMSData_CQMS(CQMSData_CQMS newtable)
{
var db = Funs.DB;
var table = db.CQMSData_CQMS.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
{
table.Id = newtable.Id;
table.UnitId = newtable.UnitId;
table.CollCropCode = newtable.CollCropCode;
table.UnitName = newtable.UnitName;
table.ReportDate = newtable.ReportDate;
table.TrainPersonNum = newtable.TrainPersonNum;
table.TechnicalDisclosePersonNum = newtable.TechnicalDisclosePersonNum;
table.UseNum = newtable.UseNum;
table.OKNum = newtable.OKNum;
table.CompanyPersonNum = newtable.CompanyPersonNum;
table.BranchPersonNum = newtable.BranchPersonNum;
table.ProjectPersonNum = newtable.ProjectPersonNum;
table.ProblemNum = newtable.ProblemNum;
table.ProblemCompletedNum = newtable.ProblemCompletedNum;
table.ProblemNotCompletedNum = newtable.ProblemNotCompletedNum;
table.SNum = newtable.SNum;
table.ANum = newtable.ANum;
table.BNum = newtable.BNum;
table.CNum = newtable.CNum;
table.KeyProcessNum = newtable.KeyProcessNum;
table.KeyProcessOKNum = newtable.KeyProcessOKNum;
table.SpecialProcessNum = newtable.SpecialProcessNum;
table.SpecialProcessOKNum = newtable.SpecialProcessOKNum;
table.ConcealedWorksNum = newtable.ConcealedWorksNum;
table.ConcealedWorksOKNum = newtable.ConcealedWorksOKNum;
table.UnitProjectOnesNum = newtable.UnitProjectOnesNum;
table.UnitProjectOnesOKNum = newtable.UnitProjectOnesOKNum;
table.MaterialInRecheckNum = newtable.MaterialInRecheckNum;
table.MaterialInRecheckOKNum = newtable.MaterialInRecheckOKNum;
table.SingleProjectNum = newtable.SingleProjectNum;
table.UnitProjectNum = newtable.UnitProjectNum;
table.SubProjectNum = newtable.SubProjectNum;
table.SubdivisionalWorksNum = newtable.SubdivisionalWorksNum;
table.InspectionLotNum = newtable.InspectionLotNum;
table.State = newtable.State;
table.CreateMan = newtable.CreateMan;
table.CreateDate = newtable.CreateDate;
db.SubmitChanges();
}
}
/// <summary>
/// 获取企业总部人数
@@ -453,10 +511,10 @@ namespace BLL
var thisUnit = CommonService.GetIsThisUnit();
if (thisUnit != null) unitId = thisUnit.UnitId;
var result = (from x in Funs.DB.Person_Persons
join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId
where x.IsPost == true && y.IsCQMS == true && x.UnitId == unitId
select x).Count();
return 0;
join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId
where x.IsPost == true && y.IsCQMS == true && x.UnitId == unitId
select x).Count();
return result;
}
/// <summary>
@@ -470,10 +528,9 @@ namespace BLL
if (thisUnit != null) unitId = thisUnit.UnitId;
var result = (from x in Funs.DB.Person_Persons
join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId
join z in Funs.DB.Base_Unit on x.UnitId equals z.UnitId
where x.IsPost == true && y.IsCQMS == true && x.UnitId != unitId && z.IsBranch== true
select x).Count();
return 0;
where x.IsPost == true && y.IsCQMS == true && x.UnitId != unitId
select x).Count();
return result;
}
}
}
@@ -31,7 +31,7 @@ namespace BLL
(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.DefectName) || x.DefectName.Contains(table.DefectName))
select x
;
@@ -51,7 +51,7 @@ namespace BLL
{
return null;
}
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
return from x in q
select new
{
@@ -75,66 +75,71 @@ namespace BLL
{
var q = from x in db.HJGLData_Defect
where x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0
select x;
select x;
return q.ToList();
}
public static void AddHJGLData_Defect(Model.HJGLData_Defect newtable)
{
Model.HJGLData_Defect table = new Model.HJGLData_Defect
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Id = newtable.Id,
UnitId = newtable.UnitId,
CollCropCode = newtable.CollCropCode,
UnitName = newtable.UnitName,
ReportDate = newtable.ReportDate,
DefectName = newtable.DefectName,
DefectNum = newtable.DefectNum,
};
db.HJGLData_Defect.InsertOnSubmit(table);
db.SubmitChanges();
Model.HJGLData_Defect table = new Model.HJGLData_Defect
{
Id = newtable.Id,
UnitId = newtable.UnitId,
CollCropCode = newtable.CollCropCode,
UnitName = newtable.UnitName,
ReportDate = newtable.ReportDate,
DefectName = newtable.DefectName,
DefectNum = newtable.DefectNum,
};
db.HJGLData_Defect.InsertOnSubmit(table);
db.SubmitChanges();
}
}
public static void UpdateHJGLData_Defect(Model.HJGLData_Defect newtable)
{
Model.HJGLData_Defect table = db.HJGLData_Defect.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
table.Id = newtable.Id;
table.UnitId = newtable.UnitId;
table.CollCropCode = newtable.CollCropCode;
table.UnitName = newtable.UnitName;
table.ReportDate = newtable.ReportDate;
table.DefectName = newtable.DefectName;
table.DefectNum = newtable.DefectNum;
db.SubmitChanges();
Model.HJGLData_Defect table = db.HJGLData_Defect.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
{
table.Id = newtable.Id;
table.UnitId = newtable.UnitId;
table.CollCropCode = newtable.CollCropCode;
table.UnitName = newtable.UnitName;
table.ReportDate = newtable.ReportDate;
table.DefectName = newtable.DefectName;
table.DefectNum = newtable.DefectNum;
db.SubmitChanges();
}
}
}
public static void DeleteHJGLData_DefectById(string Id)
{
Model.HJGLData_Defect table = db.HJGLData_Defect.FirstOrDefault(x => x.Id == Id);
if (table != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
db.HJGLData_Defect.DeleteOnSubmit(table);
db.SubmitChanges();
Model.HJGLData_Defect table = db.HJGLData_Defect.FirstOrDefault(x => x.Id == Id);
if (table != null)
{
db.HJGLData_Defect.DeleteOnSubmit(table);
db.SubmitChanges();
}
}
}
public static void DeleteHJGLData_DefectByDate(DateTime? reportDate)
{
var table = db.HJGLData_Defect.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0);
if (table != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
db.HJGLData_Defect.DeleteAllOnSubmit(table);
db.SubmitChanges();
}
var table = db.HJGLData_Defect.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0);
if (table != null)
{
db.HJGLData_Defect.DeleteAllOnSubmit(table);
db.SubmitChanges();
}
}
}
}
+146 -73
View File
@@ -6,7 +6,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;
using System.Net.PeerToPeer;
namespace BLL
{
@@ -49,58 +49,64 @@ namespace BLL
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.UnitId,
x.CollCropCode,
x.UnitName,
x.ReportDate,
x.WelderNum,
x.TotalDineNum,
x.CompleteDineNum,
x.TotalFilmNum,
x.OKFilmNum,
x.State,
x.CreateDate,
x.CreateMan
};
select new
{
x.Id,
x.UnitId,
x.CollCropCode,
x.UnitName,
x.ReportDate,
x.WelderNum,
x.TotalDineNum,
x.CompleteDineNum,
x.TotalFilmNum,
x.OKFilmNum,
x.State,
x.CreateDate,
x.CreateMan
};
}
#endregion
public static void AddHJGLData_HJGL(HJGLData_HJGL newtable)
{
var db = Funs.DB;
var table = new HJGLData_HJGL
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Id = newtable.Id,
UnitId = newtable.UnitId,
CollCropCode = newtable.CollCropCode,
UnitName = newtable.UnitName,
ReportDate = newtable.ReportDate,
WelderNum = newtable.WelderNum,
TotalDineNum = newtable.TotalDineNum,
CompleteDineNum = newtable.CompleteDineNum,
TotalFilmNum = newtable.TotalFilmNum,
OKFilmNum = newtable.OKFilmNum,
State = newtable.State,
CreateDate = newtable.CreateDate,
CreateMan = newtable.CreateMan
};
db.HJGLData_HJGL.InsertOnSubmit(table);
db.SubmitChanges();
var table = new HJGLData_HJGL
{
Id = newtable.Id,
UnitId = newtable.UnitId,
CollCropCode = newtable.CollCropCode,
UnitName = newtable.UnitName,
ReportDate = newtable.ReportDate,
WelderNum = newtable.WelderNum,
TotalDineNum = newtable.TotalDineNum,
CompleteDineNum = newtable.CompleteDineNum,
TotalFilmNum = newtable.TotalFilmNum,
OKFilmNum = newtable.OKFilmNum,
State = newtable.State,
CreateDate = newtable.CreateDate,
CreateMan = newtable.CreateMan
};
db.HJGLData_HJGL.InsertOnSubmit(table);
db.SubmitChanges();
}
}
public static void DeleteHJGLData_HJGLById(string Id)
{
var db = Funs.DB;
var table = db.HJGLData_HJGL.FirstOrDefault(x => x.Id == Id);
if (table != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
db.HJGLData_HJGL.DeleteOnSubmit(table);
db.SubmitChanges();
var table = db.HJGLData_HJGL.FirstOrDefault(x => x.Id == Id);
if (table != null)
{
db.HJGLData_HJGL.DeleteOnSubmit(table);
db.SubmitChanges();
}
}
}
public static HJGLData_HJGL GetHJGLData_HJGLById(string Id)
@@ -151,12 +157,17 @@ namespace BLL
public static HJGLData GetTodayHJGLData_HJGL()
{
var q = GetTodayData();
var data = new HJGLData();
if (CommonService.GetIsThisUnit().CollCropCode == "91410200170644116B")
if (CommonService.GetIsThisUnit().CollCropCode== "91410200170644116B")
{
return GetELECLTodayHJGLData_HJGL();
return GetELECLTodayHJGLData_HJGL();
}
if (CommonService.GetIsThisUnit().CollCropCode == "914200001775697881")
{
return GetCNCEC_16TodayHJGLData_HJGL();
}
var q = GetTodayData();
if (q != null && q.State == Const.CNCEC_State_S)
data = StatisticalData();
else
@@ -174,23 +185,82 @@ namespace BLL
string token = Const.sysglyId;
string response = Funs.RequestPost(baseurl, token, "");
var json = JsonConvert.DeserializeObject(response) as JObject;
if (json != null && json["code"]?.ToString()=="1")
{
var str = json["data"]?.ToString();
if (str != null) data = JsonConvert.DeserializeObject<HJGLData>(str);
}
return data;
}
/// <summary>
/// 获取十六化建焊接数据
/// </summary>
/// <returns></returns>
public static HJGLData GetCNCEC_16TodayHJGLData_HJGL()
{
var data = new HJGLData();
string baseurl = "https://aq.cncec16.com.cn/hjglWebApi/api/CNCECServer/PostGetHJGLData";
string token = Const.sysglyId;
string response = Funs.RequestPost(baseurl, token, "");
if (string.IsNullOrEmpty(response))
{
try
{
baseurl = "http://192.168.1.8/hjglwebapi/api/CNCECServer/PostGetHJGLData";
response = Funs.RequestPost(baseurl, token, "");
}
catch (Exception e)
{
APICommonService.SaveSysHttpLog("GetCNCEC_16TodayHJGLData_HJGL", baseurl, e.ToString());
}
}
var json = JsonConvert.DeserializeObject(response) as JObject;
if (json != null && json["code"]?.ToString() == "1")
{
var str = json["data"]?.ToString();
if (str != null) data = JsonConvert.DeserializeObject<HJGLData>(str);
}
APICommonService.SaveSysHttpLog("GetCNCEC_16TodayHJGLData_HJGL", baseurl, response);
return data;
}
public static HJGLData_HJGL GetTodayData()
{
var q = (from x in Funs.DB.HJGLData_HJGL
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
select x).FirstOrDefault();
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
select x).FirstOrDefault();
return q;
}
public static HJGLData_HJGL GetSubUnitHjglDataByDate(string Unitid, DateTime? reportdate)
{
var result = new Model.HJGLData_HJGL();
if (reportdate == null)
{
return result;
}
var projectlist = BLL.ProjectService.GetProjectWorkList();
var baseUnit = UnitService.GetUnitByUnitId(Unitid);
var ProjectData = (from x in Funs.DB.Project_HJGLData_HJGL
where x.ReportDate == reportdate && projectlist.Select(e => e.ProjectId).Contains(x.ProjectId)
select x).ToList();
result = new HJGLData_HJGL
{
UnitId = Unitid,
CollCropCode = baseUnit.CollCropCode,
UnitName = baseUnit.UnitName,
ReportDate = DateTime.Now.Date,
WelderNum = ProjectData.Sum(x => x.WelderNum),
TotalDineNum = ProjectData.Sum(x => x.TotalDineNum),
CompleteDineNum = ProjectData.Sum(x => x.CompleteDineNum),
TotalFilmNum = ProjectData.Sum(x => x.TotalFilmNum),
OKFilmNum = ProjectData.Sum(x => x.OKFilmNum),
CreateMan = Const.sysglyId,
CreateDate = DateTime.Now
};
return result;
}
public static void UpdateTodyData_State()
{
var q = GetTodayData();
@@ -205,8 +275,8 @@ namespace BLL
{
var result = false;
var q = (from x in Funs.DB.HJGLData_HJGL
where x.ReportDate >= dateTime.Date && x.ReportDate < dateTime.Date.AddDays(1).Date
select x).ToList();
where x.ReportDate >= dateTime.Date && x.ReportDate < dateTime.Date.AddDays(1).Date
select x).ToList();
if (q != null && q.Count > 0) result = true;
return result;
}
@@ -219,8 +289,8 @@ namespace BLL
{
var result = false;
var q = (from x in Funs.DB.HJGLData_HJGL
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
select x).ToList();
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
select x).ToList();
if (q.Count > 0) result = true;
return result;
}
@@ -242,8 +312,8 @@ namespace BLL
if (thisUnit != null) thisUnitId = thisUnit.UnitId;
var baseUnit = UnitService.GetUnitByUnitId(thisUnitId);
var ProjectData = (from x in Funs.DB.Project_HJGLData_HJGL
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
select x).ToList();
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
select x).ToList();
Project_HJGLData_HJGLService.StatisticalAllProjectData();
Project_HJGLData_DefectService.StatisticalAllProjectData();
@@ -294,26 +364,29 @@ namespace BLL
}
public static void UpdateHJGLData_HJGL(HJGLData_HJGL newtable)
{
var db = Funs.DB;
var table = db.HJGLData_HJGL.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
table.Id = newtable.Id;
table.UnitId = newtable.UnitId;
table.CollCropCode = newtable.CollCropCode;
table.UnitName = newtable.UnitName;
table.ReportDate = newtable.ReportDate;
table.WelderNum = newtable.WelderNum;
table.TotalDineNum = newtable.TotalDineNum;
table.CompleteDineNum = newtable.CompleteDineNum;
table.TotalFilmNum = newtable.TotalFilmNum;
table.OKFilmNum = newtable.OKFilmNum;
table.State = newtable.State;
table.CreateMan = newtable.CreateMan;
table.CreateDate = newtable.CreateDate;
db.SubmitChanges();
}
var table = db.HJGLData_HJGL.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
{
table.Id = newtable.Id;
table.UnitId = newtable.UnitId;
table.CollCropCode = newtable.CollCropCode;
table.UnitName = newtable.UnitName;
table.ReportDate = newtable.ReportDate;
table.WelderNum = newtable.WelderNum;
table.TotalDineNum = newtable.TotalDineNum;
table.CompleteDineNum = newtable.CompleteDineNum;
table.TotalFilmNum = newtable.TotalFilmNum;
table.OKFilmNum = newtable.OKFilmNum;
table.State = newtable.State;
table.CreateMan = newtable.CreateMan;
table.CreateDate = newtable.CreateDate;
db.SubmitChanges();
}
}
}
}
}
File diff suppressed because it is too large Load Diff
@@ -31,7 +31,7 @@ namespace BLL
(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))
(string.IsNullOrEmpty(table.TypeName) || x.TypeName.Contains(table.TypeName))
select x
;
@@ -51,7 +51,7 @@ namespace BLL
{
return null;
}
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
return from x in q
select new
{
@@ -82,62 +82,67 @@ namespace BLL
}
public static void AddHSSEData_HiddenDangerDetail(Model.HSSEData_HiddenDangerDetail newtable)
{
Model.HSSEData_HiddenDangerDetail table = new Model.HSSEData_HiddenDangerDetail
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Id = newtable.Id,
UnitId = newtable.UnitId,
CollCropCode = newtable.CollCropCode,
UnitName = newtable.UnitName,
ReportDate = newtable.ReportDate,
TypeName = newtable.TypeName,
TotalNum = newtable.TotalNum,
NeedRectifyNum = newtable.NeedRectifyNum,
};
db.HSSEData_HiddenDangerDetail.InsertOnSubmit(table);
db.SubmitChanges();
Model.HSSEData_HiddenDangerDetail table = new Model.HSSEData_HiddenDangerDetail
{
Id = newtable.Id,
UnitId = newtable.UnitId,
CollCropCode = newtable.CollCropCode,
UnitName = newtable.UnitName,
ReportDate = newtable.ReportDate,
TypeName = newtable.TypeName,
TotalNum = newtable.TotalNum,
NeedRectifyNum = newtable.NeedRectifyNum,
};
db.HSSEData_HiddenDangerDetail.InsertOnSubmit(table);
db.SubmitChanges();
}
}
public static void UpdateHSSEData_HiddenDangerDetail(Model.HSSEData_HiddenDangerDetail newtable)
{
Model.HSSEData_HiddenDangerDetail table = db.HSSEData_HiddenDangerDetail.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
table.Id = newtable.Id;
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.HSSEData_HiddenDangerDetail table = db.HSSEData_HiddenDangerDetail.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
{
table.Id = newtable.Id;
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 DeleteHSSEData_HiddenDangerDetailById(string Id)
{
Model.HSSEData_HiddenDangerDetail table = db.HSSEData_HiddenDangerDetail.FirstOrDefault(x => x.Id == Id);
if (table != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
db.HSSEData_HiddenDangerDetail.DeleteOnSubmit(table);
db.SubmitChanges();
Model.HSSEData_HiddenDangerDetail table = db.HSSEData_HiddenDangerDetail.FirstOrDefault(x => x.Id == Id);
if (table != null)
{
db.HSSEData_HiddenDangerDetail.DeleteOnSubmit(table);
db.SubmitChanges();
}
}
}
public static void DeleteHSSEData_HiddenDangerDetailByDate(DateTime? reportDate)
{
var table = db.HSSEData_HiddenDangerDetail.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0);
if (table != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
db.HSSEData_HiddenDangerDetail.DeleteAllOnSubmit(table);
db.SubmitChanges();
var table = db.HSSEData_HiddenDangerDetail.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0);
if (table != null)
{
db.HSSEData_HiddenDangerDetail.DeleteAllOnSubmit(table);
db.SubmitChanges();
}
}
}
}
@@ -61,7 +61,7 @@ namespace BLL
(string.IsNullOrEmpty(table.ProjectId) || x.ProjectId.Contains(table.ProjectId)) &&
(string.IsNullOrEmpty(table.Value) || x.Value.Contains(table.Value)) &&
(string.IsNullOrEmpty(table.FactoryId) || x.FactoryId.Contains(table.FactoryId)) &&
(string.IsNullOrEmpty(table.ReceiveDate) || x.ReceiveDate.Contains(table.ReceiveDate))
(string.IsNullOrEmpty(table.ReceiveDate) || x.ReceiveDate.Contains(table.ReceiveDate))
select x
;
@@ -136,124 +136,134 @@ namespace BLL
public static void AddHazard_RealTimeDevice(Model.Hazard_RealTimeDevice newtable)
{
Model.Hazard_RealTimeDevice table = new Model.Hazard_RealTimeDevice
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
ID = newtable.ID,
UnitId = newtable.UnitId,
UnitName = newtable.UnitName,
HazardName = newtable.HazardName,
HazardLevel = newtable.HazardLevel,
DeviceCode = newtable.DeviceCode,
DeviceName = newtable.DeviceName,
DeviceType = newtable.DeviceType,
SphereType = newtable.SphereType,
TemperatureType = newtable.TemperatureType,
DesignTemperantureMax = newtable.DesignTemperantureMax,
DesignTemperantureMin = newtable.DesignTemperantureMin,
PressureType = newtable.PressureType,
DesignPressure = newtable.DesignPressure,
DesignPressureMax = newtable.DesignPressureMax,
Medium = newtable.Medium,
MediumForm = newtable.MediumForm,
MediumLevelMax = newtable.MediumLevelMax,
Reserves = newtable.Reserves,
StandardCode = newtable.StandardCode,
StandardName = newtable.StandardName,
StandardType = newtable.StandardType,
StandardDes = newtable.StandardDes,
MeasurementUnit = newtable.MeasurementUnit,
MeterMax = newtable.MeterMax,
MeterMin = newtable.MeterMin,
ThresholdLow1 = newtable.ThresholdLow1,
ThresholdLow2 = newtable.ThresholdLow2,
ThresholdMax1 = newtable.ThresholdMax1,
ThresholdMax2 = newtable.ThresholdMax2,
BitNum = newtable.BitNum,
DateTime = newtable.DateTime,
ProjectId = newtable.ProjectId,
Value = newtable.Value,
FactoryId = newtable.FactoryId,
ReportDate = newtable.ReportDate,
ReceiveDate = newtable.ReceiveDate,
};
db.Hazard_RealTimeDevice.InsertOnSubmit(table);
db.SubmitChanges();
Model.Hazard_RealTimeDevice table = new Model.Hazard_RealTimeDevice
{
ID = newtable.ID,
UnitId = newtable.UnitId,
UnitName = newtable.UnitName,
HazardName = newtable.HazardName,
HazardLevel = newtable.HazardLevel,
DeviceCode = newtable.DeviceCode,
DeviceName = newtable.DeviceName,
DeviceType = newtable.DeviceType,
SphereType = newtable.SphereType,
TemperatureType = newtable.TemperatureType,
DesignTemperantureMax = newtable.DesignTemperantureMax,
DesignTemperantureMin = newtable.DesignTemperantureMin,
PressureType = newtable.PressureType,
DesignPressure = newtable.DesignPressure,
DesignPressureMax = newtable.DesignPressureMax,
Medium = newtable.Medium,
MediumForm = newtable.MediumForm,
MediumLevelMax = newtable.MediumLevelMax,
Reserves = newtable.Reserves,
StandardCode = newtable.StandardCode,
StandardName = newtable.StandardName,
StandardType = newtable.StandardType,
StandardDes = newtable.StandardDes,
MeasurementUnit = newtable.MeasurementUnit,
MeterMax = newtable.MeterMax,
MeterMin = newtable.MeterMin,
ThresholdLow1 = newtable.ThresholdLow1,
ThresholdLow2 = newtable.ThresholdLow2,
ThresholdMax1 = newtable.ThresholdMax1,
ThresholdMax2 = newtable.ThresholdMax2,
BitNum = newtable.BitNum,
DateTime = newtable.DateTime,
ProjectId = newtable.ProjectId,
Value = newtable.Value,
FactoryId = newtable.FactoryId,
ReportDate = newtable.ReportDate,
ReceiveDate = newtable.ReceiveDate,
};
db.Hazard_RealTimeDevice.InsertOnSubmit(table);
db.SubmitChanges();
}
}
public static void AddBulkHazard_RealTimeDevice(List<Model.Hazard_RealTimeDevice> newtables)
{
db.Hazard_RealTimeDevice.InsertAllOnSubmit(newtables);
db.SubmitChanges();
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
db.Hazard_RealTimeDevice.InsertAllOnSubmit(newtables);
db.SubmitChanges();
}
}
public static void UpdateHazard_RealTimeDevice(Model.Hazard_RealTimeDevice newtable)
{
Model.Hazard_RealTimeDevice table = db.Hazard_RealTimeDevice.FirstOrDefault(x => x.ID == newtable.ID);
if (table != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
table.ID = newtable.ID;
table.UnitId = newtable.UnitId;
table.UnitName = newtable.UnitName;
table.HazardName = newtable.HazardName;
table.HazardLevel = newtable.HazardLevel;
table.DeviceCode = newtable.DeviceCode;
table.DeviceName = newtable.DeviceName;
table.DeviceType = newtable.DeviceType;
table.SphereType = newtable.SphereType;
table.TemperatureType = newtable.TemperatureType;
table.DesignTemperantureMax = newtable.DesignTemperantureMax;
table.DesignTemperantureMin = newtable.DesignTemperantureMin;
table.PressureType = newtable.PressureType;
table.DesignPressure = newtable.DesignPressure;
table.DesignPressureMax = newtable.DesignPressureMax;
table.Medium = newtable.Medium;
table.MediumForm = newtable.MediumForm;
table.MediumLevelMax = newtable.MediumLevelMax;
table.Reserves = newtable.Reserves;
table.StandardCode = newtable.StandardCode;
table.StandardName = newtable.StandardName;
table.StandardType = newtable.StandardType;
table.StandardDes = newtable.StandardDes;
table.MeasurementUnit = newtable.MeasurementUnit;
table.MeterMax = newtable.MeterMax;
table.MeterMin = newtable.MeterMin;
table.ThresholdLow1 = newtable.ThresholdLow1;
table.ThresholdLow2 = newtable.ThresholdLow2;
table.ThresholdMax1 = newtable.ThresholdMax1;
table.ThresholdMax2 = newtable.ThresholdMax2;
table.BitNum = newtable.BitNum;
table.DateTime = newtable.DateTime;
table.ProjectId = newtable.ProjectId;
table.Value = newtable.Value;
table.FactoryId = newtable.FactoryId;
table.ReportDate = newtable.ReportDate;
table.ReceiveDate = newtable.ReceiveDate;
db.SubmitChanges();
Model.Hazard_RealTimeDevice table = db.Hazard_RealTimeDevice.FirstOrDefault(x => x.ID == newtable.ID);
if (table != null)
{
table.ID = newtable.ID;
table.UnitId = newtable.UnitId;
table.UnitName = newtable.UnitName;
table.HazardName = newtable.HazardName;
table.HazardLevel = newtable.HazardLevel;
table.DeviceCode = newtable.DeviceCode;
table.DeviceName = newtable.DeviceName;
table.DeviceType = newtable.DeviceType;
table.SphereType = newtable.SphereType;
table.TemperatureType = newtable.TemperatureType;
table.DesignTemperantureMax = newtable.DesignTemperantureMax;
table.DesignTemperantureMin = newtable.DesignTemperantureMin;
table.PressureType = newtable.PressureType;
table.DesignPressure = newtable.DesignPressure;
table.DesignPressureMax = newtable.DesignPressureMax;
table.Medium = newtable.Medium;
table.MediumForm = newtable.MediumForm;
table.MediumLevelMax = newtable.MediumLevelMax;
table.Reserves = newtable.Reserves;
table.StandardCode = newtable.StandardCode;
table.StandardName = newtable.StandardName;
table.StandardType = newtable.StandardType;
table.StandardDes = newtable.StandardDes;
table.MeasurementUnit = newtable.MeasurementUnit;
table.MeterMax = newtable.MeterMax;
table.MeterMin = newtable.MeterMin;
table.ThresholdLow1 = newtable.ThresholdLow1;
table.ThresholdLow2 = newtable.ThresholdLow2;
table.ThresholdMax1 = newtable.ThresholdMax1;
table.ThresholdMax2 = newtable.ThresholdMax2;
table.BitNum = newtable.BitNum;
table.DateTime = newtable.DateTime;
table.ProjectId = newtable.ProjectId;
table.Value = newtable.Value;
table.FactoryId = newtable.FactoryId;
table.ReportDate = newtable.ReportDate;
table.ReceiveDate = newtable.ReceiveDate;
db.SubmitChanges();
}
}
}
public static void DeleteHazard_RealTimeDeviceById(string ID)
{
Model.Hazard_RealTimeDevice table = db.Hazard_RealTimeDevice.FirstOrDefault(x => x.ID == ID);
if (table != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
db.Hazard_RealTimeDevice.DeleteOnSubmit(table);
db.SubmitChanges();
Model.Hazard_RealTimeDevice table = db.Hazard_RealTimeDevice.FirstOrDefault(x => x.ID == ID);
if (table != null)
{
db.Hazard_RealTimeDevice.DeleteOnSubmit(table);
db.SubmitChanges();
}
}
}
public static void DeleteALLHazard_RealTimeDevice()
{
if (db.Hazard_RealTimeDevice != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
db.Hazard_RealTimeDevice.DeleteAllOnSubmit(db.Hazard_RealTimeDevice);
db.SubmitChanges();
if (db.Hazard_RealTimeDevice != null)
{
db.Hazard_RealTimeDevice.DeleteAllOnSubmit(db.Hazard_RealTimeDevice);
db.SubmitChanges();
}
}
}
public static List<Model.Hazard_RealTimeDevice> GetHazard_RealTimeDeviceByDate(DateTime? reportDate)
@@ -265,14 +275,15 @@ namespace BLL
}
public static void DeleteHazard_RealTimeDeviceByDate(DateTime? reportDate)
{
var table = db.Hazard_RealTimeDevice.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0);
if (table != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
db.Hazard_RealTimeDevice.DeleteAllOnSubmit(table);
db.SubmitChanges();
var table = db.Hazard_RealTimeDevice.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0);
if (table != null)
{
db.Hazard_RealTimeDevice.DeleteAllOnSubmit(table);
db.SubmitChanges();
}
}
}
}
}
+32
View File
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
public class LotAPIService
{
/// <summary>
/// 保存环境监测
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static string saveEnvironmentCheck(Model.EnvironmentalCheckInput input)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
//使用Emitmapper 将input 映射到实体类db.ZJ_EnvironmentCheck
var entity = EmitMapper.ObjectMapperManager.DefaultInstance.GetMapper<Model.EnvironmentalCheckInput, Model.EnvironmentalCheck>().Map(input);
entity.Id = Guid.NewGuid().ToString();
entity.CreateTime = DateTime.Now;
db.EnvironmentalCheck.InsertOnSubmit(entity);
db.SubmitChanges();
return entity.Id;
}
}
}
}
+360
View File
@@ -0,0 +1,360 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace BLL {
public class MainSevice
{
/// <summary>
/// 在建项目集合
/// </summary>
private List<string> _beUnderConstructionList;
private HSSEData_HSSE _hsseData;
private string _unitId;
private int _unitType;
public MainSevice(string userid)
{
var userModel = Person_PersonsService.GetPerson_PersonsById(userid);
int unitType = CommonService.GetUnitTypeByUserId(userid);
var projectList = ProjectService.GetProjectWorkList().Select(x => new { x.ProjectId, x.UnitId }).ToList();
_unitId = userModel.UnitId;
_unitType = unitType;
if (unitType == 0)
{
_beUnderConstructionList = projectList.Select(x => x.ProjectId).ToList();
_unitId = BLL.Const.UnitId_SEDIN;
}
else if (unitType == 1)
{
_beUnderConstructionList = projectList.Where(x => x.UnitId == userModel.UnitId).Select(x => x.ProjectId).ToList();
}
else if (unitType == 2)
{
_beUnderConstructionList = new List<string>() { "0" };
}
}
public async Task<HSSEData_HSSE> GetHsseDataAsync()
{
try
{
// 并行执行异步方法
var totalEnergyConsumptionTask = ChemicalReportItemService.GetLatstTimeTotalEnergyConsumption();
var incomeComprehensiveEnergyConsumptionTask = ChemicalReportItemService.GetLatstTimeIncomeComprehensiveEnergyConsumption();
var newWaterConsumptionTask = ChemicalReportItemService.GetLatstTimeNewWaterConsumption();
var securityRiskOutputListTask = HSSEData_HSSEService.GetSecurityRiskOutputsAsync()
.ContinueWith(t => t.Result.Where(x => _beUnderConstructionList.Contains(x.ProjectId)));
var largeEngineeringOutputsTask = HSSEData_HSSEService.GetLargeEngineeringOutputsAsync()
.ContinueWith(t => t.Result.Where(x => _beUnderConstructionList.Contains(x.ProjectId)));
var safetyInjectionEngineerTask = HSSEData_HSSEService.GetSafetyInjectionEngineerAsync();
var certificateATask = HSSEData_HSSEService.GetCertificateAAsync();
var certificateBTask = HSSEData_HSSEService.GetCertificateBAsync();
var certificateCTask = HSSEData_HSSEService.GetCertificateCAsync();
var beUnderConstructionTask = HSSEData_HSSEService.GetBeUnderConstructionAsync();
var shutdownTask = HSSEData_HSSEService.GetShutdownAsync();
var joinConstructionPersonTask = HSSEData_HSSEService.GetJoinConstructionPersonAsync();
var majorProjectsUnderConstructionTask = HSSEData_HSSEService.GetMajorProjectsUnderConstructionAsync();
var totalWorkingHourTask = HSSEData_HSSEService.GetTotalWorkingHourAsync();
var lostWorkingHourTask = HSSEData_HSSEService.GetLostWorkingHourAsync();
var safeWorkingHourTask = HSSEData_HSSEService.GetSafeWorkingHourAsync();
var safeTrainTask = HSSEData_HSSEService.GetSafeTrainAsync();
var specialTrainTask = HSSEData_HSSEService.GetSpecialTrainAsync();
var specialOperationTrainTask = HSSEData_HSSEService.GetSpecialOperationTrainAsync();
var headOfficeInspectorGeneralTask = HSSEData_HSSEService.GetHeadOfficeInspectorGeneralAsync();
var headOfficeFullTimeTask = HSSEData_HSSEService.GetHeadOfficeFullTimeAsync();
var branchInspectorGeneralTask = HSSEData_HSSEService.GetBranchInspectorGeneralAsync();
var branchFullTimeTask = HSSEData_HSSEService.GetBranchFullTimeAsync();
var projectInspectorGeneralTask = HSSEData_HSSEService.GetProjectInspectorGeneralAsync();
var projectFullTimeTask = HSSEData_HSSEService.GetProjectFullTimeAsync();
var projectSafetyMonitorTask = HSSEData_HSSEService.GetProjectSafetyMonitorAsync();
var safetyCommitteeMeetingTask = HSSEData_HSSEService.GetSafetyCommitteeMeetingAsync();
var enterpriseTopicsMeetingTask = HSSEData_HSSEService.GetEnterpriseTopicsMeetingAsync();
var projectSafetyLeadingGroupMeetingTask = HSSEData_HSSEService.GetProjectSafetyLeadingGroupMeetingAsync();
var projectSafetyMeetingTask = HSSEData_HSSEService.GetProjectSafetyMeetingAsync();
var companyLeadShiftCheckTask = HSSEData_HSSEService.GetCompanyLeadShiftCheckAsync();
var companyComprehensiveCheckTask = HSSEData_HSSEService.GetCompanyComprehensiveCheckAsync();
var companySpecialCheckTask = HSSEData_HSSEService.GetCompanySpecialCheckAsync();
var projectLeadShiftCheckTask = HSSEData_HSSEService.GetProjectLeadShiftCheckAsync();
var projectSpecialCheckTask = HSSEData_HSSEService.GetProjectSpecialCheckAsync();
var projectMajorCheckTask = HSSEData_HSSEService.GetProjectMajorCheckAsync();
var nearMissTask = HSSEData_HSSEService.GetNearMissAsync();
var recordableEventTask = HSSEData_HSSEService.GetRecordableEventAsync();
var generalAccidentTask = HSSEData_HSSEService.GetGeneralAccidentAsync();
var majorAccidentTask = HSSEData_HSSEService.GetMajorAccidentAsync();
var seriousAccidentTask = HSSEData_HSSEService.GetSeriousAccidentAsync();
var specialSeriousAccidentTask = HSSEData_HSSEService.GetSpecialSeriousAccidentAsync();
var companyComprehensivePlanTask = HSSEData_HSSEService.GetCompanyComprehensivePlanAsync();
var companySpecialPlanTask = HSSEData_HSSEService.GetCompanySpecialPlanAsync();
var companyOnSiteDisposalPlanTask = HSSEData_HSSEService.GetCompanyOnSiteDisposalPlanAsync();
var companyDrillTask = HSSEData_HSSEService.GetCompanyDrillAsync();
var projectComprehensivePlanTask = HSSEData_HSSEService.GetProjectComprehensivePlanAsync();
var projectSpecialPlanTask = HSSEData_HSSEService.GetProjectSpecialPlanAsync();
var projectOnSiteDisposalPlanTask = HSSEData_HSSEService.GetProjectOnSiteDisposalPlanAsync();
var projectDrillTask = HSSEData_HSSEService.GetProjectDrillAsync();
var costExtractTask = HSSEData_HSSEService.GetCostExtractAsync();
var costUseTask = HSSEData_HSSEService.GetCostUseAsync();
var useEquipmentTask = HSSEData_HSSEService.GetUseEquipmentAsync();
var specialEquipmentTask = HSSEData_HSSEService.GetSpecialEquipmentAsync();
var licensesTask = HSSEData_HSSEService.GetLicensesAsync();
var licensesCloseTask = HSSEData_HSSEService.GetLicensesCloseAsync();
var generalHiddenRectificationOutputsTask = HSSEData_HSSEService.GetGeneralHiddenRectificationOutputsAsync();
var majorHiddenRectificationOutputsTask = HSSEData_HSSEService.GetMajorHiddenRectificationOutputsAsync();
// 等待所有异步方法执行完成
await Task.WhenAll(
securityRiskOutputListTask,
largeEngineeringOutputsTask,
safetyInjectionEngineerTask,
certificateATask,
certificateBTask,
certificateCTask,
beUnderConstructionTask,
shutdownTask,
joinConstructionPersonTask,
majorProjectsUnderConstructionTask,
totalWorkingHourTask,
lostWorkingHourTask,
safeWorkingHourTask,
safeTrainTask,
specialTrainTask,
specialOperationTrainTask,
headOfficeInspectorGeneralTask,
headOfficeFullTimeTask,
branchInspectorGeneralTask,
branchFullTimeTask,
projectInspectorGeneralTask,
projectFullTimeTask,
projectSafetyMonitorTask,
safetyCommitteeMeetingTask,
enterpriseTopicsMeetingTask,
projectSafetyLeadingGroupMeetingTask,
projectSafetyMeetingTask,
companyLeadShiftCheckTask,
companyComprehensiveCheckTask,
companySpecialCheckTask,
projectLeadShiftCheckTask,
projectSpecialCheckTask,
projectMajorCheckTask,
nearMissTask,
recordableEventTask,
generalAccidentTask,
majorAccidentTask,
seriousAccidentTask,
specialSeriousAccidentTask,
companyComprehensivePlanTask,
companySpecialPlanTask,
companyOnSiteDisposalPlanTask,
companyDrillTask,
projectComprehensivePlanTask,
projectSpecialPlanTask,
projectOnSiteDisposalPlanTask,
projectDrillTask,
costExtractTask,
costUseTask,
useEquipmentTask,
specialEquipmentTask,
licensesTask,
licensesCloseTask,
generalHiddenRectificationOutputsTask,
majorHiddenRectificationOutputsTask
);
// 统一获取异步方法的返回值
var totalEnergyConsumption = totalEnergyConsumptionTask;
var incomeComprehensiveEnergyConsumption = incomeComprehensiveEnergyConsumptionTask;
var newWaterConsumption = newWaterConsumptionTask;
var safetyInjectionEngineerList = await safetyInjectionEngineerTask;
var certificateAList = await certificateATask;
var certificateBList = await certificateBTask;
var certificateCList = await certificateCTask;
var beUnderConstructionList = await beUnderConstructionTask;
var shutdownList = await shutdownTask;
var joinConstructionPersonList = await joinConstructionPersonTask;
var majorProjectsUnderConstructionList = await majorProjectsUnderConstructionTask;
var totalWorkingHour = await totalWorkingHourTask;
var lostWorkingHour = await lostWorkingHourTask;
var safeWorkingHour = await safeWorkingHourTask;
var safeTrainList = await safeTrainTask;
var specialTrainList = await specialTrainTask;
var specialOperationTrainList = await specialOperationTrainTask;
var headOfficeInspectorGeneralList = await headOfficeInspectorGeneralTask;
var headOfficeFullTimeList = await headOfficeFullTimeTask;
var branchInspectorGeneralList = await branchInspectorGeneralTask;
var branchFullTimeList = await branchFullTimeTask;
var projectInspectorGeneralList = await projectInspectorGeneralTask;
var projectFullTimeList = await projectFullTimeTask;
var projectSafetyMonitorList = await projectSafetyMonitorTask;
var safetyCommitteeMeetingList = await safetyCommitteeMeetingTask;
var enterpriseTopicsMeetingList = await enterpriseTopicsMeetingTask;
var projectSafetyLeadingGroupMeetingList = await projectSafetyLeadingGroupMeetingTask;
var projectSafetyMeetingList = await projectSafetyMeetingTask;
var companyLeadShiftCheckList = await companyLeadShiftCheckTask;
var companyComprehensiveCheckList = await companyComprehensiveCheckTask;
var companySpecialCheckList = await companySpecialCheckTask;
var projectLeadShiftCheckList = await projectLeadShiftCheckTask;
var projectSpecialCheckList = await projectSpecialCheckTask;
var projectMajorCheckList = await projectMajorCheckTask;
var nearMissList = await nearMissTask;
var recordableEventList = await recordableEventTask;
var generalAccidentList = await generalAccidentTask;
var majorAccidentList = await majorAccidentTask;
var seriousAccidentList = await seriousAccidentTask;
var specialSeriousAccidentList = await specialSeriousAccidentTask;
var companyComprehensivePlanList = await companyComprehensivePlanTask;
var companySpecialPlanList = await companySpecialPlanTask;
var companyOnSiteDisposalPlanList = await companyOnSiteDisposalPlanTask;
var companyDrillList = await companyDrillTask;
var projectComprehensivePlanList = await projectComprehensivePlanTask;
var projectSpecialPlanList = await projectSpecialPlanTask;
var projectOnSiteDisposalPlanList = await projectOnSiteDisposalPlanTask;
var projectDrillList = await projectDrillTask;
var costExtractList = await costExtractTask;
var costUseList = await costUseTask;
var useEquipmentList = await useEquipmentTask;
var specialEquipmentList = await specialEquipmentTask;
var licensesList = await licensesTask;
var licensesCloseList = await licensesCloseTask;
var generalHiddenRectificationOutputsList = await generalHiddenRectificationOutputsTask;
var majorHiddenRectificationOutputsList = await majorHiddenRectificationOutputsTask;
// 构造结果对象
var table = new HSSEData_HSSE
{
JoinConstructionPersonNum = joinConstructionPersonList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
MajorProjectsUnderConstructionNum = majorProjectsUnderConstructionList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
TotalWorkingHour = totalWorkingHour,
LostWorkingHour = lostWorkingHour,
SafeWorkingHour = safeWorkingHour,
SafeTrainNum = safeTrainList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.TrainPersonNum),
SpecialTrainNum = specialTrainList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.TrainPersonNum),
SpecialOperationTrainNum = specialOperationTrainList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.TrainPersonNum),
EnvironmentalTrainNum = 0,
TotalEnergyConsumption = totalEnergyConsumption,
IncomeComprehensiveEnergyConsumption = incomeComprehensiveEnergyConsumption,
NewWaterConsumption = newWaterConsumption,
HeadOfficeInspectorGeneralNum = headOfficeInspectorGeneralList.Count(),
HeadOfficeFullTimeNum = headOfficeFullTimeList.Count,
BranchInspectorGeneralNum = branchInspectorGeneralList.Count,
BranchFullTimeNum = branchFullTimeList.Count,
ProjectInspectorGeneralNum = projectInspectorGeneralList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
ProjectFullTimeNum = projectFullTimeList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
ProjectSafetyMonitorNum = projectSafetyMonitorList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
ProjectSafetyLeadingGroupMeetingNum = projectSafetyLeadingGroupMeetingList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
ProjectSafetyMeetingNum = projectSafetyMeetingList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
CompanyLeadShiftCheckNum = companyLeadShiftCheckList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
CompanyComprehensiveCheckNum = companyComprehensiveCheckList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
CompanySpecialCheckNum = companySpecialCheckList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
ProjectLeadShiftCheckNum = projectLeadShiftCheckList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
ProjectSpecialCheckNum = projectSpecialCheckList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
ProjectMajorCheckNum = projectMajorCheckList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
NearMissNum = nearMissList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
RecordableEventNum = recordableEventList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
GeneralAccidentNum = generalAccidentList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
MajorAccidentNum = majorAccidentList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
SeriousAccidentNum = seriousAccidentList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
SpecialSeriousAccidentNum = specialSeriousAccidentList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
CompanyComprehensivePlanNum = companyComprehensivePlanList.Count(x => x.UnitId == _unitId),
CompanySpecialPlanNum = companySpecialPlanList.Count(x => x.UnitId == _unitId),
CompanyOnSiteDisposalPlan = companyOnSiteDisposalPlanList.Count(x => x.UnitId == _unitId),
CompanyDrillNum = companyDrillList.Count(x => x.UnitId.Contains(_unitId)),
ProjectComprehensivePlanNum = projectComprehensivePlanList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
ProjectSpecialPlanNum = projectSpecialPlanList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
ProjectOnSiteDisposalPlan = projectOnSiteDisposalPlanList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
ProjectDrillNum = projectDrillList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
CostExtract = Convert.ToInt32(costExtractList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.SUMCost)),
CostUse = Convert.ToInt32(costUseList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.SUMCost)),
UseEquipmentNum = useEquipmentList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
SpecialEquipmentNum = specialEquipmentList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
LicensesNum = licensesList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
LicensesCloseNum = licensesCloseList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)),
GeneralClosedNum = generalHiddenRectificationOutputsList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.RecNum),
GeneralNotClosedNum = generalHiddenRectificationOutputsList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.NoRecNum),
MajorClosedNum = majorHiddenRectificationOutputsList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.RecNum),
MajorNotClosedNum = majorHiddenRectificationOutputsList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.NoRecNum),
LowRiskNum = securityRiskOutputListTask.Result.Sum(x => x.LowRiskNum),
GeneralRiskNum = securityRiskOutputListTask.Result.Sum(x => x.GeneralRiskNum),
MediumRiskNum = securityRiskOutputListTask.Result.Sum(x => x.MediumRiskNum),
HighRiskNum = securityRiskOutputListTask.Result.Sum(x => x.HighRiskNum),
CompletedNum = largeEngineeringOutputsTask.Result.Sum(x => x.CompletedNum),
TrainPersonNum = largeEngineeringOutputsTask.Result.Sum(x => x.TrainPersonNum),
ConstructionNum = largeEngineeringOutputsTask.Result.Sum(x => x.ConstructionNum),
FinishedNum = largeEngineeringOutputsTask.Result.Sum(x => x.FinishedNum),
SuperCompletedNum = largeEngineeringOutputsTask.Result.Sum(x => x.SuperCompletedNum),
SuperTrainPersonNum = largeEngineeringOutputsTask.Result.Sum(x => x.SuperTrainPersonNum),
SuperConstructionNum = largeEngineeringOutputsTask.Result.Sum(x => x.SuperConstructionNum)
};
if (_unitType == 0)
{
table.BeUnderConstructionNum = beUnderConstructionList.Count();
table.ShutdownNum = shutdownList.Count();
table.SafetyInjectionEngineer = safetyInjectionEngineerList.Count();
table.EnterpriseTopicsMeetingNum = enterpriseTopicsMeetingList.Count();
table.CertificateANum = certificateAList.Count();
table.CertificateBNum = certificateBList.Count();
table.CertificateCNum = certificateCList.Count();
table.SafetyCommitteeMeetingNum = safetyCommitteeMeetingList.Count();
}
else if (_unitType == 1)
{
table.BeUnderConstructionNum = beUnderConstructionList.Count(x => x.UnitId == _unitId);
table.ShutdownNum = shutdownList.Count(x => x.UnitId == _unitId);
table.SafetyCommitteeMeetingNum = safetyCommitteeMeetingList.Count(x => x.UnitId == _unitId);
table.SafetyInjectionEngineer = safetyInjectionEngineerList.Count(x => _beUnderConstructionList.Contains(x.ProjectId) || x.UnitId == _unitId);
table.EnterpriseTopicsMeetingNum = safetyInjectionEngineerList.Count(x => _beUnderConstructionList.Contains(x.ProjectId) || x.UnitId == _unitId);
table.CertificateANum = certificateAList.Count(x => _beUnderConstructionList.Contains(x.ProjectId) || x.UnitId == _unitId);
table.CertificateBNum = certificateBList.Count(x => _beUnderConstructionList.Contains(x.ProjectId) || x.UnitId == _unitId);
table.CertificateCNum = certificateCList.Count(x => _beUnderConstructionList.Contains(x.ProjectId) || x.UnitId == _unitId);
}
_hsseData = table;
return _hsseData;
}
catch (Exception ex)
{
throw;
}
}
public List<HSSEDataHiddenDangerDetailItem> GetDataHiddenDangerDetailItems()
{
var db = Funs.DB;
var list = from x in db.HSSE_Hazard_HazardRegister
where _beUnderConstructionList.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 = _unitId,
ProjectId = g.Key.ProjectId,
TypeName = g.Key.RegisterTypesName,
TotalNum = g.Count(),
NeedRectifyNum = g.Count(x => x.States == "1"),
}).ToList();
var result = (from x in data
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 result;
}
} }
@@ -156,7 +156,7 @@ namespace BLL
/// <param name="newtable"></param>
public static void AddProject_CQMSData_CQMS(Model.Project_CQMSData_CQMS newtable)
{
using (var db = new SGGLDB(Funs.ConnString))
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Model.Project_CQMSData_CQMS table = new Model.Project_CQMSData_CQMS
{
@@ -200,7 +200,6 @@ namespace BLL
db.SubmitChanges();
}
}
/// <summary>
/// 修改
@@ -208,8 +207,7 @@ namespace BLL
/// <param name="newtable"></param>
public static void UpdateProject_CQMSData_CQMS(Model.Project_CQMSData_CQMS newtable)
{
using (var db = new SGGLDB(Funs.ConnString))
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Model.Project_CQMSData_CQMS table = db.Project_CQMSData_CQMS.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
@@ -252,7 +250,6 @@ namespace BLL
db.SubmitChanges();
}
}
}
/// <summary>
@@ -261,8 +258,7 @@ namespace BLL
/// <param name="Id"></param>
public static void DeleteProject_CQMSData_CQMSById(string Id)
{
using (var db = new SGGLDB(Funs.ConnString))
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Model.Project_CQMSData_CQMS table = db.Project_CQMSData_CQMS.FirstOrDefault(x => x.Id == Id);
if (table != null)
@@ -271,7 +267,6 @@ namespace BLL
db.SubmitChanges();
}
}
}
/// <summary>
@@ -321,7 +316,7 @@ namespace BLL
}
public static void StatisticalAllProjectData()
{
var projectlist = ProjectService.GetCNCECShowProjectList();
var projectlist = ProjectService.GetProjectWorkList();
foreach (var item in projectlist)
{
StatisticalData(item.ProjectId, CQMSDateType.All);
@@ -490,7 +485,7 @@ namespace BLL
{
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.States=="1"
where x.ProjectId == projectid && y.IsCQMS == true && x.States == "1"
select x).Count();
return result;
}
@@ -703,8 +698,8 @@ namespace BLL
public static int GetSingleProjectNum(string projectid)
{
int result = (from x in Funs.DB.WBS_UnitWork
where x.ProjectId == projectid
select x).Count();
where x.ProjectId == projectid
select x).Count();
return result;
}
/// <summary>
@@ -753,5 +748,34 @@ namespace BLL
}
#region
/// <summary>
/// 推送项目质量数据
/// </summary>
/// <returns></returns>
public static ReturnData PushProjectCQMSData()
{
var items = (from x in db.Project_CQMSData_CQMS
where x.ReportDate == DateTime.Now.Date
select x).ToList();
Model.ReturnData responeData = new Model.ReturnData();
if (items.Count() > 0)
{
var thisUnit = CommonService.GetIsThisUnit();
var newItem = new { CollCropCode = thisUnit.CollCropCode, Items = items };
var str = JsonConvert.SerializeObject(newItem);
var baseurl = "/api/CQMSData/SaveProjectCQMSData";
responeData = ServerService.PushCNCEC(str, baseurl);
}
else
{
responeData.code = 0;
responeData.message = "当前没有项目质量数据";
}
return responeData;
}
#endregion
}
}
@@ -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;
}
}
}
@@ -114,7 +114,7 @@ namespace BLL
}
public static void AddProject_HJGLData_HJGL(Model.Project_HJGLData_HJGL newtable)
{
using (var db = new SGGLDB(Funs.ConnString))
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Model.Project_HJGLData_HJGL table = new Model.Project_HJGLData_HJGL
{
@@ -133,11 +133,10 @@ namespace BLL
db.Project_HJGLData_HJGL.InsertOnSubmit(table);
db.SubmitChanges();
}
}
public static void UpdateProject_HJGLData_HJGL(Model.Project_HJGLData_HJGL newtable)
{
using (var db = new SGGLDB(Funs.ConnString))
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Model.Project_HJGLData_HJGL table = db.Project_HJGLData_HJGL.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
@@ -156,11 +155,10 @@ namespace BLL
db.SubmitChanges();
}
}
}
public static void DeleteProject_HJGLData_HJGLById(string Id)
{
using (var db = new SGGLDB(Funs.ConnString))
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Model.Project_HJGLData_HJGL table = db.Project_HJGLData_HJGL.FirstOrDefault(x => x.Id == Id);
if (table != null)
@@ -169,8 +167,6 @@ namespace BLL
db.SubmitChanges();
}
}
}
/// <summary>
/// 判断该项目的该日期是否统计数据
@@ -223,7 +219,7 @@ namespace BLL
/// </summary>
public static void StatisticalAllProjectData()
{
var projectlist = ProjectService.GetCNCECShowProjectList();
var projectlist = ProjectService.GetProjectWorkList();
foreach (var item in projectlist)
{
StatisticalData(item.ProjectId, HJGLDateType.All);
@@ -311,7 +307,7 @@ namespace BLL
{
int result = Convert.ToInt32((from x in Funs.DB.HJGL_WeldJoint
where x.ProjectId == projectid
select x.Size).ToList().Sum(x=>x.Value));
select x.Size).ToList().Sum(x => x.Value));
return result;
}
/// <summary>
@@ -333,7 +329,7 @@ namespace BLL
{
int result = (from x in Funs.DB.HJGL_Batch_NDEItem
join y in Funs.DB.HJGL_Batch_NDE on x.NDEID equals y.NDEID
where y.ProjectId == projectid
where y.ProjectId == projectid
select x.TotalFilm).ToList().Sum(x => x.Value);
return result;
}
@@ -345,10 +341,43 @@ namespace BLL
{
int result = (from x in Funs.DB.HJGL_Batch_NDEItem
join y in Funs.DB.HJGL_Batch_NDE on x.NDEID equals y.NDEID
where y.ProjectId == projectid
where y.ProjectId == projectid
select x.PassFilm).ToList().Sum(x => x.Value);
return result;
}
#region
/// <summary>
/// 推送项目焊接数据
/// </summary>
/// <returns></returns>
public static ReturnData PushProjectHJGLData()
{
var items = (from x in db.Project_HJGLData_HJGL
where x.ReportDate == DateTime.Now.Date
select x).ToList();
var defectItems = (from x in db.Project_HJGLData_Defect
where x.ReportDate == DateTime.Now.Date
select x).ToList();
Model.ReturnData responeData = new Model.ReturnData();
if (items.Count() > 0 || defectItems.Count() > 0)
{
var thisUnit = CommonService.GetIsThisUnit();
var newItem = new { CollCropCode = thisUnit.CollCropCode, Items = items, DefectItems = defectItems };
var str = JsonConvert.SerializeObject(newItem);
var baseurl = "/api/HJGLData/SaveProjectHJGLData";
responeData = ServerService.PushCNCEC(str, baseurl);
}
else
{
responeData.code = 0;
responeData.message = "当前没有项目焊接数据";
}
return responeData;
}
#endregion
}
}
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using FineUIPro;
using Model;
using Newtonsoft.Json;
namespace BLL
{
@@ -320,6 +321,19 @@ namespace BLL
}
}
public static void DeleteProject_HSSEData_HSSEByDate(DateTime? reportDate)
{
using (var db = new SGGLDB(Funs.ConnString))
{
var table = db.Project_HSSEData_HSSE.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0);
if (table != null)
{
db.Project_HSSEData_HSSE.DeleteAllOnSubmit(table);
db.SubmitChanges();
}
}
}
/// <summary>
/// 判断该项目的该日期是否统计数据
/// </summary>
@@ -371,7 +385,7 @@ namespace BLL
/// </summary>
public static void StatisticalAllProjectData()
{
var projectlist = ProjectService.GetCNCECShowProjectList();
var projectlist = ProjectService.GetProjectWorkList();
foreach (var item in projectlist) StatisticalData(item.ProjectId, HSSEDateType.All);
}
@@ -606,7 +620,7 @@ namespace BLL
public static int GetJoinConstructionPersonNum(string projectid)
{
var result = (from x in Funs.DB.SitePerson_Person
where x.ProjectId == projectid && x.States=="1"
where x.ProjectId == projectid && x.States == "1"
select x).Count();
return result;
}
@@ -629,11 +643,10 @@ namespace BLL
/// <returns></returns>
public static int GetTotalWorkingHour(string projectid)
{
var result = (from x in Funs.DB.SeDin_MonthReport2
join y in Funs.DB.SeDin_MonthReport on x.MonthReportId equals y.MonthReportId
where y.ProjectId == projectid
orderby y.ReporMonth descending
select x.ProjectWorkTime ?? 0).FirstOrDefault();
var result = (from x in Funs.DB.SitePerson_DayReportDetail
join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId
where y.ProjectId == projectid && y.CompileDate > Const.DtmarkTime
select x.PersonWorkTime ?? 0).ToList().Sum();
var q = Funs.GetNewIntOrZero(result.ToString().Split('.')[0]);
return q;
@@ -665,11 +678,10 @@ namespace BLL
/// <returns></returns>
public static int GetSafeWorkingHour(string projectid)
{
var result1 = (from x in Funs.DB.SeDin_MonthReport2
join y in Funs.DB.SeDin_MonthReport on x.MonthReportId equals y.MonthReportId
where y.ProjectId == projectid
orderby y.ReporMonth descending
select x.ProjectWorkTime ?? 0).FirstOrDefault();
var result1 = (from x in Funs.DB.SitePerson_DayReportDetail
join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId
where y.ProjectId == projectid && y.CompileDate > Const.DtmarkTime
select x.PersonWorkTime ?? 0).ToList().Sum();
var result2 =
(from x in Funs.DB.Accident_AccidentHandle
where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime
@@ -694,7 +706,7 @@ namespace BLL
var result = (from x in Funs.DB.EduTrain_TrainRecord
join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId
where x.ProjectId == projectid && y.TrainType == "1" && x.TrainStartDate > Const.DtmarkTime
select x).Count();
select x.TrainPersonNum ?? 0).ToList().Sum();
return result;
}
@@ -707,7 +719,7 @@ namespace BLL
var result = (from x in Funs.DB.EduTrain_TrainRecord
join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId
where x.ProjectId == projectid && y.TrainType == "2" && x.TrainStartDate > Const.DtmarkTime
select x).Count();
select x.TrainPersonNum ?? 0).ToList().Sum();
return result;
}
@@ -720,7 +732,7 @@ namespace BLL
var result = (from x in Funs.DB.EduTrain_TrainRecord
join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId
where x.ProjectId == projectid && y.TrainType == "3" && x.TrainStartDate > Const.DtmarkTime
select x).Count();
select x.TrainPersonNum ?? 0).ToList().Sum();
return result;
}
@@ -801,7 +813,7 @@ namespace BLL
public static int GetProjectInspectorGeneralNum(string projectid)
{
var result = (from x in Funs.DB.SitePerson_Person
where x.ProjectId == projectid && x.WorkPostId == Const.WorkPost_ProjectHSSEDirector && x.States=="1"
where x.ProjectId == projectid && x.WorkPostId == Const.WorkPost_ProjectHSSEDirector && x.States == "1"
select x).Count();
return result;
}
@@ -851,8 +863,9 @@ namespace BLL
public static int GetCertificateANum(string projectid)
{
var result = (from x in Funs.DB.SitePerson_Person
join y in Funs.DB.Base_Certificate on x.CertificateId equals y.CertificateId
where x.ProjectId == projectid && y.CertificateType == "A" && x.States == "1"
join y in Funs.DB.QualityAudit_PersonQuality on x.PersonId equals y.PersonId
join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId
where x.ProjectId == projectid && z.CertificateType == "A" && x.States == "1"
select x).Count();
return result;
}
@@ -864,8 +877,9 @@ namespace BLL
public static int GetCertificateBNum(string projectid)
{
var result = (from x in Funs.DB.SitePerson_Person
join y in Funs.DB.Base_Certificate on x.CertificateId equals y.CertificateId
where x.ProjectId == projectid && y.CertificateType == "B" && x.States == "1"
join y in Funs.DB.QualityAudit_PersonQuality on x.PersonId equals y.PersonId
join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId
where x.ProjectId == projectid && z.CertificateType == "B" && x.States == "1"
select x).Count();
return result;
}
@@ -877,8 +891,9 @@ namespace BLL
public static int GetCertificateCNum(string projectid)
{
var result = (from x in Funs.DB.SitePerson_Person
join y in Funs.DB.Base_Certificate on x.CertificateId equals y.CertificateId
where x.ProjectId == projectid && y.CertificateType == "C" && x.States == "1"
join y in Funs.DB.QualityAudit_PersonQuality on x.PersonId equals y.PersonId
join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId
where x.ProjectId == projectid && z.CertificateType == "C" && x.States == "1"
select x).Count();
return result;
}
@@ -968,7 +983,7 @@ namespace BLL
public static int GetProjectLeadShiftCheckNum(string projectid)
{
var result = (from x in Funs.DB.Check_ProjectLeaderCheck
where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime
where x.ProjectId == projectid && x.CheckDate > Const.DtmarkTime
select x).Count();
return result;
}
@@ -1202,7 +1217,7 @@ namespace BLL
(from x in Funs.DB.InApproveManager_GeneralEquipmentInItem
join y in Funs.DB.InApproveManager_GeneralEquipmentIn on x.GeneralEquipmentInId equals y
.GeneralEquipmentInId
where y.ProjectId == projectid
where y.ProjectId == projectid
select x).Count();
return result;
}
@@ -1227,34 +1242,9 @@ namespace BLL
public static int GetLicensesNum(string projectid)
{
var result = (from x in Funs.DB.License_LicenseManager
where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime
where x.ProjectId == projectid && x.IsHighRisk == true && x.CompileDate > Const.DtmarkTime
select x).Count();
var result1 = (from x in Funs.DB.License_BreakGround
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime
select x).Count();
var result2 = (from x in Funs.DB.License_FireWork
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime
select x).Count();
var result3 = (from x in Funs.DB.License_HeightWork
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime
select x).Count();
var result4 = (from x in Funs.DB.License_LiftingWork
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime
select x).Count();
var result5 = (from x in Funs.DB.License_LimitedSpace
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime
select x).Count();
var result6 = (from x in Funs.DB.License_NightWork
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime
select x).Count();
var result7 = (from x in Funs.DB.License_OpenCircuit
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime
select x).Count();
var result8 = (from x in Funs.DB.License_RadialWork
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime
select x).Count();
return (result+ result1+ result2+ result3+ result4+ result5+ result6+ result7+ result8);
return result;
}
/// <summary>
@@ -1264,36 +1254,10 @@ namespace BLL
public static int GetLicensesCloseNum(string projectid)
{
var result = (from x in Funs.DB.License_LicenseManager
where x.ProjectId == projectid && x.WorkStates == "3" &&
where x.ProjectId == projectid && x.IsHighRisk == true && x.WorkStates == "3" &&
x.CompileDate > Const.DtmarkTime
select x).Count();
var result1 = (from x in Funs.DB.License_BreakGround
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime && x.States == "3"
select x).Count();
var result2 = (from x in Funs.DB.License_FireWork
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime && x.States == "3"
select x).Count();
var result3 = (from x in Funs.DB.License_HeightWork
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime && x.States == "3"
select x).Count();
var result4 = (from x in Funs.DB.License_LiftingWork
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime && x.States == "3"
select x).Count();
var result5 = (from x in Funs.DB.License_LimitedSpace
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime && x.States == "3"
select x).Count();
var result6 = (from x in Funs.DB.License_NightWork
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime && x.States == "3"
select x).Count();
var result7 = (from x in Funs.DB.License_OpenCircuit
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime && x.States == "3"
select x).Count();
var result8 = (from x in Funs.DB.License_RadialWork
where x.ProjectId == projectid && x.ValidityStartTime > Const.DtmarkTime && x.States == "3"
select x).Count();
return (result + result1 + result2 + result3 + result4 + result5 + result6 + result7 + result8);
return result;
}
/// <summary>
@@ -1303,7 +1267,8 @@ namespace BLL
public static int GetGeneralClosedNum(string projectid)
{
var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister
where x.ProjectId == projectid && (x.HazardValue == "0.3" || x.HazardValue == "1" || x.HazardValue == null) && x.States == "3" && x.CheckTime > Const.DtmarkTime
where x.ProjectId == projectid && (x.HazardValue == "0.3" || x.HazardValue == "1" || x.HazardValue == null) && x.States == "3" &&
x.CheckTime > Const.DtmarkTime
select x).Count();
return result;
}
@@ -1315,7 +1280,7 @@ namespace BLL
public static int GetGeneralNotClosedNum(string projectid)
{
var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister
where x.ProjectId == projectid && (x.HazardValue == "0.3" || x.HazardValue == "1" || x.HazardValue == null) && x.States != "3" &&
where x.ProjectId == projectid && (x.HazardValue == "0.3" || x.HazardValue == "1" || x.HazardValue == null) && x.States != "3" && x.States != "-1" &&
x.CheckTime > Const.DtmarkTime
select x).Count();
return result;
@@ -1328,7 +1293,7 @@ namespace BLL
public static int GetMajorClosedNum(string projectid)
{
var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister
where x.ProjectId == projectid && x.HazardValue == "3" && x.States == "3" &&
where x.ProjectId == projectid && x.HazardValue == "3" && x.States == "3" &&
x.CheckTime > Const.DtmarkTime
select x).Count();
return result;
@@ -1341,7 +1306,7 @@ namespace BLL
public static int GetMajorNotClosedNum(string projectid)
{
var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister
where x.ProjectId == projectid && x.HazardValue == "3" && x.States != "3" &&
where x.ProjectId == projectid && x.HazardValue == "3" && x.States != "3" && x.States != "-1" &&
x.CheckTime > Const.DtmarkTime
select x).Count();
return result;
@@ -1355,8 +1320,7 @@ namespace BLL
{
var result = (from x in Funs.DB.Hazard_HazardSelectedItem
join y in Funs.DB.Base_RiskLevel on x.HazardLevel equals y.RiskLevelId
join z in Funs.DB.Hazard_HazardList on x.HazardListId equals z.HazardListId
where z.ProjectId == projectid && y.RiskLevel == 2 && z.CompileDate.Value.Year >= 2023
where x.ProjectId == projectid && (y.RiskLevel == 2 || x.HazardLevel == "2") && x.IsStart == true
select x).Count();
return result;
}
@@ -1369,8 +1333,7 @@ namespace BLL
{
var result = (from x in Funs.DB.Hazard_HazardSelectedItem
join y in Funs.DB.Base_RiskLevel on x.HazardLevel equals y.RiskLevelId
join z in Funs.DB.Hazard_HazardList on x.HazardListId equals z.HazardListId
where z.ProjectId == projectid && y.RiskLevel == 1 && z.CompileDate.Value.Year >= 2023
where x.ProjectId == projectid && (y.RiskLevel == 1 || x.HazardLevel == "1") && x.IsStart == true
select x).Count();
return result;
}
@@ -1383,8 +1346,7 @@ namespace BLL
{
var result = (from x in Funs.DB.Hazard_HazardSelectedItem
join y in Funs.DB.Base_RiskLevel on x.HazardLevel equals y.RiskLevelId
join z in Funs.DB.Hazard_HazardList on x.HazardListId equals z.HazardListId
where z.ProjectId == projectid && y.RiskLevel == 3 && z.CompileDate.Value.Year >= 2023
where x.ProjectId == projectid && (y.RiskLevel == 3 || x.HazardLevel == "3") && x.IsStart == true
select x).Count();
return result;
}
@@ -1397,8 +1359,7 @@ namespace BLL
{
var result = (from x in Funs.DB.Hazard_HazardSelectedItem
join y in Funs.DB.Base_RiskLevel on x.HazardLevel equals y.RiskLevelId
join z in Funs.DB.Hazard_HazardList on x.HazardListId equals z.HazardListId
where z.ProjectId == projectid && y.RiskLevel == 4 && z.CompileDate.Value.Year >= 2023
where x.ProjectId == projectid && y.RiskLevel == 4 && x.IsStart == true
select x).Count();
return result;
}
@@ -1621,5 +1582,38 @@ namespace BLL
}
#endregion
#region
/// <summary>
/// 推送项目安全隐患风险数据
/// </summary>
/// <returns></returns>
public static ReturnData PushProjectHSSEData()
{
var items = (from x in db.Project_HSSEData_HSSE
where x.ReportDate == DateTime.Now.Date
select x).ToList();
var detailItems = (from x in db.Project_HSSEData_HiddenDangerDetail
where x.ReportDate == DateTime.Now.Date
select x).ToList();
Model.ReturnData responeData = new Model.ReturnData();
if (items.Count() > 0 || detailItems.Count() > 0)
{
var thisUnit = CommonService.GetIsThisUnit();
var newItem = new { CollCropCode = thisUnit.CollCropCode, Items = items, DetailItems = detailItems };
var str = JsonConvert.SerializeObject(newItem);
var baseurl = "/api/HSSEData/SaveProjectHSSEData";
responeData = ServerService.PushCNCEC(str, baseurl);
}
else
{
responeData.code = 0;
responeData.message = "当前没有项目安全隐患风险数据";
}
return responeData;
}
#endregion
}
}
@@ -1,4 +1,5 @@
using FineUIPro;
using Microsoft.SqlServer.Dts.Runtime;
using Model;
using System;
using System.Collections;
@@ -113,8 +114,9 @@ namespace BLL
}
public static void AddBulkProject_HSSEData_HiddenDangerDetails(List<Model.Project_HSSEData_HiddenDangerDetail> newtables)
{
using (var db = new SGGLDB(Funs.ConnString))
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
db.Project_HSSEData_HiddenDangerDetail.InsertAllOnSubmit(newtables);
db.SubmitChanges();
}
@@ -174,7 +176,7 @@ namespace BLL
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);
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();
}
@@ -208,10 +210,68 @@ namespace BLL
select x).FirstOrDefault();
return q;
}
/// <summary>
/// 获取当天的隐患类别数据
/// </summary>
/// <returns></returns>
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
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;
}
/// <summary>
/// 根据单位id和日期 获取单位关联项目次日期的数据
/// </summary>
/// <param name="Unitid"></param>
/// <param name="reportdate"></param>
/// <returns></returns>
public static List<Model.HSSEDataHiddenDangerDetailItem> GetModelByUnitIdAndReportDate(string Unitid, DateTime? reportdate)
{
var projectlist = BLL.ProjectService.GetProjectWorkList();
var q = (from x in Funs.DB.Project_HSSEData_HiddenDangerDetail
where x.ReportDate == reportdate && projectlist.Select(e => e.ProjectId).Contains(x.ProjectId)
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;
}
/// <summary>
/// 根据日期 获取隐患类别数据
/// </summary>
/// <param name="reportdate"></param>
/// <returns></returns>
public static List<Model.HSSEDataHiddenDangerDetailItem> GetModelByReportDate( DateTime? reportdate)
{
var q = (from x in Funs.DB.Project_HSSEData_HiddenDangerDetail
where x.ReportDate == reportdate
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 List<Model.HSSEDataHiddenDangerDetailItem> GetModelByReportDate(DateTime? reportdate,string projectid)
{
var q = (from x in Funs.DB.Project_HSSEData_HiddenDangerDetail
where x.ReportDate == reportdate && x.ProjectId==projectid
group x by x.TypeName into g
select new Model.HSSEDataHiddenDangerDetailItem
{
@@ -226,7 +286,7 @@ namespace BLL
{
var db = Funs.DB;
var projectids = ProjectService.GetCNCECShowProjectList().Select(x => x.ProjectId).ToList();
var projectids = ProjectService.GetProjectWorkList().Select(x => x.ProjectId).ToList();
var thisUnitId = string.Empty;
var thisUnit = CommonService.GetIsThisUnit();
if (thisUnit != null)
@@ -234,25 +294,24 @@ namespace BLL
thisUnitId = thisUnit.UnitId;
}
var baseUnit = BLL.UnitService.GetUnitByUnitId(thisUnitId);
var list = from x in db.HSSE_Hazard_HazardRegister
where projectids.Contains(x.ProjectId)
select x;
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 }
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 = baseUnit.CollCropCode,
UnitName = baseUnit.UnitName,
ProjectId = g.Key.ProjectId,
ReportDate = DateTime.Now.Date,
TypeName = g.Key.RegisterTypesName,
TotalNum = g.Count(),
NeedRectifyNum = g.Count(x => x.States == "1"),
}).ToList();
select new
{
UnitId = thisUnitId,
CollCropCode = baseUnit.CollCropCode,
UnitName = baseUnit.UnitName,
ProjectId= g.Key.ProjectId,
ReportDate = DateTime.Now.Date,
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)
@@ -57,7 +57,7 @@ namespace BLL
public static int count
{
get;
set;
set;
}
public static List<Model.Project_SYHSEData_SYHSE> GetProject_SYHSEData_SYHSEByModle(Model.Project_SYHSEData_SYHSE table)
{
@@ -67,7 +67,7 @@ namespace BLL
(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.UnitName) || x.UnitName.Contains(table.UnitName))
select x
;
@@ -81,13 +81,13 @@ namespace BLL
/// <returns></returns>
public static IEnumerable getListData(Model.Project_SYHSEData_SYHSE table, Grid Grid1)
{
var q = GetProject_SYHSEData_SYHSEByModle(table);
var q = GetProject_SYHSEData_SYHSEByModle(table);
count = q.Count();
if (count == 0)
{
return null;
}
//q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
//q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
return from x in q
select new
{
@@ -142,113 +142,120 @@ namespace BLL
}
public static void AddProject_SYHSEData_SYHSE(Model.Project_SYHSEData_SYHSE newtable)
{
Model.Project_SYHSEData_SYHSE table = new Model.Project_SYHSEData_SYHSE
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,
GeneralRiskNum = newtable.GeneralRiskNum,
LowRiskNum = newtable.LowRiskNum,
MediumRiskNum = newtable.MediumRiskNum,
HighRiskNum = newtable.HighRiskNum,
GradedResponsiblePersonNum = newtable.GradedResponsiblePersonNum,
ChargeInsurancePersonNum = newtable.ChargeInsurancePersonNum,
DesignQuantity = newtable.DesignQuantity,
RunningCapacity = newtable.RunningCapacity,
InterlockSettingValue = newtable.InterlockSettingValue,
VideoSurveillanceNum = newtable.VideoSurveillanceNum,
TotalWorkinghours = newtable.TotalWorkinghours,
SafeWorkinghours = newtable.SafeWorkinghours,
LostWorkinghours = newtable.LostWorkinghours,
TotalEnergyConsumption = newtable.TotalEnergyConsumption,
IncomeComprehensiveEnergyConsumption = newtable.IncomeComprehensiveEnergyConsumption,
NewWaterConsumption = newtable.NewWaterConsumption,
GeneralClosedNum = newtable.GeneralClosedNum,
GeneralNotClosedNum = newtable.GeneralNotClosedNum,
MajorClosedNum = newtable.MajorClosedNum,
MajorNotClosedNum = newtable.MajorNotClosedNum,
HotWorkPermitNum = newtable.HotWorkPermitNum,
HotWorkClosedNum = newtable.HotWorkClosedNum,
HighPermitNum = newtable.HighPermitNum,
HighClosedNum = newtable.HighClosedNum,
TemporaryElectricityPermitNum = newtable.TemporaryElectricityPermitNum,
TemporaryElectricityClosedNum = newtable.TemporaryElectricityClosedNum,
BlindPlatePermitNum = newtable.BlindPlatePermitNum,
BlindPlateClosedNum = newtable.BlindPlateClosedNum,
GroundbreakingPermitNum = newtable.GroundbreakingPermitNum,
GroundbreakingClosedNum = newtable.GroundbreakingClosedNum,
OpenCircuitPermitNum = newtable.OpenCircuitPermitNum,
OpenCircuitClosedNum = newtable.OpenCircuitClosedNum,
HoistingPermitNum = newtable.HoistingPermitNum,
HoistingClosedNum = newtable.HoistingClosedNum,
};
db.Project_SYHSEData_SYHSE.InsertOnSubmit(table);
db.SubmitChanges();
Model.Project_SYHSEData_SYHSE table = new Model.Project_SYHSEData_SYHSE
{
Id = newtable.Id,
ProjectId = newtable.ProjectId,
UnitId = newtable.UnitId,
CollCropCode = newtable.CollCropCode,
UnitName = newtable.UnitName,
ReportDate = newtable.ReportDate,
GeneralRiskNum = newtable.GeneralRiskNum,
LowRiskNum = newtable.LowRiskNum,
MediumRiskNum = newtable.MediumRiskNum,
HighRiskNum = newtable.HighRiskNum,
GradedResponsiblePersonNum = newtable.GradedResponsiblePersonNum,
ChargeInsurancePersonNum = newtable.ChargeInsurancePersonNum,
DesignQuantity = newtable.DesignQuantity,
RunningCapacity = newtable.RunningCapacity,
InterlockSettingValue = newtable.InterlockSettingValue,
VideoSurveillanceNum = newtable.VideoSurveillanceNum,
TotalWorkinghours = newtable.TotalWorkinghours,
SafeWorkinghours = newtable.SafeWorkinghours,
LostWorkinghours = newtable.LostWorkinghours,
TotalEnergyConsumption = newtable.TotalEnergyConsumption,
IncomeComprehensiveEnergyConsumption = newtable.IncomeComprehensiveEnergyConsumption,
NewWaterConsumption = newtable.NewWaterConsumption,
GeneralClosedNum = newtable.GeneralClosedNum,
GeneralNotClosedNum = newtable.GeneralNotClosedNum,
MajorClosedNum = newtable.MajorClosedNum,
MajorNotClosedNum = newtable.MajorNotClosedNum,
HotWorkPermitNum = newtable.HotWorkPermitNum,
HotWorkClosedNum = newtable.HotWorkClosedNum,
HighPermitNum = newtable.HighPermitNum,
HighClosedNum = newtable.HighClosedNum,
TemporaryElectricityPermitNum = newtable.TemporaryElectricityPermitNum,
TemporaryElectricityClosedNum = newtable.TemporaryElectricityClosedNum,
BlindPlatePermitNum = newtable.BlindPlatePermitNum,
BlindPlateClosedNum = newtable.BlindPlateClosedNum,
GroundbreakingPermitNum = newtable.GroundbreakingPermitNum,
GroundbreakingClosedNum = newtable.GroundbreakingClosedNum,
OpenCircuitPermitNum = newtable.OpenCircuitPermitNum,
OpenCircuitClosedNum = newtable.OpenCircuitClosedNum,
HoistingPermitNum = newtable.HoistingPermitNum,
HoistingClosedNum = newtable.HoistingClosedNum,
};
db.Project_SYHSEData_SYHSE.InsertOnSubmit(table);
db.SubmitChanges();
}
}
public static void UpdateProject_SYHSEData_SYHSE(Model.Project_SYHSEData_SYHSE newtable)
{
Model.Project_SYHSEData_SYHSE table = db.Project_SYHSEData_SYHSE.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
table.Id = newtable.Id;
table.ProjectId = newtable.ProjectId;
table.UnitId = newtable.UnitId;
table.CollCropCode = newtable.CollCropCode;
table.UnitName = newtable.UnitName;
table.ReportDate = newtable.ReportDate;
table.GeneralRiskNum = newtable.GeneralRiskNum;
table.LowRiskNum = newtable.LowRiskNum;
table.MediumRiskNum = newtable.MediumRiskNum;
table.HighRiskNum = newtable.HighRiskNum;
table.GradedResponsiblePersonNum = newtable.GradedResponsiblePersonNum;
table.ChargeInsurancePersonNum = newtable.ChargeInsurancePersonNum;
table.DesignQuantity = newtable.DesignQuantity;
table.RunningCapacity = newtable.RunningCapacity;
table.InterlockSettingValue = newtable.InterlockSettingValue;
table.VideoSurveillanceNum = newtable.VideoSurveillanceNum;
table.TotalWorkinghours = newtable.TotalWorkinghours;
table.SafeWorkinghours = newtable.SafeWorkinghours;
table.LostWorkinghours = newtable.LostWorkinghours;
table.TotalEnergyConsumption = newtable.TotalEnergyConsumption;
table.IncomeComprehensiveEnergyConsumption = newtable.IncomeComprehensiveEnergyConsumption;
table.NewWaterConsumption = newtable.NewWaterConsumption;
table.GeneralClosedNum = newtable.GeneralClosedNum;
table.GeneralNotClosedNum = newtable.GeneralNotClosedNum;
table.MajorClosedNum = newtable.MajorClosedNum;
table.MajorNotClosedNum = newtable.MajorNotClosedNum;
table.HotWorkPermitNum = newtable.HotWorkPermitNum;
table.HotWorkClosedNum = newtable.HotWorkClosedNum;
table.HighPermitNum = newtable.HighPermitNum;
table.HighClosedNum = newtable.HighClosedNum;
table.TemporaryElectricityPermitNum = newtable.TemporaryElectricityPermitNum;
table.TemporaryElectricityClosedNum = newtable.TemporaryElectricityClosedNum;
table.BlindPlatePermitNum = newtable.BlindPlatePermitNum;
table.BlindPlateClosedNum = newtable.BlindPlateClosedNum;
table.GroundbreakingPermitNum = newtable.GroundbreakingPermitNum;
table.GroundbreakingClosedNum = newtable.GroundbreakingClosedNum;
table.OpenCircuitPermitNum = newtable.OpenCircuitPermitNum;
table.OpenCircuitClosedNum = newtable.OpenCircuitClosedNum;
table.HoistingPermitNum = newtable.HoistingPermitNum;
table.HoistingClosedNum = newtable.HoistingClosedNum;
db.SubmitChanges();
}
Model.Project_SYHSEData_SYHSE table = db.Project_SYHSEData_SYHSE.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
{
table.Id = newtable.Id;
table.ProjectId = newtable.ProjectId;
table.UnitId = newtable.UnitId;
table.CollCropCode = newtable.CollCropCode;
table.UnitName = newtable.UnitName;
table.ReportDate = newtable.ReportDate;
table.GeneralRiskNum = newtable.GeneralRiskNum;
table.LowRiskNum = newtable.LowRiskNum;
table.MediumRiskNum = newtable.MediumRiskNum;
table.HighRiskNum = newtable.HighRiskNum;
table.GradedResponsiblePersonNum = newtable.GradedResponsiblePersonNum;
table.ChargeInsurancePersonNum = newtable.ChargeInsurancePersonNum;
table.DesignQuantity = newtable.DesignQuantity;
table.RunningCapacity = newtable.RunningCapacity;
table.InterlockSettingValue = newtable.InterlockSettingValue;
table.VideoSurveillanceNum = newtable.VideoSurveillanceNum;
table.TotalWorkinghours = newtable.TotalWorkinghours;
table.SafeWorkinghours = newtable.SafeWorkinghours;
table.LostWorkinghours = newtable.LostWorkinghours;
table.TotalEnergyConsumption = newtable.TotalEnergyConsumption;
table.IncomeComprehensiveEnergyConsumption = newtable.IncomeComprehensiveEnergyConsumption;
table.NewWaterConsumption = newtable.NewWaterConsumption;
table.GeneralClosedNum = newtable.GeneralClosedNum;
table.GeneralNotClosedNum = newtable.GeneralNotClosedNum;
table.MajorClosedNum = newtable.MajorClosedNum;
table.MajorNotClosedNum = newtable.MajorNotClosedNum;
table.HotWorkPermitNum = newtable.HotWorkPermitNum;
table.HotWorkClosedNum = newtable.HotWorkClosedNum;
table.HighPermitNum = newtable.HighPermitNum;
table.HighClosedNum = newtable.HighClosedNum;
table.TemporaryElectricityPermitNum = newtable.TemporaryElectricityPermitNum;
table.TemporaryElectricityClosedNum = newtable.TemporaryElectricityClosedNum;
table.BlindPlatePermitNum = newtable.BlindPlatePermitNum;
table.BlindPlateClosedNum = newtable.BlindPlateClosedNum;
table.GroundbreakingPermitNum = newtable.GroundbreakingPermitNum;
table.GroundbreakingClosedNum = newtable.GroundbreakingClosedNum;
table.OpenCircuitPermitNum = newtable.OpenCircuitPermitNum;
table.OpenCircuitClosedNum = newtable.OpenCircuitClosedNum;
table.HoistingPermitNum = newtable.HoistingPermitNum;
table.HoistingClosedNum = newtable.HoistingClosedNum;
db.SubmitChanges();
}
}
}
public static void DeleteProject_SYHSEData_SYHSEById(string Id)
{
Model.Project_SYHSEData_SYHSE table = db.Project_SYHSEData_SYHSE.FirstOrDefault(x => x.Id == Id);
if (table != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
db.Project_SYHSEData_SYHSE.DeleteOnSubmit(table);
db.SubmitChanges();
Model.Project_SYHSEData_SYHSE table = db.Project_SYHSEData_SYHSE.FirstOrDefault(x => x.Id == Id);
if (table != null)
{
db.Project_SYHSEData_SYHSE.DeleteOnSubmit(table);
db.SubmitChanges();
}
}
}
/// <summary>
/// 判断当天是否统计过数据
@@ -284,7 +291,7 @@ namespace BLL
/// </summary>
public static void StatisticalAllProjectData()
{
var projectlist = ProjectService.GetCNCECShowProjectList();
var projectlist = ProjectService.GetProjectWorkList();
foreach (var item in projectlist)
{
StatisticalData(item.ProjectId, SYHSESDateType.All);
@@ -295,7 +302,7 @@ namespace BLL
/// </summary>
/// <param name="projectid"></param>
/// <param name="sYHSESDateType"></param>
public static void StatisticalData(string projectid, SYHSESDateType sYHSESDateType)
public static void StatisticalData(string projectid,SYHSESDateType sYHSESDateType)
{
string thisUnitId = string.Empty;
var thisUnit = CommonService.GetIsThisUnit();
@@ -319,7 +326,7 @@ namespace BLL
table.ProjectId = projectid;
table.ReportDate = DateTime.Now.Date;
if (sYHSESDateType == SYHSESDateType.RiskControl || sYHSESDateType == SYHSESDateType.All)
if (sYHSESDateType== SYHSESDateType.RiskControl || sYHSESDateType == SYHSESDateType.All)
{
table.GeneralRiskNum = GetGeneralRiskNum(projectid);
table.LowRiskNum = GetLowRiskNum(projectid);
+36 -36
View File
@@ -30,7 +30,7 @@ namespace BLL
var q = from x in db.SYHSEData_Data
where
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
(string.IsNullOrEmpty(table.FactoryId) || x.FactoryId.Contains(table.FactoryId))
(string.IsNullOrEmpty(table.FactoryId) || x.FactoryId.Contains(table.FactoryId))
select x
;
@@ -89,31 +89,31 @@ namespace BLL
}
public static Model.NewSYHSEData GetItemById(string Id)
{
var data = GetSYHSEData_DataById(Id);
var data=GetSYHSEData_DataById(Id);
var data_realtime = HazardRealtimedeviceService.GetHazard_RealTimeDeviceByDate(data.ReportDate);
var data_hidden = SyhsedataHiddendangercheckService.GetSYHSEData_HiddenDangerCheckByDate(data.ReportDate);
var data_risk = SyhsedataRiskcontrolService.GetSYHSEData_RiskControlByDate(data.ReportDate);
var data_hidden= SyhsedataHiddendangercheckService.GetSYHSEData_HiddenDangerCheckByDate(data.ReportDate);
var data_risk= SyhsedataRiskcontrolService.GetSYHSEData_RiskControlByDate(data.ReportDate);
NewSYHSEData APIData = new NewSYHSEData();
var APIDataList_Item = new List<NewSYHSEDataItem>();
var APIDataList_Relatime = new List<NewSYHSEDataRealTimeDeviceItem>();
var APIDataList_Hidden = new List<NewSYHSEDataHiddenDangerCheckItem>();
var APIDataList_Risk = new List<NewSYHSEDataRiskControlItem>();
var APIDataList_Item= new List<NewSYHSEDataItem>();
var APIDataList_Relatime= new List<NewSYHSEDataRealTimeDeviceItem>();
var APIDataList_Hidden= new List<NewSYHSEDataHiddenDangerCheckItem>();
var APIDataList_Risk= new List<NewSYHSEDataRiskControlItem>();
foreach (var tb in data_realtime)
{
var q = new NewSYHSEDataRealTimeDeviceItem()
{
Id = tb.ID,
HazardName = tb.HazardName,
HazardLevel = tb.HazardLevel,
DeviceName = tb.DeviceName,
Medium = tb.Medium,
MeasurementUnit = tb.MeasurementUnit,
DateTime = tb.DateTime.ToString(),
Value = tb.Value,
Id=tb.ID,
HazardName=tb.HazardName,
HazardLevel=tb.HazardLevel,
DeviceName=tb.DeviceName,
Medium=tb.Medium,
MeasurementUnit=tb.MeasurementUnit,
DateTime=tb.DateTime.ToString(),
Value=tb.Value,
};
APIDataList_Relatime.Add(q);
@@ -123,10 +123,10 @@ namespace BLL
{
var q = new NewSYHSEDataHiddenDangerCheckItem()
{
Id = tb.Id,
HiddenDangerName = tb.HiddenDangerName,
TotalNum = tb.TotalNum.HasValue ? tb.TotalNum.Value : 0,
OKNum = tb.OKNum.HasValue ? tb.OKNum.Value : 0,
Id=tb.Id,
HiddenDangerName=tb.HiddenDangerName,
TotalNum=tb.TotalNum.HasValue ? tb.TotalNum.Value:0,
OKNum=tb.OKNum.HasValue ? tb.OKNum.Value : 0,
};
APIDataList_Hidden.Add(q);
@@ -136,31 +136,31 @@ namespace BLL
{
var q = new NewSYHSEDataRiskControlItem()
{
Id = tb.Id,
RiskControlName = tb.RiskControlName,
};
{
Id=tb.Id,
RiskControlName=tb.RiskControlName,
};
APIDataList_Risk.Add(q);
}
var thisUnit = CommonService.GetIsThisUnit();
NewSYHSEDataItem Item = new NewSYHSEDataItem();
Item.Id = data.Id;
Item.ReportDate = data.ReportDate.ToString();
Item.ReportDate=data.ReportDate.ToString();
Item.UnitId = thisUnit.UnitId;
Item.CollCropCode = thisUnit.CollCropCode;
Item.UnitName = thisUnit.UnitName;
Item.UnitName= thisUnit.UnitName;
Item.FactoryId = data.FactoryId;
Item.FactoryCode = ProjectService.GetProjectByProjectId(data.FactoryId).ProjectCode;
Item.FactoryCode = ProjectService.GetProjectByProjectId(data.FactoryId).ProjectCode;
Item.FactoryName = ProjectService.GetProjectByProjectId(data.FactoryId).ProjectName;
Item.Address = ProjectService.GetProjectByProjectId(data.FactoryId).ProjectAddress;
Item.MapCoordinates = ProjectService.GetProjectByProjectId(data.FactoryId).MapCoordinates;
Item.SafetyMnaHours = data.SafetyMnaHours.HasValue ? data.SafetyMnaHours.Value : 0;
Item.GeneralRiskNum = data.GeneralRiskNum.HasValue ? data.GeneralRiskNum.Value : 0;
Item.LowRiskNum = data.LowRiskNum.HasValue ? data.LowRiskNum.Value : 0;
Item.MoreRiskNum = data.MoreRiskNum.HasValue ? data.MoreRiskNum.Value : 0;
Item.GreatRiskNum = data.GreatRiskNum.HasValue ? data.GreatRiskNum.Value : 0;
Item.MapCoordinates= ProjectService.GetProjectByProjectId(data.FactoryId).MapCoordinates;
Item.SafetyMnaHours = data.SafetyMnaHours.HasValue ? data.SafetyMnaHours.Value : 0;
Item.GeneralRiskNum = data.GeneralRiskNum.HasValue ? data.GeneralRiskNum.Value : 0;
Item.LowRiskNum = data.LowRiskNum.HasValue ? data.LowRiskNum.Value : 0;
Item.MoreRiskNum = data.MoreRiskNum.HasValue ? data.MoreRiskNum.Value : 0;
Item.GreatRiskNum = data.GreatRiskNum.HasValue ? data.GreatRiskNum.Value : 0;
Item.NewSYHSEDataRiskControlItems = APIDataList_Risk;
Item.NewSYHSEDataRealTimeDeviceItems = APIDataList_Relatime;
Item.NewSYHSEDataHiddenDangerCheckItems = APIDataList_Hidden;
@@ -168,7 +168,7 @@ namespace BLL
APIDataList_Item.Add(Item);
APIData.NewSYHSEDataItems = APIDataList_Item;
return APIData;
}
@@ -29,7 +29,7 @@ namespace BLL
where
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
(string.IsNullOrEmpty(table.FactoryId) || x.FactoryId.Contains(table.FactoryId)) &&
(string.IsNullOrEmpty(table.HiddenDangerName) || x.HiddenDangerName.Contains(table.HiddenDangerName))
(string.IsNullOrEmpty(table.HiddenDangerName) || x.HiddenDangerName.Contains(table.HiddenDangerName))
select x
;
@@ -29,7 +29,7 @@ namespace BLL
where
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
(string.IsNullOrEmpty(table.FactoryId) || x.FactoryId.Contains(table.FactoryId)) &&
(string.IsNullOrEmpty(table.RiskControlName) || x.RiskControlName.Contains(table.RiskControlName))
(string.IsNullOrEmpty(table.RiskControlName) || x.RiskControlName.Contains(table.RiskControlName))
select x
;
@@ -307,7 +307,7 @@ namespace BLL
q.State = Const.CNCEC_State_1;
UpdateSYHSEData_SYHSE(q);
}
}
public static bool IsReportByDate(DateTime dateTime)
{
+242 -29
View File
@@ -1,25 +1,34 @@
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Configuration;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using ResponeData = Model.ResponeData;
namespace BLL
{
/// <summary>
/// 集团服务类
/// </summary>
public static class ServerService
{
/// <summary>
/// 获取集团token
/// </summary>
/// <returns></returns>
public static Model.TokenItem GetCNCECToken()
{
string CNCECPath = SysConstSetService.CNCECPath;
string baseurl = CNCECPath + "/api/Common/GetToken";
var client = new RestClient(baseurl);
client.Timeout = -1;
client.Timeout = 2000;//获取token设置超时时间为3秒
var request = new RestRequest(Method.POST);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var thisUnit = CommonService.GetIsThisUnit();
@@ -28,45 +37,73 @@ namespace BLL
//request.AddJsonBody(JsonBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
var responeData = JsonConvert.DeserializeObject<Model.ResponeData>(response.Content.ToString());
TokenItem tokenItem = new TokenItem();
if (responeData.code == 1 && string.IsNullOrEmpty(responeData.message))
try
{
var token = JsonConvert.DeserializeObject<Model.TokenItem>(responeData.data.ToString());
tokenItem.Token = token.Token.ToString();
tokenItem.ExpiryTime = token.ExpiryTime.ToString();
SysConstSetService.SetToken(tokenItem.Token);
SysConstSetService.SetTokenExpirationTime(tokenItem.ExpiryTime);
var responeData = JsonConvert.DeserializeObject<Model.ResponeData>(response.Content.ToString());
if (responeData != null && responeData.code == 1 && string.IsNullOrEmpty(responeData.message))
{
var token = JsonConvert.DeserializeObject<Model.TokenItem>(responeData.data.ToString());
tokenItem.Token = token.Token.ToString();
tokenItem.ExpiryTime = token.ExpiryTime.ToString();
SysConstSetService.SetToken(tokenItem.Token);
SysConstSetService.SetTokenExpirationTime(tokenItem.ExpiryTime);
}
}
catch (Exception e)
{
}
return tokenItem;
}
/// <summary>
/// 推送数据至集团(post接口)
/// </summary>
/// <param name="JsonBody"></param>
/// <param name="apiurl"></param>
/// <returns></returns>
public static Model.ReturnData PushCNCEC(string JsonBody, string apiurl)
{
Model.ReturnData responeData = new Model.ReturnData();
string CNCECPath = SysConstSetService.CNCECPath;
if (string.IsNullOrEmpty(CNCECPath))
try
{
responeData.code = 0;
responeData.message = "接口地址为空,请配置!";
return responeData;
Model.ReturnData responeData = new Model.ReturnData();
string CNCECPath = SysConstSetService.CNCECPath;
//CNCECPath = "http://localhost:7143";
if (string.IsNullOrEmpty(CNCECPath))
{
responeData.code = 0;
responeData.message = "接口地址为空,请配置!";
return responeData;
}
string baseurl = CNCECPath + apiurl;
var client = new RestClient(baseurl);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var tokenItem = GetToken();
request.AddHeader("token", tokenItem.Token);
request.AddJsonBody(JsonBody);
IRestResponse response = client.Execute(request);
APICommonService.SaveSysHttpLog("api_Out", baseurl, response.Content);
var returnData = JsonConvert.DeserializeObject<Model.ResponeData>(response.Content.ToString());
responeData.code = returnData.code;
responeData.message = returnData.message;
return responeData;
}
catch (Exception ex)
{
throw;
}
string baseurl = CNCECPath + apiurl;
var client = new RestClient(baseurl);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var tokenItem = GetToken();
request.AddHeader("token", tokenItem.Token);
request.AddJsonBody(JsonBody);
IRestResponse response = client.Execute(request);
APICommonService.SaveSysHttpLog("api_Out", baseurl, response.Content);
var returnData = JsonConvert.DeserializeObject<Model.ResponeData>(response.Content.ToString());
responeData.code = returnData.code;
responeData.message = returnData.message;
return responeData;
}
/// <summary>
/// 获取token
/// </summary>
/// <returns></returns>
public static Model.TokenItem GetToken()
{
Model.TokenItem tokenItem = new Model.TokenItem();
@@ -84,6 +121,182 @@ namespace BLL
}
return tokenItem;
}
/// <summary>
/// 从集团获取数据(Get接口)
/// </summary>
/// <param name="apiurl">接口地址</param>
/// <param name="parameters">parameters参数</param>
/// <param name="timeout">超时时间</param>
/// <returns></returns>
public static Model.ResponeData GerDataFromCncec(string apiurl, Dictionary<string, string> parameters, int? timeout = null)
{
Model.ResponeData responeData = new Model.ResponeData();
try
{
string CNCECPath = SysConstSetService.CNCECPath;
if (string.IsNullOrEmpty(CNCECPath))
{
responeData.code = 0;
responeData.message = "接口地址为空,请配置!";
return responeData;
}
string baseurl = CNCECPath + apiurl;
var client = new RestClient(baseurl);
client.Timeout = timeout ?? -1;
var request = new RestRequest(Method.GET);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var tokenItem = GetToken();
if (tokenItem == null || string.IsNullOrEmpty(tokenItem.Token))
{
responeData.code = 0;
responeData.message = "token 不存在!";
return responeData;
}
request.AddHeader("token", tokenItem.Token);
if (parameters != null)
{
foreach (var parameter in parameters)
{
request.AddParameter(parameter.Key, parameter.Value);
}
}
IRestResponse response = client.Execute(request);
APICommonService.SaveSysHttpLog("api_Out", baseurl, response.Content);
var returnData = JsonConvert.DeserializeObject<Model.ResponeData>(response.Content.ToString());
if (returnData != null)
{
responeData.code = returnData.code;
responeData.message = returnData.message;
responeData.data = returnData.data;
}
else
{
responeData.code = -1;
responeData.message = "接口有误";
}
return responeData;
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.ToString();
return responeData;
}
}
/// <summary>
/// 获取安全合规列表
/// </summary>
/// <param name="type">类型(1-法律法规;2-标准规范;3-规章制度;4-管理规定)</param>
/// <returns></returns>
public static async Task<List<Model.SafeLawItem>> GetSafeLawListByTypeAsync(string type)
{
// 使用 lambda 表达式来调用 getSafeLawListByType
return await Task.Run(() => GetSafeLawListByType(type));
}
/// <summary>
/// 获取安全合规列表
/// </summary>
/// <param name="type">类型(1-法律法规;2-标准规范;3-规章制度;4-管理规定)</param>
/// <returns></returns>
public static List<Model.SafeLawItem> GetSafeLawListByType(string type)
{
List<SafeLawItem> result = new List<SafeLawItem>();
string baseurl = "/api/Resources/getSafeLawListByType";
Dictionary<string, string> dic = new Dictionary<string, string>()
{
{"type",type},
{"pageIndex","0"}
};
var returnData = GerDataFromCncec(baseurl, dic, 3000);
if (returnData != null && returnData.code == 1)
{
JObject jt = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(returnData.data.ToString());
var data = jt["getDataList"].ToString();
result = JsonConvert.DeserializeObject<List<Model.SafeLawItem>>(data);
}
return result;
}
/// <summary>
/// 获取公告列表
/// </summary>
/// <returns></returns>
public static List<Model.NoticeOutput> GetNoticeList()
{
List<NoticeOutput> result = new List<NoticeOutput>();
string baseurl = "/api/Notice/getNoticeList";
Dictionary<string, string> dic = new Dictionary<string, string>()
{
{"pageIndex","0"}
};
var returnData = GerDataFromCncec(baseurl, dic, 4000);
if (returnData != null && returnData.code == 1)
{
JObject jt = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(returnData.data.ToString());
var data = jt["getDataList"].ToString();
result = JsonConvert.DeserializeObject<List<Model.NoticeOutput>>(data);
}
return result;
}
/// <summary>
/// 获取公告列表
/// </summary>
/// <returns></returns>
public static async Task<List<Model.NoticeOutput>> GetNoticeListAsync()
{
return await Task.Run(() => GetNoticeList());
}
/// <summary>
/// 获取新闻列表
/// </summary>
/// <returns></returns>
public static List<Model.NoticeOutput> GetNewsList()
{
List<NoticeOutput> result = new List<NoticeOutput>();
string baseurl = "/api/Notice/getNewsList";
Dictionary<string, string> dic = new Dictionary<string, string>()
{
{"pageIndex","0"}
};
var returnData = GerDataFromCncec(baseurl, dic, 3000);
if (returnData != null && returnData.code == 1)
{
JObject jt = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(returnData.data.ToString());
var data = jt["getDataList"].ToString();
result = JsonConvert.DeserializeObject<List<Model.NoticeOutput>>(data);
}
return result;
}
/// <summary>
/// 获取新闻列表
/// </summary>
/// <returns></returns>
public static async Task<List<Model.NoticeOutput>> GetNewsListAsync()
{
return await Task.Run(() => GetNewsList());
}
/// <summary>
/// 获取QHSEUrl
/// </summary>
/// <returns></returns>
public static string GetQHSEUrl()
{
var result = GerDataFromCncec("/api/Data/GetWebUrl", null, 3000).data?.ToString();
return result;
}
}
}