Files
xinjiang/SGGL/BLL/Score/ScoreFlowLogService.cs
T
2026-11-25 19:14:57 +08:00

675 lines
36 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 Model;
using System;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
/// <summary>
/// 人员记分流水日志表
/// </summary>
public class ScoreFlowLogService
{
/// <summary>
/// 记分方式
/// </summary>
public enum TypeInt : int
{
加分 = 1,
扣分 = 0
}
/// <summary>
///
/// </summary>
public static Dictionary<string, int> TypeMap = new Dictionary<string, int>
{
{ "加分" ,(int)TypeInt.加分},
{ "扣分" ,(int)TypeInt.扣分},
};
/// <summary>
/// 根据Id获取人员记分流水
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public static Model.ScoreFlowLog GetScoreFlowLogById(string Id)
{
return Funs.DB.ScoreFlowLog.FirstOrDefault(e => e.Id == Id);
}
/// <summary>
/// 根据证件号码获取人员今年上一条记分流水记录
/// </summary>
/// <param name="IdentityCard"></param>
/// <param name="year"></param>
/// <returns></returns>
public static Model.ScoreFlowLog GetScoreFlowLogByIdentityCard(string IdentityCard, int year, DateTime compileDate)
{
return Funs.DB.ScoreFlowLog.Where(e => e.IdentityCard == IdentityCard && e.Year == year && e.CompileDate <= compileDate).OrderByDescending(x => x.CompileDate).FirstOrDefault();
}
/// <summary>
/// 根据数据来源id获取人员计分流水
/// </summary>
/// <param name="IdentityCard"></param>
/// <param name="year"></param>
/// <param name="dataSourceId"></param>
/// <returns></returns>
public static Model.ScoreFlowLog GetScoreFlowLogByDataSourceId(string IdentityCard, int year, string dataSourceId)
{
return Funs.DB.ScoreFlowLog.FirstOrDefault(e => e.IdentityCard == IdentityCard && e.Year == year && e.DataSourceId == dataSourceId);
}
/// <summary>
/// 根据时间获取比当前年份的人员比时间后的数据
/// </summary>
/// <param name="IdentityCard"></param>
/// <param name="year"></param>
/// <param name="compliedate"></param>
/// <returns></returns>
public static List<Model.ScoreFlowLog> GetScoreFlowLogByCompileDate(string IdentityCard, int year, DateTime compliedate)
{
return (from x in Funs.DB.ScoreFlowLog where x.IdentityCard == IdentityCard && x.Year == year && x.CompileDate > compliedate select x).ToList();
}
/// <summary>
/// 根据年份、身份证号码获取人员流水日志记录
/// </summary>
/// <param name="IdentityCard"></param>
/// <param name="year"></param>
/// <returns></returns>
public static List<Model.ScoreFlowLog> GetScoreLogByIdentityCard(int year, string IdentityCard)
{
return (from x in Funs.DB.ScoreFlowLog where x.IdentityCard == IdentityCard && x.Year == year orderby x.CompileDate descending select x).ToList();
}
/// <summary>
/// 增加人员记分流水
/// </summary>
/// <param name="model">人员记分流水实体</param>
public static void AddScoreFlowLog(Model.ScoreFlowLog model)
{
Model.ScoreFlowLog newModel = new Model.ScoreFlowLog();
newModel.Id = model.Id;
newModel.Year = model.Year;
newModel.IdentityCard = model.IdentityCard;
newModel.UserName = model.UserName;
newModel.Type = model.Type;
newModel.Score = model.Score;
newModel.CurrentScore = model.CurrentScore;
newModel.Item = model.Item;
newModel.LogContent = model.LogContent;
newModel.UserId = model.UserId;
newModel.PersonId = model.PersonId;
newModel.UnitId = model.UnitId;
newModel.ProjectId = model.ProjectId;
newModel.UnitName = model.UnitName;
newModel.ProjectName = model.ProjectName;
newModel.Remark = model.Remark;
newModel.CompileDate = model.CompileDate;
newModel.CompileMan = model.CompileMan;
newModel.CompileManId = model.CompileManId;
newModel.DataSourceId = model.DataSourceId;
newModel.CheckDate = model.CheckDate;
Funs.DB.ScoreFlowLog.InsertOnSubmit(newModel);
Funs.DB.SubmitChanges();
}
/// <summary>
/// 修改人员记分流水
/// </summary>
/// <param name="model">人员记分流水实体</param>
public static void UpdateScoreFlowLog(Model.ScoreFlowLog model)
{
Model.ScoreFlowLog newModel = Funs.DB.ScoreFlowLog.FirstOrDefault(e => e.Id == model.Id);
if (newModel != null)
{
//newModel.Id = model.Id;
newModel.Year = model.Year;
newModel.IdentityCard = model.IdentityCard;
newModel.UserName = model.UserName;
newModel.Type = model.Type;
newModel.Score = model.Score;
newModel.CurrentScore = model.CurrentScore;
newModel.Item = model.Item;
newModel.LogContent = model.LogContent;
newModel.UserId = model.UserId;
newModel.PersonId = model.PersonId;
newModel.UnitId = model.UnitId;
newModel.ProjectId = model.ProjectId;
newModel.UnitName = model.UnitName;
newModel.ProjectName = model.ProjectName;
newModel.Remark = model.Remark;
//newModel.CompileDate = model.CompileDate;
//newModel.CompileMan = model.CompileMan;
//newModel.CompileManId = model.CompileManId;
newModel.DataSourceId = model.DataSourceId;
newModel.CheckDate = model.CheckDate;
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 根据Id删除人员记分流水
/// </summary>
/// <param name="Id"></param>
/// <param name="opUser"></param>
public static void DeleteScoreFlowLogById(string Id, Sys_User opUser)
{
var db = Funs.DB;
Model.ScoreFlowLog model = db.ScoreFlowLog.FirstOrDefault(x => x.Id == Id);
if (model != null)
{
db.ScoreFlowLog.DeleteOnSubmit(model);
db.SubmitChanges();
//BLL.LogService.AddSys_Log(opUser, model.Id, model.Id, BLL.Const.ProjectScoreFlowLogMenuId, BLL.Const.BtnDelete);
}
}
public static void DeleteScoreFlowLogByDataSourceId(string IdentityCard, int year, string dataSourceId)
{
var db = Funs.DB;
Model.ScoreFlowLog model = db.ScoreFlowLog.FirstOrDefault(x => x.IdentityCard == IdentityCard && x.Year == year && x.DataSourceId == dataSourceId);
if (model != null)
{
db.ScoreFlowLog.DeleteOnSubmit(model);
db.SubmitChanges();
}
}
#region 考试后记分
/// <summary>
/// 考试后记分
/// </summary>
/// <param name="testRecordId"></param>
public static void HseScoring(string testRecordId)
{
//ErrLogInfo.WriteLog($"【考试后记分】testRecordId:{testRecordId};");
if (string.IsNullOrWhiteSpace(testRecordId))
{
return;
}
//考试大于等于及格分、已开考、且没有加过分的记录,加分
int passScore = SysConstSetService.getPassScore();
var testRecordList = (from x in Funs.DB.View_Training_TestRecord
where x.TestScores >= passScore && x.TestRecordId == testRecordId && x.TestStartTime != null
&& !Funs.DB.ScoreFlowLog.Any(log => log.DataSourceId == x.TestRecordId)
select x).ToList();
foreach (var item in testRecordList)
{
//无身份证(人员档案缺失)或教材/教材分类已删除时无法定位记分对象,跳过,避免按首档分重复加分
if (string.IsNullOrWhiteSpace(item.IdentityCard)
|| string.IsNullOrWhiteSpace(item.CompanyTrainingName)
|| string.IsNullOrWhiteSpace(item.CompanyTrainingItemName))
{
continue;
}
//查找最新一条积分记录
var flowLog = GetScoreFlowLogByIdentityCard(item.IdentityCard, item.TestStartTime.Value.Year, DateTime.Now);
//作业人员考试加分
if (item.WorkPostType == "一般作业岗位" || item.WorkPostType == "特种作业人员")
{
//必修-岗位基本操作技能:一门专业课20分,最高20分;超过1门课程,多出的学习课程每门2分
if (item.CompanyTrainingId == BLL.Const.CompanyTrainingId3)
{
var scoreFlowLog = (from x in Funs.DB.ScoreFlowLog where x.Type == 1 && x.IdentityCard == item.IdentityCard && x.Year == item.TestStartTime.Value.Year && x.Item.Contains("考试【岗位基本操作技能】") orderby x.CompileDate descending select x).ToList();
//一个课程加分一次
var isExist = scoreFlowLog.Where(x => x.LogContent.Contains("岗位基本操作技能【" + item.CompanyTrainingItemName + "】")).FirstOrDefault();
if (isExist == null)//第一次加分
{
//人员记分流水日志表
Model.ScoreFlowLog newlog = new Model.ScoreFlowLog();
newlog.Id = SQLHelper.GetNewID();
newlog.Year = item.TestStartTime.Value.Year;
newlog.IdentityCard = item.IdentityCard;
newlog.UserName = item.PersonName;
newlog.PersonId = item.TestManId;
newlog.UnitId = item.UnitId;
newlog.ProjectId = item.ProjectId;
newlog.UnitName = item.UnitName;
newlog.ProjectName = item.ProjectName;
newlog.Type = 1;
newlog.Item = "考试【岗位基本操作技能】";
newlog.LogContent = "岗位基本操作技能【" + item.CompanyTrainingItemName + "】考试得分" + item.TestScores + "分后,加分";
newlog.CompileDate = DateTime.Now;
newlog.CompileManId = "";
newlog.CompileMan = "";
newlog.DataSourceId = item.TestRecordId;
newlog.CheckDate = item.TestStartTime;
if (scoreFlowLog.Count == 0)
{
newlog.Score = 20;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 20;
}
else
{
newlog.CurrentScore = 120;
}
}
else
{
newlog.Score = 2;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 2;
}
else
{
newlog.CurrentScore = 102;
}
}
newlog.CurrentScore = newlog.CurrentScore < 0 ? 0 : newlog.CurrentScore;
BLL.ScoreFlowLogService.AddScoreFlowLog(newlog);
//人员记分情况
Model.ScoreUser newScoreUser = new ScoreUser();
newScoreUser.Id = SQLHelper.GetNewID();
newScoreUser.Year = newlog.Year;
newScoreUser.IdentityCard = item.IdentityCard;
newScoreUser.Score = newlog.CurrentScore;
newScoreUser.UserName = newlog.UserName;
newScoreUser.CompileDate = newlog.CompileDate;
newScoreUser.DataSourceId = newlog.DataSourceId;
newScoreUser.CheckDate = newlog.CheckDate;
BLL.ScoreUserService.AddScoreUser(newScoreUser);
}
}
//必修-通用安全知识:60分,每门10分,最高60分;超过6门课程,多出的学习课程每门2分
else if (item.CompanyTrainingId == BLL.Const.CompanyTrainingId1)
{
var scoreFlowLog = (from x in Funs.DB.ScoreFlowLog where x.Type == 1 && x.IdentityCard == item.IdentityCard && x.Year == item.TestStartTime.Value.Year && x.Item.Contains("考试【通用安全知识】") orderby x.CompileDate descending select x).ToList();
//一个课程加分一次
var isExist = scoreFlowLog.Where(x => x.LogContent.Contains("通用安全知识【" + item.CompanyTrainingItemName + "】")).FirstOrDefault();
if (isExist == null)//第一次加分
{
//人员记分流水日志表
Model.ScoreFlowLog newlog = new Model.ScoreFlowLog();
newlog.Id = SQLHelper.GetNewID();
newlog.Year = item.TestStartTime.Value.Year;
newlog.IdentityCard = item.IdentityCard;
newlog.UserName = item.PersonName;
newlog.PersonId = item.TestManId;
newlog.UnitId = item.UnitId;
newlog.ProjectId = item.ProjectId;
newlog.UnitName = item.UnitName;
newlog.ProjectName = item.ProjectName;
newlog.Type = 1;
newlog.Item = "考试【通用安全知识】";
newlog.LogContent = "通用安全知识【" + item.CompanyTrainingItemName + "】考试得分" + item.TestScores + "分后,加分";
newlog.CompileDate = DateTime.Now;
newlog.CompileManId = "";
newlog.CompileMan = "";
newlog.DataSourceId = item.TestRecordId;
newlog.CheckDate = item.TestStartTime;
if (scoreFlowLog.Count < 6)
{
newlog.Score = 10;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 10;
}
else
{
newlog.CurrentScore = 110;
}
}
else
{
newlog.Score = 2;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 2;
}
else
{
newlog.CurrentScore = 102;
}
}
newlog.CurrentScore = newlog.CurrentScore < 0 ? 0 : newlog.CurrentScore;
BLL.ScoreFlowLogService.AddScoreFlowLog(newlog);
//人员记分情况
Model.ScoreUser newScoreUser = new ScoreUser();
newScoreUser.Id = SQLHelper.GetNewID();
newScoreUser.Year = newlog.Year;
newScoreUser.IdentityCard = item.IdentityCard;
newScoreUser.Score = newlog.CurrentScore;
newScoreUser.UserName = newlog.UserName;
newScoreUser.CompileDate = newlog.CompileDate;
newScoreUser.DataSourceId = newlog.DataSourceId;
newScoreUser.CheckDate = newlog.CheckDate;
BLL.ScoreUserService.AddScoreUser(newScoreUser);
}
}
//选修加分 每节课2分,加分上线不限制,以年度为节点
else
{
var isExist = (from x in Funs.DB.ScoreFlowLog
where x.Type == 1 && x.IdentityCard == item.IdentityCard && x.Year == item.TestStartTime.Value.Year
&& x.Item.Contains(item.CompanyTrainingName)
&& x.LogContent.Contains(item.CompanyTrainingName + "【" + item.CompanyTrainingItemName + "】")
orderby x.CompileDate descending
select x).FirstOrDefault();
if (isExist == null)
{
//人员记分流水日志表
Model.ScoreFlowLog newlog = new Model.ScoreFlowLog();
newlog.Id = SQLHelper.GetNewID();
newlog.Year = item.TestStartTime.Value.Year;
newlog.IdentityCard = item.IdentityCard;
newlog.UserName = item.PersonName;
newlog.PersonId = item.TestManId;
newlog.UnitId = item.UnitId;
newlog.ProjectId = item.ProjectId;
newlog.UnitName = item.UnitName;
newlog.ProjectName = item.ProjectName;
newlog.Type = 1;
newlog.Item = "考试【" + item.CompanyTrainingName + "】";
newlog.LogContent = item.CompanyTrainingName + "【" + item.CompanyTrainingItemName + "】考试得分" + item.TestScores + "分后,加分";
newlog.CompileDate = DateTime.Now;
newlog.CompileManId = "";
newlog.CompileMan = "";
newlog.DataSourceId = item.TestRecordId;
newlog.CheckDate = item.TestStartTime;
newlog.Score = 2;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 2;
}
else
{
newlog.CurrentScore = 102;
}
newlog.CurrentScore = newlog.CurrentScore < 0 ? 0 : newlog.CurrentScore;
BLL.ScoreFlowLogService.AddScoreFlowLog(newlog);
//人员记分情况
Model.ScoreUser newScoreUser = new ScoreUser();
newScoreUser.Id = SQLHelper.GetNewID();
newScoreUser.Year = newlog.Year;
newScoreUser.IdentityCard = item.IdentityCard;
newScoreUser.Score = newlog.CurrentScore;
newScoreUser.UserName = newlog.UserName;
newScoreUser.CompileDate = newlog.CompileDate;
newScoreUser.DataSourceId = newlog.DataSourceId;
newScoreUser.CheckDate = newlog.CheckDate;
BLL.ScoreUserService.AddScoreUser(newScoreUser);
}
}
}
//管理人员考试加分
else if (item.WorkPostType == "一般管理岗位" || item.WorkPostType == "特种管理人员")
{
//必修-知识方法工具,最少学习5门课程,一门5分;超过5门课程,多出的学习课程每门2分
if (item.CompanyTrainingId == BLL.Const.CompanyTrainingId2)
{
var scoreFlowLog = (from x in Funs.DB.ScoreFlowLog where x.Type == 1 && x.IdentityCard == item.IdentityCard && x.Year == item.TestStartTime.Value.Year && x.Item.Contains("考试【知识方法工具】") orderby x.CompileDate descending select x).ToList();
//一次考试加分一次
var isExist = scoreFlowLog.Where(x => x.LogContent.Contains("知识方法工具【" + item.CompanyTrainingItemName + "】")).FirstOrDefault();
if (isExist == null)//第一次加分
{
//人员记分流水日志表
Model.ScoreFlowLog newlog = new Model.ScoreFlowLog();
newlog.Id = SQLHelper.GetNewID();
newlog.Year = item.TestStartTime.Value.Year;
newlog.IdentityCard = item.IdentityCard;
newlog.UserName = item.PersonName;
newlog.PersonId = item.TestManId;
newlog.UnitId = item.UnitId;
newlog.ProjectId = item.ProjectId;
newlog.UnitName = item.UnitName;
newlog.ProjectName = item.ProjectName;
newlog.Type = 1;
newlog.Item = "考试【知识方法工具】";
newlog.LogContent = "知识方法工具【" + item.CompanyTrainingItemName + "】考试得分" + item.TestScores + "分后,加分";
newlog.CompileDate = DateTime.Now;
newlog.CompileManId = "";
newlog.CompileMan = "";
newlog.DataSourceId = item.TestRecordId;
newlog.CheckDate = item.TestStartTime;
if (scoreFlowLog.Count < 5)
{
newlog.Score = 5;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 5;
}
else
{
newlog.CurrentScore = 105;
}
}
else
{
newlog.Score = 2;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 2;
}
else
{
newlog.CurrentScore = 102;
}
}
newlog.CurrentScore = newlog.CurrentScore < 0 ? 0 : newlog.CurrentScore;
BLL.ScoreFlowLogService.AddScoreFlowLog(newlog);
//人员记分情况
Model.ScoreUser newScoreUser = new ScoreUser();
newScoreUser.Id = SQLHelper.GetNewID();
newScoreUser.Year = newlog.Year;
newScoreUser.IdentityCard = item.IdentityCard;
newScoreUser.Score = newlog.CurrentScore;
newScoreUser.UserName = newlog.UserName;
newScoreUser.CompileDate = newlog.CompileDate;
newScoreUser.DataSourceId = newlog.DataSourceId;
newScoreUser.CheckDate = newlog.CheckDate;
BLL.ScoreUserService.AddScoreUser(newScoreUser);
}
}
//必修-生产受控管理,最少学习5门课程,一门5分;超过5门课程,多出的学习课程每门2分
else if (item.CompanyTrainingId == BLL.Const.CompanyTrainingId4)
{
var scoreFlowLog = (from x in Funs.DB.ScoreFlowLog where x.Type == 1 && x.IdentityCard == item.IdentityCard && x.Year == item.TestStartTime.Value.Year && x.Item.Contains("考试【生产受控管理】") orderby x.CompileDate descending select x).ToList();
//一次考试加分一次
var isExist = scoreFlowLog.Where(x => x.LogContent.Contains("生产受控管理【" + item.CompanyTrainingItemName + "】")).FirstOrDefault();
if (isExist == null)//第一次加分
{
//人员记分流水日志表
Model.ScoreFlowLog newlog = new Model.ScoreFlowLog();
newlog.Id = SQLHelper.GetNewID();
newlog.Year = item.TestStartTime.Value.Year;
newlog.IdentityCard = item.IdentityCard;
newlog.UserName = item.PersonName;
newlog.PersonId = item.TestManId;
newlog.UnitId = item.UnitId;
newlog.ProjectId = item.ProjectId;
newlog.UnitName = item.UnitName;
newlog.ProjectName = item.ProjectName;
newlog.Type = 1;
newlog.Item = "考试【生产受控管理】";
newlog.LogContent = "生产受控管理【" + item.CompanyTrainingItemName + "】考试得分" + item.TestScores + "分后,加分";
newlog.CompileDate = DateTime.Now;
newlog.CompileManId = "";
newlog.CompileMan = "";
newlog.DataSourceId = item.TestRecordId;
newlog.CheckDate = item.TestStartTime;
if (scoreFlowLog.Count < 5)
{
newlog.Score = 5;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 5;
}
else
{
newlog.CurrentScore = 105;
}
}
else
{
newlog.Score = 2;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 2;
}
else
{
newlog.CurrentScore = 102;
}
}
newlog.CurrentScore = newlog.CurrentScore < 0 ? 0 : newlog.CurrentScore;
BLL.ScoreFlowLogService.AddScoreFlowLog(newlog);
//人员记分情况
Model.ScoreUser newScoreUser = new ScoreUser();
newScoreUser.Id = SQLHelper.GetNewID();
newScoreUser.Year = newlog.Year;
newScoreUser.IdentityCard = item.IdentityCard;
newScoreUser.Score = newlog.CurrentScore;
newScoreUser.UserName = newlog.UserName;
newScoreUser.CompileDate = newlog.CompileDate;
newScoreUser.DataSourceId = newlog.DataSourceId;
newScoreUser.CheckDate = newlog.CheckDate;
BLL.ScoreUserService.AddScoreUser(newScoreUser);
}
}
//必修-通用课程:通用安全知识:30分,每门10分,最高30分;超过3门课程,多出的学习课程每门2分
else if (item.CompanyTrainingId == BLL.Const.CompanyTrainingId1)
{
var scoreFlowLog = (from x in Funs.DB.ScoreFlowLog where x.Type == 1 && x.IdentityCard == item.IdentityCard && x.Year == item.TestStartTime.Value.Year && x.Item.Contains("考试【通用安全知识】") orderby x.CompileDate descending select x).ToList();
//一次考试加分一次
var isExist = scoreFlowLog.Where(x => x.LogContent.Contains("通用安全知识【" + item.CompanyTrainingItemName + "】")).FirstOrDefault();
if (isExist == null)//第一次加分
{
//人员记分流水日志表
Model.ScoreFlowLog newlog = new Model.ScoreFlowLog();
newlog.Id = SQLHelper.GetNewID();
newlog.Year = item.TestStartTime.Value.Year;
newlog.IdentityCard = item.IdentityCard;
newlog.UserName = item.PersonName;
newlog.PersonId = item.TestManId;
newlog.UnitId = item.UnitId;
newlog.ProjectId = item.ProjectId;
newlog.UnitName = item.UnitName;
newlog.ProjectName = item.ProjectName;
newlog.Type = 1;
newlog.Item = "考试【通用安全知识】";
newlog.LogContent = "通用安全知识【" + item.CompanyTrainingItemName + "】考试得分" + item.TestScores + "分后,加分";
newlog.CompileDate = DateTime.Now;
newlog.CompileManId = "";
newlog.CompileMan = "";
newlog.DataSourceId = item.TestRecordId;
newlog.CheckDate = item.TestStartTime;
if (scoreFlowLog.Count < 3)
{
newlog.Score = 10;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 10;
}
else
{
newlog.CurrentScore = 110;
}
}
else
{
newlog.Score = 2;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 2;
}
else
{
newlog.CurrentScore = 102;
}
}
newlog.CurrentScore = newlog.CurrentScore < 0 ? 0 : newlog.CurrentScore;
BLL.ScoreFlowLogService.AddScoreFlowLog(newlog);
//人员记分情况
Model.ScoreUser newScoreUser = new ScoreUser();
newScoreUser.Id = SQLHelper.GetNewID();
newScoreUser.Year = newlog.Year;
newScoreUser.IdentityCard = item.IdentityCard;
newScoreUser.Score = newlog.CurrentScore;
newScoreUser.UserName = newlog.UserName;
newScoreUser.CompileDate = newlog.CompileDate;
newScoreUser.DataSourceId = newlog.DataSourceId;
newScoreUser.CheckDate = newlog.CheckDate;
BLL.ScoreUserService.AddScoreUser(newScoreUser);
}
}
else //选修加分 每节课2分,加分上线不限制,以年度为节点
{
var isExist = (from x in Funs.DB.ScoreFlowLog
where x.Type == 1 && x.IdentityCard == item.IdentityCard && x.Year == item.TestStartTime.Value.Year
&& x.Item.Contains(item.CompanyTrainingName)
&& x.LogContent.Contains(item.CompanyTrainingName + "【" + item.CompanyTrainingItemName + "】")
orderby x.CompileDate descending
select x).FirstOrDefault();
if (isExist == null)
{
//人员记分流水日志表
Model.ScoreFlowLog newlog = new Model.ScoreFlowLog();
newlog.Id = SQLHelper.GetNewID();
newlog.Year = item.TestStartTime.Value.Year;
newlog.IdentityCard = item.IdentityCard;
newlog.UserName = item.PersonName;
newlog.PersonId = item.TestManId;
newlog.UnitId = item.UnitId;
newlog.ProjectId = item.ProjectId;
newlog.UnitName = item.UnitName;
newlog.ProjectName = item.ProjectName;
newlog.Type = 1;
newlog.Item = "考试【" + item.CompanyTrainingName + "】";
newlog.LogContent = item.CompanyTrainingName + "【" + item.CompanyTrainingItemName + "】考试得分" + item.TestScores + "分后,加分";
newlog.CompileDate = DateTime.Now;
newlog.CompileManId = "";
newlog.CompileMan = "";
newlog.DataSourceId = item.TestRecordId;
newlog.CheckDate = item.TestStartTime;
newlog.Score = 2;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 2;
}
else
{
newlog.CurrentScore = 102;
}
newlog.CurrentScore = newlog.CurrentScore < 0 ? 0 : newlog.CurrentScore;
BLL.ScoreFlowLogService.AddScoreFlowLog(newlog);
//人员记分情况
Model.ScoreUser newScoreUser = new ScoreUser();
newScoreUser.Id = SQLHelper.GetNewID();
newScoreUser.Year = newlog.Year;
newScoreUser.IdentityCard = item.IdentityCard;
newScoreUser.Score = newlog.CurrentScore;
newScoreUser.UserName = newlog.UserName;
newScoreUser.CompileDate = newlog.CompileDate;
newScoreUser.DataSourceId = newlog.DataSourceId;
newScoreUser.CheckDate = newlog.CheckDate;
BLL.ScoreUserService.AddScoreUser(newScoreUser);
}
}
}
}
}
#endregion
}
}