CNCEC_SUBQHSE_WUHUAN/SGGL/BLL/HSSE/Check/Check_CheckSpecialProServic...

319 lines
15 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace BLL
{
/// <summary>
/// 专项检查
/// </summary>
public static class Check_CheckSpecialProService
{
/// <summary>
/// 根据专项检查ID获取专项检查信息
/// </summary>
/// <param name="CheckSpecialName"></param>
/// <returns></returns>
public static Model.Check_CheckSpecialPro GetCheckSpecialByCheckSpecialId(string checkSpecialId)
{
return Funs.DB.Check_CheckSpecialPro.FirstOrDefault(e => e.CheckSpecialId == checkSpecialId);
}
/// <summary>
/// 根据时间段获取专项检查信息集合
/// </summary>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <param name="projectId"></param>
/// <returns></returns>
public static int GetCountByCheckTime(DateTime startTime, DateTime endTime, string projectId)
{
return (from x in Funs.DB.Check_CheckSpecialPro where x.CheckTime >= startTime && x.CheckTime < endTime && x.ProjectId == projectId select x).Count();
}
/// <summary>
/// 根据时间段获取专项检查集合
/// </summary>
/// <param name="startTime">开始时间</param>
/// <param name="endTime">结束时间</param>
/// <param name="projectId">项目号</param>
/// <returns>专项检查集合</returns>
public static List<Model.Check_CheckSpecialPro> GetListByCheckTime(DateTime startTime, DateTime endTime, string projectId)
{
return (from x in Funs.DB.Check_CheckSpecialPro where x.CheckTime >= startTime && x.CheckTime < endTime && x.ProjectId == projectId select x).ToList();
}
/// <summary>
/// 根据时间段获取已完成的专项检查整改数量
/// </summary>
/// <param name="startTime">开始时间</param>
/// <param name="endTime">结束时间</param>
/// <param name="projectId">项目号</param>
/// <returns>已完成的专项检查整改数量</returns>
public static int GetIsOKViolationCountByCheckTime(DateTime startTime, DateTime endTime, string projectId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
return (from x in db.Check_CheckSpecialPro
join y in db.Check_CheckSpecialProDetail on x.CheckSpecialId equals y.CheckSpecialId
where x.CheckTime >= startTime && x.CheckTime <= endTime && x.ProjectId == projectId && y.CompleteStatus != null && y.CompleteStatus == true
select y).Count();
}
}
/// <summary>
/// 添加安全专项检查
/// </summary>
/// <param name="checkSpecial"></param>
public static void AddCheckSpecial(Model.Check_CheckSpecialPro checkSpecial)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Model.Check_CheckSpecialPro newCheckSpecial = new Model.Check_CheckSpecialPro
{
CheckSpecialId = checkSpecial.CheckSpecialId,
CheckSpecialCode = checkSpecial.CheckSpecialCode,
ProjectId = checkSpecial.ProjectId,
CheckPerson = checkSpecial.CheckPerson,
CheckTime = checkSpecial.CheckTime,
ScanUrl = checkSpecial.ScanUrl,
DaySummary = checkSpecial.DaySummary,
PartInUnits = checkSpecial.PartInUnits,
PartInPersons = checkSpecial.PartInPersons,
PartInPersonIds = checkSpecial.PartInPersonIds,
PartInPersonNames = checkSpecial.PartInPersonNames,
CheckAreas = checkSpecial.CheckAreas,
States = checkSpecial.States,
CompileMan = checkSpecial.CompileMan,
CheckType = checkSpecial.CheckType,
CheckItemSetId = checkSpecial.CheckItemSetId,
};
db.Check_CheckSpecialPro.InsertOnSubmit(newCheckSpecial);
db.SubmitChanges();
}
////增加一条编码记录
BLL.CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(BLL.Const.ProjectCheckSpecialMenuId, checkSpecial.ProjectId, null, checkSpecial.CheckSpecialId, checkSpecial.CheckTime);
}
/// <summary>
/// 修改安全专项检查
/// </summary>
/// <param name="checkSpecial"></param>
public static void UpdateCheckSpecial(Model.Check_CheckSpecialPro checkSpecial)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Model.Check_CheckSpecialPro newCheckSpecial = db.Check_CheckSpecialPro.FirstOrDefault(e => e.CheckSpecialId == checkSpecial.CheckSpecialId);
if (newCheckSpecial != null)
{
newCheckSpecial.CheckSpecialCode = checkSpecial.CheckSpecialCode;
//newCheckSpecial.ProjectId = checkSpecial.ProjectId;
newCheckSpecial.CheckPerson = checkSpecial.CheckPerson;
newCheckSpecial.CheckTime = checkSpecial.CheckTime;
newCheckSpecial.ScanUrl = checkSpecial.ScanUrl;
newCheckSpecial.DaySummary = checkSpecial.DaySummary;
newCheckSpecial.PartInUnits = checkSpecial.PartInUnits;
newCheckSpecial.PartInPersons = checkSpecial.PartInPersons;
newCheckSpecial.PartInPersonIds = checkSpecial.PartInPersonIds;
newCheckSpecial.PartInPersonNames = checkSpecial.PartInPersonNames;
newCheckSpecial.CheckAreas = checkSpecial.CheckAreas;
newCheckSpecial.States = checkSpecial.States;
newCheckSpecial.CheckType = checkSpecial.CheckType;
newCheckSpecial.CheckItemSetId = checkSpecial.CheckItemSetId;
db.SubmitChanges();
}
}
}
/// <summary>
/// 根据专项检查ID 更新专项检查状态
/// </summary>
/// <param name="checkSpecialDetailId"></param>
public static void UpdateCheckSpecialStates(string checkSpecialId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var getS = db.Check_CheckSpecialPro.FirstOrDefault(x => x.CheckSpecialId == checkSpecialId);
if (getS != null && getS.States == Const.State_1)
{
var getNCDetail = Funs.DB.Check_CheckSpecialProDetail.FirstOrDefault(x => x.CheckSpecialId == getS.CheckSpecialId && x.CompleteStatus == false);
if (getNCDetail == null)
{
getS.States = Const.State_2;
db.SubmitChanges();
}
}
}
}
/// <summary>
/// 根据专项检查ID删除对应专项检查记录信息
/// </summary>
/// <param name="superviseCheckReportId"></param>
public static void DeleteCheckSpecial(string checkSpecialId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var q = (from x in db.Check_CheckSpecialPro where x.CheckSpecialId == checkSpecialId select x).FirstOrDefault();
if (q != null)
{
///删除编码表记录
BLL.CodeRecordsService.DeleteCodeRecordsByDataId(q.CheckSpecialId);
////删除附件表
BLL.CommonService.DeleteAttachFileById(q.CheckSpecialId);
////删除审核流程表
BLL.CommonService.DeleteFlowOperateByID(q.CheckSpecialId);
db.Check_CheckSpecialPro.DeleteOnSubmit(q);
db.SubmitChanges();
}
}
}
/// <summary>
///
/// </summary>
/// <param name="CheckSpecialDetailId"></param>
/// <returns></returns>
public static string ConvertHandleStep(object CheckSpecialDetailId)
{
string name = string.Empty;
if (CheckSpecialDetailId != null)
{
var getDetail = BLL.Check_CheckSpecialProDetailService.GetCheckSpecialDetailByCheckSpecialDetailId(CheckSpecialDetailId.ToString());
if (getDetail != null)
{
if (getDetail.DataType == "1")
{
name = "下发整改单:";
var getRe = RectifyNoticesService.GetRectifyNoticesById(getDetail.DataId);
if (getRe != null)
{
name += getRe.RectifyNoticesCode;
}
}
else if (getDetail.DataType == "2")
{
name = "下发处罚单:";
var getRe = PunishNoticeService.GetPunishNoticeById(getDetail.DataId);
if (getRe != null)
{
name += getRe.PunishNoticeCode;
}
}
else if (getDetail.DataType == "3")
{
name = "下发暂停令:";
var getRe = Check_PauseNoticeService.GetPauseNoticeByPauseNoticeId(getDetail.DataId);
if (getRe != null)
{
name += getRe.PauseNoticeCode;
}
}
}
}
return name;
}
/// <summary>
///
/// </summary>
/// <param name="detailLists"></param>
/// <param name="checkSpecial"></param>
/// <returns></returns>
public static string IssueRectification(List<Model.Check_CheckSpecialProDetail> detailLists, Model.Check_CheckSpecialPro checkSpecial)
{
string info = string.Empty;
if (detailLists.Count() > 0 && checkSpecial != null)
{
////隐患整改单
var getDetail1 = detailLists.Where(x => x.CompleteStatus == false);
if (getDetail1.Count() > 0)
{
var getUnitList = getDetail1.Select(x => x.UnitId).Distinct();
foreach (var unitItem in getUnitList)
{
var getUnitItemList = getDetail1.Where(x => x.UnitId == unitItem);
foreach (var item in getUnitItemList)
{
Model.HSSE_Hazard_HazardRegister register = Funs.DB.HSSE_Hazard_HazardRegister.FirstOrDefault(x => x.CheckItemDetailId == item.CheckSpecialDetailId);
if (register == null)
{
register = new Model.HSSE_Hazard_HazardRegister();
}
register.ProjectId = checkSpecial.ProjectId;
register.CheckItemDetailId = item.CheckSpecialDetailId;
register.ProblemTypes = "2"; //1 安全问题 2 专项巡检
register.Type = 0;//0日常巡检、1;常规巡检
register.RegisterTypesId = item.CheckItem;
// register.CheckCycle = this.ckType.SelectedValue;
register.IsEffective = "1";
register.RegisterDate = checkSpecial.CheckTime;
register.CheckTime = checkSpecial.CheckTime;
register.ResponsibleUnit = item.UnitId;
// register.Place = item.WorkArea;
register.Place = item.CheckArea;
register.RegisterDef = item.Unqualified;
// register.HandleIdea = item.Suggestions;
register.ResponsibleMan = item.HSEManage;
// register.Risk_Level = item.RiskLevel;
switch (item.RiskLevel)
{
//case "0": register.Risk_Level = "一般"; break;
case "1": register.Risk_Level = "一般"; break;
case "2": register.Risk_Level = "较大"; break;
case "3": register.Risk_Level = "重大"; break;
default: register.Risk_Level = "一般"; break;
}
register.Requirements = item.Suggestions;
register.CheckSpecialId = item.CheckSpecialId;
register.RectificationPeriod = item.LimitedDate;
register.CheckManId = checkSpecial.CompileMan;
//register.CutPayment = Funs.GetNewIntOrZero(this.txtCutPayment.Text.Trim());
register.States = "1"; //待整改
if (string.IsNullOrEmpty(register.HazardRegisterId))
{
register.HazardRegisterId = Guid.NewGuid().ToString();
var url = AttachFileService.getFileUrl(item.CheckSpecialDetailId);
register.ImageUrl = url;
SaveAttachFile(register.HazardRegisterId, BLL.Const.HSSE_HiddenRectificationListMenuId, url);
BLL.HSSE_Hazard_HazardRegisterService.AddHazardRegister(register);
}
else
{
var url = AttachFileService.getFileUrl(item.CheckSpecialDetailId);
register.ImageUrl = url;
SaveAttachFile(register.HazardRegisterId, BLL.Const.HSSE_HiddenRectificationListMenuId, url);
BLL.HSSE_Hazard_HazardRegisterService.UpdateHazardRegister(register);
}
}
}
info += "整改已下发。";
}
Check_CheckSpecialProService.UpdateCheckSpecial(checkSpecial);
}
if (!string.IsNullOrEmpty(info))
{
info += "请在相应办理页面提交!";
}
return info;
}
public static void SaveAttachFile(string dataId, string menuId, string url)
{
Model.ToDoItem toDoItem = new Model.ToDoItem
{
MenuId = menuId,
DataId = dataId,
UrlStr = url,
};
APIUpLoadFileService.SaveAttachUrl(toDoItem);
}
}
}