603 lines
24 KiB
C#
603 lines
24 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Net;
|
||
using System.Net.Http;
|
||
using System.Web.Http;
|
||
using BLL;
|
||
using Model;
|
||
|
||
namespace WebAPI.Controllers.DataPenetrate
|
||
{
|
||
/// <summary>
|
||
/// 安全监督检查数据Api控制器
|
||
/// </summary>
|
||
public class CheckPenetrateController : ApiController
|
||
{
|
||
#region 企业级安全监督检查报告
|
||
/// <summary>
|
||
/// 保存企业级安全监督检查报告
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData SaveSuperviseCheckReport([FromBody] Model.Supervise_SuperviseCheckReport model)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
#region 判断是否未填
|
||
if (string.IsNullOrEmpty(model.SuperviseCheckReportCode))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "检查编号(SuperviseCheckReportCode)不能为空";
|
||
return responeData;
|
||
}
|
||
if (string.IsNullOrEmpty(model.CheckType))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "检查类别(CheckType)不能为空";
|
||
return responeData;
|
||
}
|
||
if (string.IsNullOrEmpty(model.ProjectId))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "项目id(ProjectId)不能为空";
|
||
return responeData;
|
||
}
|
||
else
|
||
{
|
||
//判断projectid是否有数据
|
||
var pmodel = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == model.ProjectId);
|
||
if (pmodel == null)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "检查对象项目id(ProjectId)未查询到数据,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
}
|
||
if (string.IsNullOrEmpty(model.UnitId))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "单位id(UnitId)不能为空";
|
||
return responeData;
|
||
}
|
||
else
|
||
{
|
||
//判断userid是否有数据
|
||
var umodel = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == model.UnitId);
|
||
if (umodel == null)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "单位id(UnitId)未查询到数据,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
}
|
||
#endregion
|
||
if (string.IsNullOrEmpty(model.SuperviseCheckReportId))
|
||
{
|
||
model.SuperviseCheckReportId = SQLHelper.GetNewID(typeof(Model.Supervise_SuperviseCheckReport));
|
||
BLL.SuperviseCheckReportService.AddSuperviseCheckReport(model);
|
||
responeData.message = "保存成功";
|
||
}
|
||
else
|
||
{
|
||
var pmodel = Funs.DB.Supervise_SuperviseCheckReport.FirstOrDefault(x => x.SuperviseCheckReportId == model.SuperviseCheckReportId);
|
||
if (pmodel == null)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "检查id(SuperviseCheckReportId)未查询到数据,无法修改,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
|
||
var report = BLL.SuperviseCheckReportService.GetSuperviseCheckReportById(model.SuperviseCheckReportId);
|
||
if (report.IsIssued == "1") //已下发
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "已下发检查整改,无法修改!";
|
||
return responeData;
|
||
}
|
||
BLL.SuperviseCheckReportService.UpdateSuperviseCheckReport(model);
|
||
BLL.SuperviseCheckReportItemService.DeleteSuperviseCheckReportItemBySuperviseCheckReportId(model.SuperviseCheckReportId);
|
||
responeData.message = "修改成功";
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 领导带班检查(项目负责人带班检查)
|
||
/// <summary>
|
||
/// 保存项目负责人带班检查
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData SaveCheck_ProjectLeaderCheck([FromBody] Model.Check_ProjectLeaderCheck model)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
#region 判断是否未填
|
||
if (string.IsNullOrEmpty(model.CheckCode))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "编号(CheckCode)不能为空";
|
||
return responeData;
|
||
}
|
||
if (string.IsNullOrEmpty(model.UnitIds))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "责任单位(UnitIds)不能为空";
|
||
return responeData;
|
||
}
|
||
if (string.IsNullOrEmpty(model.LeaderIds))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "带班领导(LeaderIds)不能为空";
|
||
return responeData;
|
||
}
|
||
if (string.IsNullOrEmpty(model.ProjectId))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "项目id(ProjectId)不能为空";
|
||
return responeData;
|
||
}
|
||
else
|
||
{
|
||
//判断projectid是否有数据
|
||
var pmodel = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == model.ProjectId);
|
||
if (pmodel == null)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "项目id(ProjectId)未查询到数据,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
if (string.IsNullOrEmpty(model.ProjectLeaderCheckId))
|
||
{
|
||
model.ProjectLeaderCheckId = SQLHelper.GetNewID(typeof(Model.Supervise_SuperviseCheckReport));
|
||
BLL.Check_ProjectLeaderCheckService.AddProjectLeaderCheck(model);
|
||
responeData.message = "保存成功";
|
||
}
|
||
else
|
||
{
|
||
var pmodel = Funs.DB.Check_ProjectLeaderCheck.FirstOrDefault(x => x.ProjectLeaderCheckId == model.ProjectLeaderCheckId);
|
||
if (pmodel == null)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "主键(ProjectLeaderCheckId)未查询到数据,无法修改,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
BLL.Check_ProjectLeaderCheckService.UpdateProjectLeaderCheck(model);
|
||
|
||
responeData.message = "修改成功";
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region HSE日常巡检(项目专业检查)
|
||
/// <summary>
|
||
/// 保存项目专业检查
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData SaveHSSE_Hazard_HazardRegister([FromBody] Model.HSSE_Hazard_HazardRegister model)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
#region 判断是否未填
|
||
if (string.IsNullOrEmpty(model.RegisterTypesId))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "检查项ID(RegisterTypesId)不能为空";
|
||
return responeData;
|
||
}
|
||
else {
|
||
var pmodel = Funs.DB.HSSE_Hazard_HazardRegisterTypes.FirstOrDefault(x => x.RegisterTypesId == model.RegisterTypesId);
|
||
if (pmodel == null)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "检查项ID(RegisterTypesId)未查询到数据,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
}
|
||
if (string.IsNullOrEmpty(model.RegisterDef))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "问题描述(RegisterDef)不能为空";
|
||
return responeData;
|
||
}
|
||
if (string.IsNullOrEmpty(model.ResponsibleMan))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "责任人(ResponsibleMan)不能为空";
|
||
return responeData;
|
||
}
|
||
else {
|
||
//判断projectid是否有数据
|
||
var pmodel = Funs.DB.Sys_User.FirstOrDefault(x => x.UserId == model.ResponsibleMan);
|
||
if (pmodel == null)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "责任人(ResponsibleMan)未查询到数据,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
}
|
||
if (string.IsNullOrEmpty(model.CheckManId))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "检查人(CheckManId)不能为空";
|
||
return responeData;
|
||
}
|
||
else {
|
||
//判断projectid是否有数据
|
||
var pmodel = Funs.DB.Sys_User.FirstOrDefault(x => x.UserId == model.CheckManId);
|
||
if (pmodel == null)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "检查人(CheckManId)未查询到数据,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
}
|
||
if (string.IsNullOrEmpty(model.CheckTime.ToString()))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "检查时间(CheckTime)不能为空";
|
||
return responeData;
|
||
}
|
||
if (string.IsNullOrEmpty(model.ProjectId))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "项目id(ProjectId)不能为空";
|
||
return responeData;
|
||
}
|
||
else
|
||
{
|
||
//判断projectid是否有数据
|
||
var pmodel = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == model.ProjectId);
|
||
if (pmodel == null)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "项目id(ProjectId)未查询到数据,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
model.IsEffective = "1";
|
||
model.States = "1"; //待整改
|
||
if (string.IsNullOrEmpty(model.HazardRegisterId))
|
||
{
|
||
model.HazardRegisterId = SQLHelper.GetNewID(typeof(Model.HSSE_Hazard_HazardRegister));
|
||
BLL.HSSE_Hazard_HazardRegisterService.UpdateHazardRegister(model);
|
||
responeData.message = "保存成功";
|
||
}
|
||
else
|
||
{
|
||
var pmodel = Funs.DB.HSSE_Hazard_HazardRegister.FirstOrDefault(x => x.HazardRegisterId == model.HazardRegisterId);
|
||
if (pmodel == null)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "主键(HazardRegisterId)未查询到数据,无法修改,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
BLL.HSSE_Hazard_HazardRegisterService.UpdateHazardRegister(model);
|
||
|
||
responeData.message = "修改成功";
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 专项检查(项目专项检查)
|
||
public class Check_CheckSpecialNew
|
||
{
|
||
public string CheckSpecialId { get; set; }
|
||
|
||
public string ProjectId { get; set; }
|
||
public string UnitId { get; set; }
|
||
public string CheckType { get; set; }
|
||
public string CheckItemSetId { get; set; }
|
||
public DateTime CheckTime { get; set; }
|
||
public string PartInPersonIds { get; set; }
|
||
public string PartInPersons { get; set; }
|
||
public string PartInPersonNames { get; set; }
|
||
public string CompileMan { get; set; }
|
||
|
||
public string CheckSpecialCode { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 保存专项检查
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData SaveCheck_CheckSpecial([FromBody] Check_CheckSpecialNew model)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
#region 判断是否未填
|
||
if (string.IsNullOrEmpty(model.UnitId))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "单位Id(UnitId)不能为空";
|
||
return responeData;
|
||
}
|
||
else
|
||
{
|
||
//判断userid是否有数据
|
||
var umodel = Funs.DB.Base_Unit.Where(x => x.UnitId == model.UnitId).ToList();
|
||
if (umodel.Count == 0)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "单位id未查询到数据,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
}
|
||
if (string.IsNullOrEmpty(model.ProjectId))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "项目id(ProjectId)不能为空";
|
||
return responeData;
|
||
}
|
||
else
|
||
{
|
||
//判断projectid是否有数据
|
||
var pmodel = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == model.ProjectId);
|
||
if (pmodel == null)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "项目id未查询到数据,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
}
|
||
var panduan = "0123";
|
||
if (string.IsNullOrEmpty(model.CheckType))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "检查类型(CheckType)不能为空";
|
||
return responeData;
|
||
}
|
||
else if (panduan.IndexOf(model.CheckType)<0)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "检查类型(CheckType)必须为0,1,2,3中的一个。";
|
||
return responeData;
|
||
}
|
||
if (string.IsNullOrEmpty(model.CheckItemSetId))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "检查类别(CheckItemSetId)不能为空";
|
||
return responeData;
|
||
}
|
||
else {
|
||
var getCheckItem = Funs.DB.Technique_CheckItemSet.FirstOrDefault(x => x.CheckItemSetId == model.CheckItemSetId);
|
||
if (getCheckItem == null)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "检查类别(CheckItemSetId)未查询到数据,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
}
|
||
if (string.IsNullOrEmpty(model.CheckTime.ToString()))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "检查日期(CheckTime)不能为空";
|
||
return responeData;
|
||
}
|
||
if (string.IsNullOrEmpty(model.CompileMan))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "编制人Userid(CompileMan)不能为空";
|
||
return responeData;
|
||
}
|
||
else {
|
||
//判断是否有数据
|
||
var pmodel = Funs.DB.Sys_User.FirstOrDefault(x => x.UserId == model.CompileMan);
|
||
if (pmodel == null)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "编制人Userid未查询到数据,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
//自动生成编码
|
||
model.CheckSpecialCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectCheckSpecialMenuId, model.ProjectId, model.UnitId);
|
||
Check_CheckSpecial models = new Check_CheckSpecial()
|
||
{
|
||
ProjectId = model.ProjectId,
|
||
CheckType = model.CheckType,
|
||
CheckItemSetId = model.CheckItemSetId,
|
||
CheckTime = model.CheckTime,
|
||
PartInPersonIds = model.PartInPersonIds,
|
||
PartInPersons = model.PartInPersons,
|
||
PartInPersonNames = model.PartInPersonNames,
|
||
CompileMan = model.CompileMan,
|
||
CheckSpecialCode = model.CheckSpecialCode
|
||
};
|
||
if (string.IsNullOrEmpty(model.CheckSpecialId))
|
||
{
|
||
models.CheckSpecialId = SQLHelper.GetNewID(typeof(Model.Check_CheckSpecial));
|
||
|
||
Check_CheckSpecialService.AddCheckSpecial(models);
|
||
responeData.message = "保存成功";
|
||
}
|
||
else
|
||
{
|
||
models.CheckSpecialId = model.CheckSpecialId;
|
||
var pmodel = Funs.DB.Check_CheckSpecial.FirstOrDefault(x => x.CheckSpecialId == model.CheckSpecialId);
|
||
if (pmodel == null)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "主键(CheckSpecialId)未查询到数据,无法修改,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
Check_CheckSpecialService.UpdateCheckSpecial(models);
|
||
|
||
responeData.message = "修改成功";
|
||
}
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 安全巡检类型查询
|
||
/// <summary>
|
||
/// 安全巡检类型查询
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getHazardRegisterTypesInfo()
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
var getDataList = Funs.DB.HSSE_Hazard_HazardRegisterTypes.Where(x => x.HazardRegisterType == "1")
|
||
.Select(x=> new HazardRegisterTypesModel {
|
||
RegisterTypesId=x.RegisterTypesId,
|
||
RegisterTypesName=x.RegisterTypesName
|
||
}).ToList();
|
||
|
||
responeData.data = new { getDataList };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
/// <summary>
|
||
/// 安全巡检类型查询查询返回实体类
|
||
/// </summary>
|
||
public class HazardRegisterTypesModel {
|
||
public string RegisterTypesId { get; set; }
|
||
public string RegisterTypesName { get; set; }
|
||
}
|
||
#endregion
|
||
|
||
#region 安全巡检类型保存
|
||
/// <summary>
|
||
/// 安全巡检类型保存
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData saveHazardRegisterTypes([FromBody] Model.HSSE_Hazard_HazardRegisterTypes model)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
#region 判断是否未填
|
||
if (string.IsNullOrEmpty(model.RegisterTypesName))
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "类型名称(RegisterTypesName)不能为空";
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
model.HazardRegisterType = "1"; //安全巡检类型
|
||
if (string.IsNullOrEmpty(model.RegisterTypesId))
|
||
{
|
||
model.RegisterTypesId = SQLHelper.GetNewID(typeof(Model.HSSE_Hazard_HazardRegisterTypes));
|
||
BLL.HSSE_Hazard_HazardRegisterTypesService.AddHazardRegisterTypes(model);
|
||
responeData.message = "保存成功";
|
||
}
|
||
else
|
||
{
|
||
var pmodel = Funs.DB.HSSE_Hazard_HazardRegisterTypes.FirstOrDefault(x => x.RegisterTypesId == model.RegisterTypesId);
|
||
if (pmodel == null)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = "主键ID(RegisterTypesId)未查询到数据,无法修改,请检查是否正确。";
|
||
return responeData;
|
||
}
|
||
|
||
BLL.HSSE_Hazard_HazardRegisterTypesService.UpdateHazardRegisterTypes(model);
|
||
responeData.message = "修改成功";
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 检查类别查询
|
||
/// <summary>
|
||
/// 安全巡检类型查询
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getTechnique_CheckItemSetInfo()
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
var getDataList = Funs.DB.Technique_CheckItemSet.Where(x => x.CheckType == "2"&&x.SupCheckItem=="0").Select(x=>new Technique_CheckItemModel {
|
||
CheckItemSetId=x.CheckItemSetId,
|
||
CheckItemName=x.CheckItemName
|
||
} ).ToList();
|
||
|
||
responeData.data = new { getDataList };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 安全巡检类型查询返回实体类
|
||
/// </summary>
|
||
public class Technique_CheckItemModel {
|
||
public string CheckItemSetId { get; set; }
|
||
public string CheckItemName { get; set; }
|
||
}
|
||
#endregion
|
||
}
|
||
} |