20260817 积分、扣分
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using BLL;
|
||||
using Model;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System;
|
||||
|
||||
namespace FineUIPro.Web.Check.HSE
|
||||
@@ -55,21 +56,34 @@ namespace FineUIPro.Web.Check.HSE
|
||||
if (model != null)
|
||||
{
|
||||
this.drpUnit.SelectedValue = model.UnitId;
|
||||
this.drpRectificationUser.Items.Clear();
|
||||
BLL.UserService.InitUserUnitIdDropDownList(this.drpRectificationUser, this.drpUnit.SelectedValue, true);
|
||||
this.drpPMUser.Items.Clear();
|
||||
BLL.UserService.InitUserUnitIdDropDownList(this.drpPMUser, this.drpUnit.SelectedValue, true);
|
||||
|
||||
BLL.ProjectService.InitProjectDropDownList(this.drpProject, model.UnitId, true);
|
||||
if (!string.IsNullOrWhiteSpace(model.ProjectId))
|
||||
{
|
||||
this.drpProject.SelectedValue = model.ProjectId;
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(model.ProjectName))
|
||||
if (!string.IsNullOrWhiteSpace(model.ProjectName))
|
||||
{
|
||||
this.drpProject.Text = model.ProjectName;
|
||||
}
|
||||
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))
|
||||
@@ -311,6 +325,7 @@ namespace FineUIPro.Web.Check.HSE
|
||||
/// </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;
|
||||
@@ -359,6 +374,7 @@ namespace FineUIPro.Web.Check.HSE
|
||||
model.Remark = this.txtRemark.Text.Trim();
|
||||
if (string.IsNullOrWhiteSpace(this.CheckId))
|
||||
{
|
||||
saveType = "1";//新增
|
||||
//新增
|
||||
model.CheckId = SQLHelper.GetNewID(typeof(CheckProblem_Safety));
|
||||
this.CheckId = model.CheckId;
|
||||
@@ -369,13 +385,134 @@ namespace FineUIPro.Web.Check.HSE
|
||||
|
||||
////增加一条编码记录
|
||||
//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.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();
|
||||
if (!string.IsNullOrEmpty(txtCheckDate.Text.Trim()))
|
||||
{
|
||||
log.Year = Convert.ToDateTime(txtCheckDate.Text.Trim()).Year;
|
||||
}
|
||||
log.UserId = this.drpRectificationUser.SelectedValue;
|
||||
log.UserName = this.drpRectificationUser.SelectedText;
|
||||
log.IdentityCard = user.IdentityCard;
|
||||
log.UnitId = this.drpUnit.SelectedValue;
|
||||
log.ProjectId = this.drpProject.SelectedValue;
|
||||
log.UnitName = this.drpUnit.SelectedText;
|
||||
log.ProjectName = this.drpProject.SelectedText;
|
||||
log.Item = "安全不符合项";
|
||||
log.LogContent = "隐患问责扣分";
|
||||
log.CheckDate = Convert.ToDateTime(this.txtCheckDate.Text.Trim());
|
||||
if (saveType == "1")
|
||||
{
|
||||
log.CompileDate = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.CompileDate = comdate;
|
||||
}
|
||||
log.CompileMan = this.CurrUser.UserName;
|
||||
log.CompileManId = this.CurrUser.UserId;
|
||||
log.DataSourceId = this.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;
|
||||
}
|
||||
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 = this.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
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user