235 lines
9.8 KiB
C#
235 lines
9.8 KiB
C#
using FineUIPro;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Linq;
|
|
|
|
namespace BLL
|
|
{
|
|
/// <summary>
|
|
/// 安全许可证
|
|
/// </summary>
|
|
public static class LicenseManagerService
|
|
{
|
|
#region 获取安全巡检列表信息
|
|
/// <summary>
|
|
/// 记录数
|
|
/// </summary>
|
|
public static int count
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 定义变量
|
|
/// </summary>
|
|
private static IQueryable<Model.License_LicenseManager> getDataLists = from x in Funs.DB.License_LicenseManager
|
|
select x;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="projetcId"></param>
|
|
/// <param name="checkMan"></param>
|
|
/// <param name="type"></param>
|
|
/// <param name="workAreaName"></param>
|
|
/// <param name="responsibilityUnitName"></param>
|
|
/// <param name="startTime"></param>
|
|
/// <param name="endTime"></param>
|
|
/// <param name="startRectificationTime"></param>
|
|
/// <param name="endRectificationTime"></param>
|
|
/// <param name="states"></param>
|
|
/// <param name="personId"></param>
|
|
/// <param name="unitId"></param>
|
|
/// <param name="Grid1"></param>
|
|
/// <returns></returns>
|
|
public static IEnumerable getListData(string projectId, string unitId, DateTime? startTime, DateTime? endTime, string licenseType, string unitId2, Grid Grid1)
|
|
{
|
|
IQueryable<Model.License_LicenseManager> getDataList = getDataLists;
|
|
if (!string.IsNullOrEmpty(projectId))
|
|
{
|
|
getDataList = getDataList.Where(e => e.ProjectId == projectId);
|
|
}
|
|
if (BLL.ProjectUnitService.GetProjectUnitTypeByProjectIdUnitId(projectId, unitId))
|
|
{
|
|
getDataList = getDataList.Where(e => e.UnitId == unitId);
|
|
}
|
|
if (startTime.HasValue)
|
|
{
|
|
getDataList = getDataList.Where(e => e.StartDate >= startTime);
|
|
}
|
|
if (endTime.HasValue)
|
|
{
|
|
getDataList = getDataList.Where(e => e.EndDate <= endTime);
|
|
}
|
|
if (!string.IsNullOrEmpty(licenseType))
|
|
{
|
|
getDataList = getDataList.Where(e => e.LicenseTypeId == licenseType);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(unitId2) && unitId2 != Const._Null)
|
|
{
|
|
getDataList = getDataList.Where(e => e.UnitId == unitId2);
|
|
}
|
|
|
|
|
|
count = getDataList.Count();
|
|
if (count == 0)
|
|
{
|
|
return null;
|
|
}
|
|
getDataList = SortConditionHelper.SortingAndPaging(getDataList, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
|
var db1 = Funs.DB;
|
|
return from x in getDataList
|
|
select new
|
|
{
|
|
x.LicenseManagerId,
|
|
x.LicenseManagerCode,
|
|
LicenseTypeName = db1.Base_LicenseType.First(t => t.LicenseTypeId == x.LicenseTypeId).LicenseTypeName,
|
|
UnitName = db1.Base_Unit.First(u => u.UnitId == x.UnitId).UnitName,
|
|
WorkAreaName = UnitWorkService.GetUnitWorkName(x.WorkAreaId),
|
|
x.CompileDate,
|
|
x.StartDate,
|
|
x.EndDate,
|
|
FlowOperateName = getFlow(x.LicenseManagerId, x.States),
|
|
};
|
|
}
|
|
|
|
public static string getFlow(string id, string states)
|
|
{
|
|
string strrValue = string.Empty;
|
|
string name = string.Empty;
|
|
var getFlow = Funs.DB.Sys_FlowOperate.FirstOrDefault(x => x.DataId == id && x.IsClosed != true);
|
|
if (getFlow != null)
|
|
{
|
|
var getPerson = Funs.DB.Person_Persons.FirstOrDefault(x => x.PersonId == getFlow.OperaterId);
|
|
if (getPerson != null)
|
|
{
|
|
name = getPerson.PersonName;
|
|
}
|
|
}
|
|
|
|
if (states == BLL.Const.State_0 || string.IsNullOrEmpty(states))
|
|
{
|
|
strrValue = "待[" + name + "]提交";
|
|
}
|
|
else if (states == BLL.Const.State_1)
|
|
{
|
|
strrValue = "审核/审批完成";
|
|
}
|
|
else
|
|
{
|
|
strrValue = "待[" + name + "]办理";
|
|
}
|
|
|
|
return strrValue;
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 根据主键获取安全许可证
|
|
/// </summary>
|
|
/// <param name="licenseManagerId"></param>
|
|
/// <returns></returns>
|
|
public static Model.License_LicenseManager GetLicenseManagerById(string licenseManagerId)
|
|
{
|
|
return Funs.DB.License_LicenseManager.FirstOrDefault(e => e.LicenseManagerId == licenseManagerId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据时间段获取HSE安全许可证集合
|
|
/// </summary>
|
|
/// <param name="startTime">开始时间</param>
|
|
/// <param name="endTime">结束时间</param>
|
|
/// <param name="projectId">项目Id</param>
|
|
/// <returns>时间段内的HSE安全许可证集合</returns>
|
|
public static int GetCountByDate(DateTime startTime, DateTime endTime, string projectId)
|
|
{
|
|
return (from x in Funs.DB.License_LicenseManager where x.CompileDate >= startTime && x.CompileDate <= endTime && x.ProjectId == projectId select x).Count();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加安全许可证
|
|
/// </summary>
|
|
/// <param name="licenseManager"></param>
|
|
public static void AddLicenseManager(Model.License_LicenseManager licenseManager)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.License_LicenseManager newLicenseManager = new Model.License_LicenseManager
|
|
{
|
|
LicenseManagerId = licenseManager.LicenseManagerId,
|
|
ProjectId = licenseManager.ProjectId,
|
|
LicenseTypeId = licenseManager.LicenseTypeId,
|
|
LicenseManagerCode = licenseManager.LicenseManagerCode,
|
|
LicenseManageName = licenseManager.LicenseManageName,
|
|
UnitId = licenseManager.UnitId,
|
|
LicenseManageContents = licenseManager.LicenseManageContents,
|
|
ApplicantMan = licenseManager.ApplicantMan,
|
|
CompileMan = licenseManager.CompileMan,
|
|
CompileDate = licenseManager.CompileDate,
|
|
States = licenseManager.States,
|
|
WorkAreaId = licenseManager.WorkAreaId,
|
|
StartDate = licenseManager.StartDate,
|
|
EndDate = licenseManager.EndDate,
|
|
WorkStates = licenseManager.WorkStates,
|
|
};
|
|
db.License_LicenseManager.InsertOnSubmit(newLicenseManager);
|
|
db.SubmitChanges();
|
|
|
|
////增加一条编码记录
|
|
BLL.CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(BLL.Const.ProjectLicenseManagerMenuId, licenseManager.ProjectId, null, licenseManager.LicenseManagerId, licenseManager.CompileDate);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改安全许可证
|
|
/// </summary>
|
|
/// <param name="licenseManager"></param>
|
|
public static void UpdateLicenseManager(Model.License_LicenseManager licenseManager)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.License_LicenseManager newLicenseManager = db.License_LicenseManager.FirstOrDefault(e => e.LicenseManagerId == licenseManager.LicenseManagerId);
|
|
if (newLicenseManager != null)
|
|
{
|
|
newLicenseManager.LicenseTypeId = licenseManager.LicenseTypeId;
|
|
newLicenseManager.LicenseManagerCode = licenseManager.LicenseManagerCode;
|
|
newLicenseManager.LicenseManageName = licenseManager.LicenseManageName;
|
|
newLicenseManager.UnitId = licenseManager.UnitId;
|
|
newLicenseManager.LicenseManageContents = licenseManager.LicenseManageContents;
|
|
newLicenseManager.ApplicantMan = licenseManager.ApplicantMan;
|
|
newLicenseManager.CompileDate = licenseManager.CompileDate;
|
|
newLicenseManager.States = licenseManager.States;
|
|
newLicenseManager.WorkAreaId = licenseManager.WorkAreaId;
|
|
newLicenseManager.StartDate = licenseManager.StartDate;
|
|
newLicenseManager.EndDate = licenseManager.EndDate;
|
|
newLicenseManager.WorkStates = licenseManager.WorkStates;
|
|
newLicenseManager.IsUpdate = null;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键删除安全许可证
|
|
/// </summary>
|
|
/// <param name="licenseManagerId"></param>
|
|
public static void DeleteLicenseManagerById(string licenseManagerId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.License_LicenseManager licenseManager = db.License_LicenseManager.FirstOrDefault(e => e.LicenseManagerId == licenseManagerId);
|
|
if (licenseManager != null)
|
|
{
|
|
///删除编码表记录
|
|
BLL.CodeRecordsService.DeleteCodeRecordsByDataId(licenseManagerId);
|
|
BLL.CommonService.DeleteAttachFileById(licenseManagerId);//删除附件
|
|
///删除工程师日志收集记录
|
|
var flowOperate = from x in db.Sys_FlowOperate where x.DataId == licenseManager.LicenseManagerId select x;
|
|
if (flowOperate.Count() > 0)
|
|
{
|
|
BLL.CommonService.DeleteFlowOperateByID(licenseManager.LicenseManagerId); ////删除审核流程表
|
|
}
|
|
db.License_LicenseManager.DeleteOnSubmit(licenseManager);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
}
|