Files
xinjiang/SGGL/FineUIPro.Web/Check/HSE/CheckProblemEdit.aspx.cs
T
2026-11-19 16:31:11 +08:00

565 lines
24 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 BLL;
using Model;
using System;
namespace FineUIPro.Web.Check.HSE
{
public partial class CheckProblemEdit : PageBase
{
#region 公共字段
/// <summary>
/// 主键
/// </summary>
public string CheckId
{
get
{
return (string)ViewState["CheckId"];
}
set
{
ViewState["CheckId"] = value;
}
}
#endregion
/// <summary>
/// 图片是否可以编辑 -1查看 0编辑
/// </summary>
public int QuestionImg
{
get
{
return Convert.ToInt32(ViewState["QuestionImg"]);
}
set
{
ViewState["QuestionImg"] = value;
}
}
/// <summary>
/// 页面初始化加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CheckId = Request.Params["CheckId"];
this.InitDropDownList();
var model = CheckProblemSafetyService.GetCheckProblemById(this.CheckId);
if (model != null)
{
if (!string.IsNullOrWhiteSpace(model.UnitId))
{
this.drpUnit.SelectedValue = model.UnitId;
this.drpRectificationUser.Items.Clear();
//BLL.UserService.InitUserUnitIdDropDownList(this.drpRectificationUser, model.UnitId, true);
this.drpPMUser.Items.Clear();
BLL.UserService.InitUserUnitIdDropDownList(this.drpPMUser, model.UnitId, true);
BLL.ProjectService.InitProjectDropDownList(this.drpProject, model.UnitId, true);
}
if (!string.IsNullOrWhiteSpace(model.ProjectId))
{
this.drpProject.SelectedValue = model.ProjectId;
var pro = BLL.ProjectService.GetProjectByProjectId(model.ProjectId);
this.txtAddress.Text = pro.ProjectAddress;
this.drpRectificationUser.Items.Clear();
//BLL.UserService.InitUserDropDownList(this.drpRectificationUser, model.ProjectId, true);
this.drpPMUser.Items.Clear();
BLL.UserService.InitUserDropDownList(this.drpPMUser, model.ProjectId, true);
}
else if (!string.IsNullOrWhiteSpace(model.ProjectName))
{
this.drpProject.Text = model.ProjectName;
}
PersonService.InitPersonByProjectUnitDropDownList(this.drpRectificationUser, model.ProjectId, model.UnitId, true);
//var pro = BLL.ProjectService.GetProjectByProjectId(model.ProjectId);
//if (pro != null)
//{
// this.txtAddress.Text = pro.ProjectAddress;
// this.drpPMUser.Items.Clear();
// BLL.UserService.InitUserDropDownList(this.drpPMUser, model.ProjectId, true);
//}
this.drpClassify.SelectedValue = model.ClassifyId;
BLL.SafetyProblemClassifyItemService.InitClassifyItemDownList(this.drpClassifyItem, model.ClassifyId, true);
if (!string.IsNullOrWhiteSpace(model.ClassifyItemId))
{
this.drpClassifyItem.SelectedValue = model.ClassifyItemId;
}
this.drpNature.SelectedValue = model.NatureId;
BLL.SafetyProblemNatureItemService.InitNatureItemDownList(this.drpNatureItem, model.NatureId, true);
if (!string.IsNullOrWhiteSpace(model.NatureItemId))
{
this.drpNatureItem.SelectedValue = model.NatureItemId;
}
this.txtAddress.Text = model.Address;
this.rblUnitType.SelectedValue = model.UnitType;
this.txtAssemblyName.Text = model.AssemblyName;
this.txtDescription.Text = model.Description;
this.txtRemark.Text = model.Remark;
this.txtCheckTeamUser.Text = model.CheckTeamUser;
//if (!string.IsNullOrWhiteSpace(model.CheckUserId))
//{
// this.drpCheckUser.SelectedValue = model.CheckUserId;
//}
if (!string.IsNullOrWhiteSpace(model.RectificationUserId))
{
this.drpRectificationUser.SelectedValue = model.RectificationUserId;
}
if (!string.IsNullOrWhiteSpace(model.PMUserId))
{
this.drpPMUser.SelectedValue = model.PMUserId;
}
this.txtCompileManName.Text = model.CompileManName;
if (model.CheckDate != null)
{
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", model.CheckDate);
}
if (model.LimitDate != null)
{
this.txtLimitDate.Text = string.Format("{0:yyyy-MM-dd}", model.LimitDate);
}
if (model.CloseTime != null)
{
this.txtCloseTime.Text = string.Format("{0:yyyy-MM-dd}", model.CloseTime);
}
if (model.CompileDate != null)
{
this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", model.CompileDate);
}
}
else
{
this.txtCompileManName.Text = this.CurrUser.UserName;
this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
}
}
#region 下拉数据加载
/// <summary>
/// 初始化下拉框
/// </summary>
private void InitDropDownList()
{
//受检单位
UnitService.InitBranchUnitDropDownList(this.drpUnit, false);
////受检项目
//ProjectService.InitProjectDropDownList(this.drpProject, true);
//问题分类
SafetyProblemClassifyService.InitClassifyDropDownList(this.drpClassify, false);
//问题性质
SafetyProblemNatureService.InitNatureDropDownList(this.drpNature, false);
}
/// <summary>
/// 受检单位下拉触发事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
{
this.drpProject.Items.Clear();
//受检项目
BLL.ProjectService.InitProjectDropDownList(this.drpProject, this.drpUnit.SelectedValue, true);
this.drpRectificationUser.Items.Clear();
//BLL.UserService.InitUserUnitIdDropDownList(this.drpRectificationUser, this.drpUnit.SelectedValue, true);
PersonService.InitPersonByProjectUnitDropDownList(this.drpRectificationUser, null, this.drpUnit.SelectedValue, true);
this.drpPMUser.Items.Clear();
BLL.UserService.InitUserUnitIdDropDownList(this.drpPMUser, this.drpUnit.SelectedValue, true);
}
/// <summary>
/// 受检项目下拉触发事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpProject_SelectedIndexChanged(object sender, EventArgs e)
{
string proId = this.drpProject.SelectedValue;
if (!string.IsNullOrWhiteSpace(proId) && proId != Const._Null)
{
var pro = BLL.ProjectService.GetProjectByProjectId(proId);
if (pro != null)
{
this.txtAddress.Text = pro.ProjectAddress;
this.drpRectificationUser.Items.Clear();
//BLL.UserService.InitUserDropDownList(this.drpRectificationUser, proId, true);
PersonService.InitPersonByProjectUnitDropDownList(this.drpRectificationUser, proId, this.drpUnit.SelectedValue, true);
this.drpPMUser.Items.Clear();
BLL.UserService.InitUserDropDownList(this.drpPMUser, proId, true);
}
}
}
/// <summary>
/// 问题分类下拉触发事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpClassify_SelectedIndexChanged(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(this.drpClassify.SelectedValue))
{
this.drpClassifyItem.Items.Clear();
BLL.SafetyProblemClassifyItemService.InitClassifyItemDownList(this.drpClassifyItem, this.drpClassify.SelectedValue, true);
}
}
/// <summary>
/// 问题性质下拉触发事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpNature_SelectedIndexChanged(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(this.drpNature.SelectedValue))
{
this.drpNatureItem.Items.Clear();
BLL.SafetyProblemNatureItemService.InitNatureItemDownList(this.drpNatureItem, this.drpNature.SelectedValue, true);
}
}
#endregion
#region 附件上传
/// <summary>
/// 上传附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttach_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CheckProblemSafety&menuId={1}", this.CheckId, BLL.Const.SafetyCheckProblemMenuId)));
}
#endregion
//protected void imgBtnFile_Click(object sender, EventArgs e)
//{
// PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/CheckProblemSafety&menuId={2}", QuestionImg, this.hdCheckControlCode.Text, BLL.Const.SafetyCheckProblemMenuId)));
//}
/// <summary>
/// 保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
//if (this.drpUnit.SelectedValue == BLL.Const._Null)
//{
// Alert.ShowInTop("请选择受检单位!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.drpClassify.SelectedValue) || this.drpClassify.SelectedValue == BLL.Const._Null)
//{
// Alert.ShowInTop("请选择问题分类!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.drpNature.SelectedValue) || this.drpNature.SelectedValue == BLL.Const._Null)
//{
// Alert.ShowInTop("请选择问题性质!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.txtDescription.Text.Trim()))
//{
// Alert.ShowInTop("请填写问题描述!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.txtCheckTeamUser.Text.Trim()))
//{
// Alert.ShowInTop("请填写检查组/检查人!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.drpRectificationUser.SelectedValue) || this.drpRectificationUser.SelectedValue == BLL.Const._Null)
//{
// Alert.ShowInTop("请选择整改人!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.drpPMUser.SelectedValue) || this.drpPMUser.SelectedValue == BLL.Const._Null)
//{
// Alert.ShowInTop("请选择项目经理!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.txtCheckDate.Text.Trim()))
//{
// Alert.ShowInTop("请选择检查日期!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.txtLimitDate.Text.Trim()))
//{
// Alert.ShowInTop("请选择整改期限!", MessageBoxIcon.Warning);
// return;
//}
SaveData();
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
///// <summary>
///// 提交
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//protected void btnSubmit_Click(object sender, EventArgs e)
//{
// if (BLL.CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SafetyCheckProblemMenuId, BLL.Const.BtnSubmit))
// {
// if (string.IsNullOrEmpty(Request.Params["Main"]))
// {
// PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
// }
// else
// {
// PageContext.RegisterStartupScript(String.Format("window.close();"));
// }
// }
// else
// {
// Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
// }
//}
/// <summary>
/// 保存数据
/// </summary>
protected void SaveData()
{
string saveType = string.Empty;//1-新增,2-修改
CheckProblem_Safety model = new CheckProblem_Safety();
model.UnitId = this.drpUnit.SelectedValue;
model.UnitName = this.drpUnit.SelectedText;
string proId = this.drpProject.SelectedValue;
if (!string.IsNullOrWhiteSpace(proId) && proId != Const._Null)
{
model.ProjectId = this.drpProject.SelectedValue;
model.ProjectName = this.drpProject.SelectedText;
}
//else
//{
// model.ProjectName = this.drpUnit.SelectedText;
//}
model.Address = this.txtAddress.Text.Trim();
model.Description = this.txtDescription.Text.Trim();
model.UnitType = this.rblUnitType.SelectedValue;
model.AssemblyName = this.txtAssemblyName.Text.Trim();
model.CheckTeamUser = this.txtCheckTeamUser.Text.Trim();
model.CheckDate = Funs.GetNewDateTimeOrNow(this.txtCheckDate.Text.Trim());
model.LimitDate = Funs.GetNewDateTime(this.txtLimitDate.Text.Trim());
if (!string.IsNullOrWhiteSpace(this.txtCloseTime.Text.Trim()))
{
model.CloseTime = Funs.GetNewDateTime(this.txtCloseTime.Text.Trim());
model.State = (int)CheckProblemSafetyService.StateInt.已闭环;
}
else
{
model.State = (int)CheckProblemSafetyService.StateInt.整改中;
}
model.RectificationUserId = this.drpRectificationUser.SelectedValue;
model.RectificationUserName = this.drpRectificationUser.SelectedText;
model.PMUserId = this.drpPMUser.SelectedValue;
model.PMUserName = this.drpPMUser.SelectedText;
model.ClassifyId = this.drpClassify.SelectedValue;
string classifyItemId = this.drpClassifyItem.SelectedValue;
if (!string.IsNullOrWhiteSpace(classifyItemId) && classifyItemId != Const._Null)
{
model.ClassifyItemId = classifyItemId;
}
model.NatureId = this.drpNature.SelectedValue;
string natureItemId = this.drpNatureItem.SelectedValue;
if (!string.IsNullOrWhiteSpace(natureItemId) && natureItemId != Const._Null)
{
model.NatureItemId = natureItemId;
}
model.Remark = this.txtRemark.Text.Trim();
if (string.IsNullOrWhiteSpace(this.CheckId))
{
saveType = "1";//新增
//新增
model.CheckId = SQLHelper.GetNewID(typeof(CheckProblem_Safety));
this.CheckId = model.CheckId;
model.CompileMan = this.CurrUser.UserId;
model.CompileManName = this.CurrUser.UserName;
model.CompileDate = DateTime.Now;
BLL.CheckProblemSafetyService.AddCheckProblem(model);
////增加一条编码记录
//BLL.CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(BLL.Const.SafetyCheckProblemMenuId, model.ProjectId, null, model.CheckId, model.CheckDate);
}
else
{
saveType = "2";//修改
//更新
model.CheckId = this.CheckId;
BLL.CheckProblemSafetyService.UpdateCheckProblem(model);
}
#region 扣分记录
var user = BLL.PersonService.GetPersonById(model.RectificationUserId);
//var user = BLL.UserService.GetUserByUserId(model.RectificationUserId);
if (user != null)
{
int oldS = 0;
DateTime comdate = new DateTime();
var scoreFlowLog = BLL.ScoreFlowLogService.GetScoreFlowLogByDataSourceId(user.IdentityCard, model.CheckDate.Year, model.CheckId);
if (scoreFlowLog != null)
{
oldS = scoreFlowLog.CurrentScore;
comdate = scoreFlowLog.CompileDate;
BLL.ScoreFlowLogService.DeleteScoreFlowLogByDataSourceId(user.IdentityCard, model.CheckDate.Year, model.CheckId);
}
var scoreUser = BLL.ScoreUserService.GetScoreUserByDataSourceId(user.IdentityCard, model.CheckDate.Year, model.CheckId);
if (scoreUser != null)
{
BLL.ScoreUserService.DeleteScoreUserByDataSourceId(user.IdentityCard, model.CheckDate.Year, model.CheckId);
}
#region 增加积分流水
//增加人员记分流水
ScoreFlowLog log = new ScoreFlowLog();
log.Id = SQLHelper.GetNewID();
log.Year = model.CheckDate.Year;
log.UserId = model.RectificationUserId;
log.UserName = model.RectificationUserName;
log.IdentityCard = user.IdentityCard;
log.UnitId = model.UnitId;
log.ProjectId = model.ProjectId;
log.UnitName = model.UnitName;
log.ProjectName = model.ProjectName;
log.Item = "安全不符合项";
log.LogContent = "隐患问责扣分";
log.CheckDate = model.CheckDate;
if (saveType == "1")
{
log.CompileDate = DateTime.Now;
}
else
{
log.CompileDate = comdate;
}
log.CompileMan = this.CurrUser.UserName;
log.CompileManId = this.CurrUser.UserId;
log.DataSourceId = model.CheckId;
log.Type = 0;//扣分
//特别严重(管控红线)扣成0分,严重(危险作业许可)扣除100分,较大扣除50分,一般扣除20分,轻微扣除2分
if (drpNature.SelectedValue == BLL.Const.SafetyNatureIdN1)
{
var sfl = BLL.ScoreFlowLogService.GetScoreFlowLogByIdentityCard(log.IdentityCard, log.Year, log.CompileDate);
if (sfl != null)
{
log.Score = -sfl.CurrentScore;//上一条记录多少分扣多少分
}
else
{
log.Score = -100;
}
}
else if (drpNature.SelectedValue == BLL.Const.SafetyNatureIdN2)
{
log.Score = -100;
}
else if (drpNature.SelectedValue == BLL.Const.SafetyNatureIdN3)
{
log.Score = -50;
}
else if (drpNature.SelectedValue == BLL.Const.SafetyNatureIdN4)
{
log.Score = -20;
}
var cs = BLL.ScoreFlowLogService.GetScoreFlowLogByIdentityCard(log.IdentityCard, log.Year, log.CompileDate);
if (cs != null)
{
log.CurrentScore = cs.CurrentScore + log.Score;//记分后人员得分值
}
else
{
log.CurrentScore = 100 + log.Score;
}
log.CurrentScore = log.CurrentScore < 0 ? 0 : log.CurrentScore;
BLL.ScoreFlowLogService.AddScoreFlowLog(log);
//增加人员记分情况
ScoreUser su = new ScoreUser();
su.Id = SQLHelper.GetNewID();
su.Year = log.Year;
su.IdentityCard = log.IdentityCard;
su.Score = log.CurrentScore;
su.UserName = log.UserName;
su.CompileDate = log.CompileDate;
su.DataSourceId = model.CheckId;
su.CheckDate = log.CheckDate;
BLL.ScoreUserService.AddScoreUser(su);
#endregion
var lastFlowLog = BLL.ScoreFlowLogService.GetScoreFlowLogByCompileDate(user.IdentityCard, log.Year, log.CompileDate);
if (lastFlowLog.Count > 0)
{
foreach (var item in lastFlowLog)
{
item.CurrentScore = item.CurrentScore - (oldS - log.CurrentScore);
Funs.DB.SubmitChanges();
}
}
var lastScoreUser = BLL.ScoreUserService.GetScoreUserByCompileDate(user.IdentityCard, su.Year, su.CompileDate);
if (lastScoreUser.Count > 0)
{
foreach (var item in lastScoreUser)
{
item.Score = item.Score - (oldS - su.Score);
Funs.DB.SubmitChanges();
}
}
}
#endregion
var classModel = SafetyProblemClassifyItemService.GetClassifyItemById(model.ClassifyItemId);
#region 责任人和问题类型关联重修教材非空,生成培训计划
if (!string.IsNullOrWhiteSpace(model.RectificationUserId) && !string.IsNullOrWhiteSpace(classModel.CompanyTrainingItemId))
{//责任人和重修教材非空,生成培训计划
var ItemIds = classModel.CompanyTrainingItemId.Split(',');
int index = 0;
foreach (var ItemId in ItemIds)
{
index++;
var CheckTypeName = Enums.RetakeCourseType.HSE不符合项.ToString();
Model.ProducePlanInfo info = new Model.ProducePlanInfo
{
CurrProjectId = !string.IsNullOrWhiteSpace(model.ProjectId) ? model.ProjectId : this.CurrUser.LoginProjectId,
CurrUserId = this.CurrUser.UserId,
CheckId = $"{this.CheckId}_{index}",
CheckType = (int)Enums.RetakeCourseType.HSE不符合项,
CheckTypeName = "HSE不符合项",
PersonId = model.RectificationUserId,
CompanyTrainingItemId = ItemId,
//TrainEndDate = model.RectificationPeriod
};
TrainingPlanService.RetakeCourseProducePlan(info);
}
}
#endregion
}
protected void WindowAtt_Close(object sender, WindowCloseEventArgs e)
{
}
}
}