提交代码

This commit is contained in:
2025-03-10 11:08:30 +08:00
13 changed files with 2993 additions and 6 deletions
+47
View File
@@ -0,0 +1,47 @@
using System;
using System.Data.SqlClient;
namespace WebAPI.Helpers
{
public class DatabaseHelper : IDisposable
{
private SqlConnection _sqlConnection;
private bool _disposed = false;
public DatabaseHelper(string connectionString)
{
_sqlConnection = new SqlConnection(connectionString);
_sqlConnection.Open();
}
public SqlConnection GetConnection()
{
return _sqlConnection;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
// 释放托管资源
if (_sqlConnection != null)
{
_sqlConnection.Close();
_sqlConnection.Dispose();
_sqlConnection = null;
}
}
// 释放非托管资源
_disposed = true;
}
}
}
}
@@ -40,7 +40,9 @@ namespace WebAPI.Controllers.HSSE
var responeData = new Model.ResponeData();
try
{
responeData.data = AwardStandardsService.GetAwardStandardsListById(AwardStandardsId);
var data = AwardStandardsService.GetAwardStandardsListById(AwardStandardsId);
data.AttachUrl = BLL.AttachFileService.getFileUrl(data.AwardStandardsId);
responeData.data = data;
}
catch (Exception ex)
{
@@ -40,7 +40,9 @@ namespace WebAPI.Controllers.HSSE
var responeData = new Model.ResponeData();
try
{
responeData.data = ConstructionStandardsService.GetConstructionStandardsListById(ConstructionStandardsId);
var data = ConstructionStandardsService.GetConstructionStandardsListById(ConstructionStandardsId);
data.AttachUrl = BLL.AttachFileService.getFileUrl(data.ConstructionStandardsId);
responeData.data = data;
}
catch (Exception ex)
{
@@ -39,7 +39,9 @@ namespace WebAPI.Controllers.HSSE
var responeData = new Model.ResponeData();
try
{
responeData.data = ProtectionStandardsService.GetProtectionStandardsListById(ProtectionStandardsId);
var data = ProtectionStandardsService.GetProtectionStandardsListById(ProtectionStandardsId);
data.AttachUrl = BLL.AttachFileService.getFileUrl(data.ProtectionStandardsId);
responeData.data = data;
}
catch (Exception ex)
{
@@ -0,0 +1,264 @@
using BLL;
using System;
using System.Linq;
using System.Web.Http;
using BLL.OfficeCheck.Inspect;
using Model;
using static BLL.OfficeCheck.Inspect.Inspect_InspectionService;
using System.Collections.Generic;
namespace WebAPI.Controllers.HSSE
{
public class SafetyInspectionController : ApiController
{
//新增
/// <summary>
/// 编辑 保存
/// </summary>
/// <param name="trainingPlan">安全专检</param>
[HttpPost]
public Model.ResponeData Save([FromBody] Model.Inspect_Inspection Inspection)
{
var responeData = new Model.ResponeData();
try
{
if (string.IsNullOrEmpty(Inspection.InspectionId))
{
Inspection.InspectionId = Guid.NewGuid().ToString();
Inspection.CreateTime = DateTime.Now;
Inspect_InspectionService.AddInspection(Inspection);
}
else
{
Inspect_InspectionService.UpdateInspection(Inspection);
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
//查询
public Model.ResponeData getList(string ProjectId,string States,string PersonResponsible, int PageNumber, int PageSize)
{
var responeData = new Model.ResponeData();
try
{
responeData.data = Inspect_InspectionService.GetInspectionList(ProjectId,States,PersonResponsible,PageNumber,PageSize);
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
//专检明细
public Model.ResponeData getInspectionById(string InspectionId)
{
var responeData = new Model.ResponeData();
try
{
var getDataLists = (from x in Funs.DB.Inspect_Inspection
join user in Funs.DB.Sys_User on x.InspectMan equals user.UserId into userJoin1
from subUser1 in userJoin1.DefaultIfEmpty()
join user in Funs.DB.Sys_User on x.CreateMan equals user.UserId into userJoin2
from subUser2 in userJoin2.DefaultIfEmpty()
join user in Funs.DB.Sys_User on x.PersonResponsible equals user.UserId into userJoin3
from subUser3 in userJoin3.DefaultIfEmpty()
join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into project
from pro in project.DefaultIfEmpty()
where x.InspectionId == InspectionId
select new InspectionDto
{
InspectionId = x.InspectionId,
InspectionCode = x.InspectionCode,
ProjectId = x.ProjectId,
ProjectName = pro.ProjectName,
PersonResponsible = x.PersonResponsible,
PersonResponsibleName = subUser3.UserName,
InspectTime = x.InspectTime,
Description = x.Description,
States = x.States,
InspectMan = subUser1.UserName,
InspectManId = x.InspectMan,
InspectType = x.InspectType,
InspectItemSetId = x.InspectItemSetId,
CreateMan = subUser2.UserName,
CreateTime = x.CreateTime,
}).FirstOrDefault();
responeData.data = getDataLists;
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
//项目负责人下拉
public Model.ResponeData getPersonResponsibleList(string ProjectId)
{
var responeData = new Model.ResponeData();
try
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var users = (from x in db.Sys_User
where x.IsPost == true && x.UserId != Const.hfnbdId && x.UserId != Const.sedinId
orderby x.UserName
select new UserDto
{
UserId = x.UserId,
UserName = x.UserName,
}).ToList();
if (!string.IsNullOrEmpty(ProjectId))
{
users = (from x in users
join y in db.Project_ProjectUser on x.UserId equals y.UserId
where y.ProjectId == ProjectId
orderby x.UserName
select new UserDto
{
UserId = x.UserId,
UserName = x.UserName,
}).ToList();
}
responeData.data = users;
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
public class UserDto
{
public string UserId
{
get;
set;
}
public string UserName
{
get;
set;
}
}
//专检明细
public Model.ResponeData getInspectItemsByInspectionId(string InspectionId, int PageNumber, int PageSize)
{
var responeData = new Model.ResponeData();
try
{
responeData.data = Inspect_InspectionService.GetInspectionItemList(InspectionId,PageNumber,PageSize);
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
//编辑 新增明细
[HttpPost]
public Model.ResponeData SaveInspectionItem([FromBody] List<Model.Inspect_InspectionItem> InspectionItems)
{
var responeData = new Model.ResponeData();
try
{
foreach (var InspectionItem in InspectionItems)
{
if (string.IsNullOrEmpty(InspectionItem.InspectionItemId))
{
InspectionItem.InspectionItemId = Guid.NewGuid().ToString();
InspectionItem.CompileTime = DateTime.Now;
Inspect_InspectionService.AddInspectionItem(InspectionItem);
}
else
{
Inspect_InspectionService.UpdateInspectionItem(InspectionItem);
}
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
//专检子表明细
public Model.ResponeData getInspectItemsById(string InspectionItemId)
{
var responeData = new Model.ResponeData();
try
{
var getDataLists = (from x in Funs.DB.Inspect_InspectionItem
join user in Funs.DB.Sys_User on x.CompileMan equals user.UserId into userJoin1
from subUser1 in userJoin1.DefaultIfEmpty()
join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into project
from pro in project.DefaultIfEmpty()
where x.InspectionItemId == InspectionItemId
select new InspectionItemDto
{
InspectionItemId = x.InspectionItemId,
InspectionId = x.InspectionId,
InspectionItemCode = x.InspectionItemCode,
ProjectId = x.ProjectId,
ProjectName = pro.ProjectName,
InspectionDescribe = x.InspectionDescribe,
PhotoUrl = x.PhotoUrl,
VideoUrl = x.VideoUrl,
EvaluateResults = x.EvaluateResults,
TimeLimited = x.TimeLimited,
RectificationDescription = x.RectificationDescription,
RectificationResults = x.RectificationResults,
States = x.States,
CompileMan = subUser1.UserName,
CompileTime = x.CompileTime,
}).FirstOrDefault();
responeData.data = getDataLists;
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
}
@@ -40,7 +40,9 @@ namespace WebAPI.Controllers.HSSE
var responeData = new Model.ResponeData();
try
{
responeData.data = SafetyResponsibilitiesService.GetSafetyResponsibilitiesListById(SafetyResponsibilitiesId);
var data = SafetyResponsibilitiesService.GetSafetyResponsibilitiesListById(SafetyResponsibilitiesId);
data.AttachUrl = BLL.AttachFileService.getFileUrl(data.SafetyResponsibilitiesId);
responeData.data = data;
}
catch (Exception ex)
{
File diff suppressed because it is too large Load Diff