2676 lines
133 KiB
C#
2676 lines
133 KiB
C#
using Model;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
namespace BLL
|
|
{
|
|
/// <summary>
|
|
/// 三库业务数据汇总上报
|
|
/// </summary>
|
|
public static class SanKuDataSummaryReportService
|
|
{
|
|
#region 数据操作
|
|
|
|
/// <summary>
|
|
/// 收集三库业务数据
|
|
/// </summary>
|
|
public static string DataCollectOp()
|
|
{
|
|
var db = Funs.DB;
|
|
string resultStr = string.Empty;
|
|
string msg = string.Empty;
|
|
try
|
|
{
|
|
var result = Funs.DB.SP_SANKU_DATA_INIT("", 1);
|
|
resultStr = "成功";
|
|
msg = $"收集三库业务数据";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
resultStr = "失败";
|
|
msg = JsonConvert.SerializeObject(ex);
|
|
}
|
|
|
|
//记录上报结果日志
|
|
Model.SANKU_REPORT_LOG newModel = new Model.SANKU_REPORT_LOG();
|
|
newModel.OPTYPE = "数据操作";
|
|
newModel.CONTENT = msg;
|
|
newModel.RESULT = resultStr;
|
|
newModel.DETAIL = msg;
|
|
newModel.OPERATOR = "定时任务";
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_REPORT_LOG.InsertOnSubmit(newModel);
|
|
db.SubmitChanges();
|
|
|
|
return resultStr == "成功" ? "1" : "0";
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 业务更新
|
|
|
|
#region 事故事件
|
|
|
|
/// <summary>
|
|
/// 更新事故事件数据
|
|
/// </summary>
|
|
/// <param name="accidentHandleId">事故id</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string UpdateAccidentRecord(string accidentHandleId, ref string message)
|
|
{
|
|
string result = string.Empty;
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var models = from tba in db.Accident_AccidentHandle
|
|
join bu in db.Base_Unit on tba.UnitId equals bu.UnitId
|
|
join su in db.Sys_User on tba.ResponsibleMan equals su.UserId
|
|
join suc in db.Sys_User on tba.CompileMan equals suc.UserId
|
|
join bp in db.Base_Project on tba.ProjectId equals bp.ProjectId
|
|
join pms in db.Ads_pms_pro_info_build on bp.MasterSysId equals pms.Pro_id
|
|
where tba.AccidentHandleId == accidentHandleId
|
|
select new SankuAccident
|
|
{
|
|
ACCIDENT_ID = tba.AccidentHandleId,
|
|
//PROJECT_CODE = pms.Pro_code.ToString(),
|
|
PROJECT_CODE = pms.Pro_code,
|
|
PROJECT_NAME = pms.Pro_name,
|
|
ACCIDENT_NAME = tba.AccidentHandleName,
|
|
ACCIDENT_TIME = tba.AccidentDate,
|
|
ACCIDENT_LEVEL = tba.AccidentLevel,
|
|
ACCIDENT_TYPE = tba.AccidentType,
|
|
ACCIDENT_LOCATION = tba.AccidentLocation,
|
|
ACCIDENT_DESCRIPTION = tba.AccidentDef,
|
|
DEATH_COUNT = (int)tba.DeathPersonNum,
|
|
SERIOUS_INJURY_COUNT = (int)tba.InjuriesPersonNum,
|
|
MINOR_INJURY_COUNT = (int)tba.MinorInjuriesPersonNum,
|
|
DIRECT_ECONOMIC_LOSS = (decimal)tba.MoneyLoss,
|
|
INDIRECT_ECONOMIC_LOSS = (decimal)tba.IndirectMoneyLoss,
|
|
CONTRACTING_RESPONSIBILITY = tba.ContractingResponsibility,
|
|
SUBCONTRACTOR_ID = bu.MasterAdOrgCode,
|
|
SUBCONTRACTOR_CODE = bu.CollCropCode,
|
|
SUBCONTRACTOR_NAME = bu.UnitName,
|
|
POSITION_NAME = tba.PositionName,
|
|
RESPONSIBILITY_TYPE = tba.ResponsibilityType,
|
|
RESPONSIBILITY_DESC = tba.ResponsibilityDesc,
|
|
PERSONNEL_ID_NUMBER = su.IdentityCard,
|
|
PERSONNEL_NAME = tba.ResponsibleManName,
|
|
SUBMITTER_ID_NUMBER = suc.IdentityCard,
|
|
SUBMITTER_NAME = suc.UserName,
|
|
UPDATE_TIME = (DateTime)tba.CompileDate,
|
|
CREATE_TIME = (DateTime)tba.CompileDate
|
|
};
|
|
var model = models.ToList().FirstOrDefault();
|
|
List<string> errMsgs = new List<string>();
|
|
if (model != null)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(model.PROJECT_CODE))
|
|
{
|
|
errMsgs.Add("项目未关联集团主数据");
|
|
}
|
|
if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE))
|
|
{
|
|
errMsgs.Add("责任单位未关联主数据组织且统一社会信用代码为空");
|
|
}
|
|
else if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && !string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE) && model.SUBCONTRACTOR_CODE.Length != 18)
|
|
{
|
|
errMsgs.Add("责任单位未关联主数据组织且统一社会信用代码异常");
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(model.PERSONNEL_ID_NUMBER) && model.PERSONNEL_ID_NUMBER.Length != 18)
|
|
//{
|
|
// errMsgs.Add("分包人员身份证异常");
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(model.SUBMITTER_ID_NUMBER) && model.SUBMITTER_ID_NUMBER.Length != 18)
|
|
//{
|
|
// errMsgs.Add("填报人身份证异常");
|
|
//}
|
|
if (errMsgs.Any())
|
|
{
|
|
message = $"无法更新三库,数据异常:{string.Join(",", errMsgs)}";
|
|
}
|
|
else
|
|
{
|
|
var exist = db.SANKU_ACCIDENT_RECORD.Where(x => x.ACCIDENT_ID == model.ACCIDENT_ID).FirstOrDefault();
|
|
if (exist != null)
|
|
{
|
|
//更新三库
|
|
exist.ACCIDENT_ID = model.ACCIDENT_ID;
|
|
exist.PROJECT_CODE = model.PROJECT_CODE;
|
|
exist.PROJECT_NAME = model.PROJECT_NAME;
|
|
exist.ACCIDENT_NAME = model.ACCIDENT_NAME;
|
|
exist.ACCIDENT_TIME = model.ACCIDENT_TIME;
|
|
exist.ACCIDENT_LEVEL = model.ACCIDENT_LEVEL;
|
|
exist.ACCIDENT_TYPE = model.ACCIDENT_TYPE;
|
|
exist.ACCIDENT_LOCATION = model.ACCIDENT_LOCATION;
|
|
exist.ACCIDENT_DESCRIPTION = model.ACCIDENT_DESCRIPTION;
|
|
exist.DEATH_COUNT = model.DEATH_COUNT;
|
|
exist.SERIOUS_INJURY_COUNT = model.SERIOUS_INJURY_COUNT;
|
|
exist.MINOR_INJURY_COUNT = model.MINOR_INJURY_COUNT;
|
|
exist.DIRECT_ECONOMIC_LOSS = model.DIRECT_ECONOMIC_LOSS;
|
|
exist.INDIRECT_ECONOMIC_LOSS = model.INDIRECT_ECONOMIC_LOSS;
|
|
exist.CONTRACTING_RESPONSIBILITY = model.CONTRACTING_RESPONSIBILITY;
|
|
exist.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
exist.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
exist.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
exist.POSITION_NAME = model.POSITION_NAME;
|
|
exist.RESPONSIBILITY_TYPE = model.RESPONSIBILITY_TYPE;
|
|
exist.RESPONSIBILITY_DESC = model.RESPONSIBILITY_DESC;
|
|
exist.PERSONNEL_ID_NUMBER = model.PERSONNEL_ID_NUMBER;
|
|
exist.PERSONNEL_NAME = model.PERSONNEL_NAME;
|
|
exist.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
exist.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
exist.UPDATE_TIME = DateTime.Now;
|
|
//exist.UPDATE_TIME = model.UPDATE_TIME;
|
|
//exist.CREATE_TIME = model.CREATE_TIME;
|
|
exist.ReportDate = null;
|
|
}
|
|
else
|
|
{
|
|
//新增三库
|
|
var newModel = new SANKU_ACCIDENT_RECORD();
|
|
newModel.ACCIDENT_ID = model.ACCIDENT_ID;
|
|
newModel.PROJECT_CODE = model.PROJECT_CODE;
|
|
newModel.PROJECT_NAME = model.PROJECT_NAME;
|
|
newModel.ACCIDENT_NAME = model.ACCIDENT_NAME;
|
|
newModel.ACCIDENT_TIME = model.ACCIDENT_TIME;
|
|
newModel.ACCIDENT_LEVEL = model.ACCIDENT_LEVEL;
|
|
newModel.ACCIDENT_TYPE = model.ACCIDENT_TYPE;
|
|
newModel.ACCIDENT_LOCATION = model.ACCIDENT_LOCATION;
|
|
newModel.ACCIDENT_DESCRIPTION = model.ACCIDENT_DESCRIPTION;
|
|
newModel.DEATH_COUNT = model.DEATH_COUNT;
|
|
newModel.SERIOUS_INJURY_COUNT = model.SERIOUS_INJURY_COUNT;
|
|
newModel.MINOR_INJURY_COUNT = model.MINOR_INJURY_COUNT;
|
|
newModel.DIRECT_ECONOMIC_LOSS = model.DIRECT_ECONOMIC_LOSS;
|
|
newModel.INDIRECT_ECONOMIC_LOSS = model.INDIRECT_ECONOMIC_LOSS;
|
|
newModel.CONTRACTING_RESPONSIBILITY = model.CONTRACTING_RESPONSIBILITY;
|
|
newModel.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
newModel.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
newModel.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
newModel.POSITION_NAME = model.POSITION_NAME;
|
|
newModel.RESPONSIBILITY_TYPE = model.RESPONSIBILITY_TYPE;
|
|
newModel.RESPONSIBILITY_DESC = model.RESPONSIBILITY_DESC;
|
|
newModel.PERSONNEL_ID_NUMBER = model.PERSONNEL_ID_NUMBER;
|
|
newModel.PERSONNEL_NAME = model.PERSONNEL_NAME;
|
|
newModel.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
newModel.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
newModel.UPDATE_TIME = DateTime.Now;
|
|
//newModel.UPDATE_TIME = model.UPDATE_TIME;
|
|
newModel.CREATE_TIME = model.CREATE_TIME;
|
|
db.SANKU_ACCIDENT_RECORD.InsertOnSubmit(newModel);
|
|
}
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 违章作业
|
|
|
|
/// <summary>
|
|
/// 更新违章作业数据
|
|
/// </summary>
|
|
/// <param name="recordId">违章作业id</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string UpdateViolationRecord(string recordId, ref string message)
|
|
{
|
|
string result = string.Empty;
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var models = from tba in db.Check_ViolationPerson
|
|
join bu in db.Base_Unit on tba.UnitId equals bu.UnitId
|
|
join spp in db.SitePerson_Person on tba.PersonId equals spp.PersonId
|
|
join suc in db.Sys_User on tba.CompileMan equals suc.UserId
|
|
join bp in db.Base_Project on tba.ProjectId equals bp.ProjectId
|
|
join pms in db.Ads_pms_pro_info_build on bp.MasterSysId equals pms.Pro_id
|
|
where tba.ViolationPersonId == recordId
|
|
select new SankuViolation
|
|
{
|
|
RECORD_ID = tba.ViolationPersonId,
|
|
//PROJECT_CODE = pms.Pro_code.ToString(),
|
|
PROJECT_CODE = pms.Pro_code,
|
|
PROJECT_NAME = pms.Pro_name,
|
|
SUBCONTRACTOR_ID = bu.MasterAdOrgCode,
|
|
SUBCONTRACTOR_CODE = bu.CollCropCode,
|
|
SUBCONTRACTOR_NAME = bu.UnitName,
|
|
PERSONNEL_ID_NUMBER = spp.IdentityCard,
|
|
PERSONNEL_NAME = spp.PersonName,
|
|
VIOLATION_DATE = (DateTime)tba.ViolationDate,
|
|
VIOLATION_TYPE = tba.ViolationLevel,
|
|
VIOLATION_CONTENT = tba.ViolationDef,
|
|
PENALTY_RESULT = tba.RectificationStatus,
|
|
RECTIFICATION_STATUS = ViolatioResult(tba.HandleStep),
|
|
SUBMITTER_ID_NUMBER = suc.IdentityCard,
|
|
SUBMITTER_NAME = suc.UserName,
|
|
UPDATE_TIME = (DateTime)tba.CompileDate,
|
|
CREATE_TIME = (DateTime)tba.CompileDate
|
|
};
|
|
var model = models.ToList().FirstOrDefault();
|
|
List<string> errMsgs = new List<string>();
|
|
if (model != null)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(model.PROJECT_CODE))
|
|
{
|
|
errMsgs.Add("项目未关联集团主数据");
|
|
}
|
|
if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE))
|
|
{
|
|
errMsgs.Add("违章人员单位未关联主数据组织且统一社会信用代码为空");
|
|
}
|
|
else if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && !string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE) && model.SUBCONTRACTOR_CODE.Length != 18)
|
|
{
|
|
errMsgs.Add("违章人员单位未关联主数据组织且统一社会信用代码异常");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(model.PERSONNEL_ID_NUMBER) && model.PERSONNEL_ID_NUMBER.Length != 18)
|
|
{
|
|
errMsgs.Add("违章人员身份证异常");
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(model.SUBMITTER_ID_NUMBER) && model.SUBMITTER_ID_NUMBER.Length != 18)
|
|
//{
|
|
// errMsgs.Add("填报人身份证异常");
|
|
//}
|
|
if (errMsgs.Any())
|
|
{
|
|
message = $"无法更新三库,数据异常:{string.Join(",", errMsgs)}";
|
|
}
|
|
else
|
|
{
|
|
var exist = db.SANKU_VIOLATION.Where(x => x.RECORD_ID == model.RECORD_ID).FirstOrDefault();
|
|
if (exist != null)
|
|
{
|
|
//更新三库
|
|
exist.RECORD_ID = model.RECORD_ID;
|
|
exist.PROJECT_CODE = model.PROJECT_CODE;
|
|
exist.PROJECT_NAME = model.PROJECT_NAME;
|
|
exist.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
exist.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
exist.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
exist.PERSONNEL_ID_NUMBER = model.PERSONNEL_ID_NUMBER;
|
|
exist.PERSONNEL_NAME = model.PERSONNEL_NAME;
|
|
exist.VIOLATION_DATE = model.VIOLATION_DATE;
|
|
exist.VIOLATION_TYPE = model.VIOLATION_TYPE;
|
|
exist.VIOLATION_CONTENT = model.VIOLATION_CONTENT;
|
|
exist.PENALTY_RESULT = model.PENALTY_RESULT;
|
|
exist.RECTIFICATION_STATUS = model.RECTIFICATION_STATUS;
|
|
exist.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
exist.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
exist.UPDATE_TIME = DateTime.Now;
|
|
//exist.UPDATE_TIME = model.UPDATE_TIME;
|
|
//exist.CREATE_TIME = model.CREATE_TIME;
|
|
exist.ReportDate = null;
|
|
}
|
|
else
|
|
{
|
|
//新增三库
|
|
var newModel = new SANKU_VIOLATION();
|
|
newModel.RECORD_ID = model.RECORD_ID;
|
|
newModel.PROJECT_CODE = model.PROJECT_CODE;
|
|
newModel.PROJECT_NAME = model.PROJECT_NAME;
|
|
newModel.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
newModel.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
newModel.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
newModel.PERSONNEL_ID_NUMBER = model.PERSONNEL_ID_NUMBER;
|
|
newModel.PERSONNEL_NAME = model.PERSONNEL_NAME;
|
|
newModel.VIOLATION_DATE = model.VIOLATION_DATE;
|
|
newModel.VIOLATION_TYPE = model.VIOLATION_TYPE;
|
|
newModel.VIOLATION_CONTENT = model.VIOLATION_CONTENT;
|
|
newModel.PENALTY_RESULT = model.PENALTY_RESULT;
|
|
newModel.RECTIFICATION_STATUS = model.RECTIFICATION_STATUS;
|
|
newModel.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
newModel.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
newModel.UPDATE_TIME = DateTime.Now;
|
|
//newModel.UPDATE_TIME = model.UPDATE_TIME;
|
|
newModel.CREATE_TIME = model.CREATE_TIME;
|
|
db.SANKU_VIOLATION.InsertOnSubmit(newModel);
|
|
}
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 违章作业处理结果
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static string ViolatioResult(string value)
|
|
{
|
|
string result = string.Empty;
|
|
var constObj = BLL.ConstValue.GetConstByConstValueAndGroupId(value, BLL.ConstValue.Group_ViolationPersonHandleStep);
|
|
if (constObj != null)
|
|
{
|
|
result = constObj.ConstText;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 安全奖惩
|
|
|
|
/// <summary>
|
|
/// 更新安全奖惩数据
|
|
/// </summary>
|
|
/// <param name="recordId">安全奖惩id</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string UpdateSafetyRewardRecord(string recordId, ref string message)
|
|
{
|
|
string result = string.Empty;
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var models = from tba in db.Check_RewardAndPunish
|
|
join spp in db.SitePerson_Person on tba.RewardAndPunishMan equals spp.PersonId
|
|
join bu in db.Base_Unit on tba.ResponseUnit equals bu.UnitId
|
|
join suc in db.Sys_User on tba.CreateMan equals suc.UserId
|
|
join bp in db.Base_Project on tba.ProjectId equals bp.ProjectId
|
|
join pms in db.Ads_pms_pro_info_build on bp.MasterSysId equals pms.Pro_id
|
|
where tba.RewardAndPunishID == recordId
|
|
select new SankuSafetyReward
|
|
{
|
|
RECORD_ID = tba.RewardAndPunishID,
|
|
//PROJECT_CODE = pms.Pro_code.ToString(),
|
|
PROJECT_CODE = pms.Pro_code,
|
|
PROJECT_NAME = pms.Pro_name,
|
|
PERSONNEL_ID_NUMBER = spp.IdentityCard,
|
|
PERSONNEL_NAME = spp.PersonName,
|
|
REWARD_DATE = (DateTime)tba.Date,
|
|
REWARD_TYPE = tba.Type == 1 ? "奖励" : "处罚",
|
|
REWARD_UNIT_ID = bu.MasterAdOrgCode,
|
|
REWARD_UNIT_CODE = bu.CollCropCode,
|
|
REWARD_UNIT_NAME = bu.UnitName,
|
|
REWARD_CONTENT = tba.Description,
|
|
//REWARD_AMOUNT = (decimal)tba.Money,
|
|
REWARD_AMOUNT = SafetyRewardMoneyConvertValue(tba.Type, (decimal)tba.Money),
|
|
REWARD_LEVEL = SafetyRewardType(tba.Type, tba.RewardAndPunishType),
|
|
SUBMITTER_ID_NUMBER = suc.IdentityCard,
|
|
SUBMITTER_NAME = suc.UserName,
|
|
//UPDATE_TIME = (DateTime)tba.CompileDate,
|
|
//CREATE_TIME = (DateTime)tba.CompileDate
|
|
};
|
|
var model = models.ToList().FirstOrDefault();
|
|
List<string> errMsgs = new List<string>();
|
|
if (model != null)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(model.PROJECT_CODE))
|
|
{
|
|
errMsgs.Add("项目未关联集团主数据");
|
|
}
|
|
if (string.IsNullOrWhiteSpace(model.REWARD_UNIT_ID) && string.IsNullOrWhiteSpace(model.REWARD_UNIT_CODE))
|
|
{
|
|
errMsgs.Add("奖惩单位未关联主数据组织且统一社会信用代码为空");
|
|
}
|
|
else if (string.IsNullOrWhiteSpace(model.REWARD_UNIT_ID) && !string.IsNullOrWhiteSpace(model.REWARD_UNIT_CODE) && model.REWARD_UNIT_CODE.Length != 18)
|
|
{
|
|
errMsgs.Add("奖惩单位未关联主数据组织且统一社会信用代码异常");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.PERSONNEL_ID_NUMBER) && model.PERSONNEL_ID_NUMBER.Length != 18)
|
|
{
|
|
errMsgs.Add("奖惩人员身份证异常");
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(model.SUBMITTER_ID_NUMBER) && model.SUBMITTER_ID_NUMBER.Length != 18)
|
|
//{
|
|
// errMsgs.Add("填报人身份证异常");
|
|
//}
|
|
if (errMsgs.Any())
|
|
{
|
|
message = $"无法更新三库,数据异常:{string.Join(",", errMsgs)}";
|
|
}
|
|
else
|
|
{
|
|
var exist = db.SANKU_SAFETY_REWARD.Where(x => x.RECORD_ID == model.RECORD_ID).FirstOrDefault();
|
|
if (exist != null)
|
|
{
|
|
//更新三库
|
|
exist.RECORD_ID = model.RECORD_ID;
|
|
exist.PROJECT_CODE = model.PROJECT_CODE;
|
|
exist.PROJECT_NAME = model.PROJECT_NAME;
|
|
exist.PERSONNEL_ID_NUMBER = model.PERSONNEL_ID_NUMBER;
|
|
exist.PERSONNEL_NAME = model.PERSONNEL_NAME;
|
|
exist.REWARD_DATE = model.REWARD_DATE;
|
|
exist.REWARD_TYPE = model.REWARD_TYPE;
|
|
exist.REWARD_UNIT_ID = model.REWARD_UNIT_ID;
|
|
exist.REWARD_UNIT_CODE = model.REWARD_UNIT_CODE;
|
|
exist.REWARD_UNIT_NAME = model.REWARD_UNIT_NAME;
|
|
exist.REWARD_CONTENT = model.REWARD_CONTENT;
|
|
exist.REWARD_AMOUNT = model.REWARD_AMOUNT;
|
|
exist.REWARD_LEVEL = model.REWARD_LEVEL;
|
|
exist.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
exist.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
exist.UPDATE_TIME = DateTime.Now;
|
|
//exist.UPDATE_TIME = model.UPDATE_TIME;
|
|
//exist.CREATE_TIME = model.CREATE_TIME;
|
|
exist.ReportDate = null;
|
|
}
|
|
else
|
|
{
|
|
//新增三库
|
|
var newModel = new SANKU_SAFETY_REWARD();
|
|
newModel.RECORD_ID = model.RECORD_ID;
|
|
newModel.PROJECT_CODE = model.PROJECT_CODE;
|
|
newModel.PROJECT_NAME = model.PROJECT_NAME;
|
|
newModel.PERSONNEL_ID_NUMBER = model.PERSONNEL_ID_NUMBER;
|
|
newModel.PERSONNEL_NAME = model.PERSONNEL_NAME;
|
|
newModel.REWARD_DATE = model.REWARD_DATE;
|
|
newModel.REWARD_TYPE = model.REWARD_TYPE;
|
|
newModel.REWARD_UNIT_ID = model.REWARD_UNIT_ID;
|
|
newModel.REWARD_UNIT_CODE = model.REWARD_UNIT_CODE;
|
|
newModel.REWARD_UNIT_NAME = model.REWARD_UNIT_NAME;
|
|
newModel.REWARD_CONTENT = model.REWARD_CONTENT;
|
|
newModel.REWARD_AMOUNT = model.REWARD_AMOUNT;
|
|
newModel.REWARD_LEVEL = model.REWARD_LEVEL;
|
|
newModel.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
newModel.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
newModel.UPDATE_TIME = DateTime.Now;
|
|
//newModel.UPDATE_TIME = model.UPDATE_TIME;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_SAFETY_REWARD.InsertOnSubmit(newModel);
|
|
}
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 安全奖惩处理结果
|
|
/// </summary>
|
|
/// <param name="type">1:奖励、2:处罚</param>
|
|
/// <param name="value"></param>
|
|
/// <returns></returns>
|
|
public static string SafetyRewardType(int? type, string value)
|
|
{
|
|
string result = string.Empty;
|
|
if (type != null && !string.IsNullOrWhiteSpace(value))
|
|
{
|
|
string groupId = type == 1 ? BLL.ConstValue.Group_RewardType : BLL.ConstValue.Group_PunishType;
|
|
var constObj = BLL.ConstValue.GetConstByConstValueAndGroupId(value, groupId);
|
|
if (constObj != null)
|
|
{
|
|
result = constObj.ConstText;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 安全奖惩金额转换
|
|
/// </summary>
|
|
/// <param name="type">1:奖励、2:处罚</param>
|
|
/// <param name="money">原始金额,可null</param>
|
|
/// <returns>转换后金额</returns>
|
|
public static decimal? SafetyRewardMoneyConvertValue(int? type, decimal? money)
|
|
{
|
|
// 原始值为空,直接返回null
|
|
if (!money.HasValue)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
decimal val = money.Value;
|
|
|
|
switch (type)
|
|
{
|
|
case 1:
|
|
// 强制转为正数
|
|
return Math.Abs(val);
|
|
case 2:
|
|
// 强制转为负数
|
|
return -Math.Abs(val);
|
|
default:
|
|
// 未知类型,返回原值
|
|
return val;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 行政处罚
|
|
|
|
/// <summary>
|
|
/// 更新行政处罚数据
|
|
/// </summary>
|
|
/// <param name="recordId">行政处罚id</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string UpdateAdminPenaltyRecord(string recordId, ref string message)
|
|
{
|
|
string result = string.Empty;
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var models = from tba in db.Check_AdminPenalty
|
|
join bu in db.Base_Unit on tba.UnitId equals bu.UnitId
|
|
//join spp in db.SitePerson_Person on tba.RewardAndPunishMan equals spp.PersonId
|
|
join suc in db.Sys_User on tba.CompileMan equals suc.UserId
|
|
join bp in db.Base_Project on tba.ProjectId equals bp.ProjectId
|
|
join pms in db.Ads_pms_pro_info_build on bp.MasterSysId equals pms.Pro_id
|
|
where tba.PenaltyId == recordId
|
|
select new SankuAdminPenalty
|
|
{
|
|
RECORD_ID = tba.PenaltyId,
|
|
//PROJECT_CODE = pms.Pro_code.ToString(),
|
|
PROJECT_CODE = pms.Pro_code,
|
|
PROJECT_NAME = pms.Pro_name,
|
|
SUBCONTRACTOR_ID = bu.MasterAdOrgCode,
|
|
SUBCONTRACTOR_CODE = bu.CollCropCode,
|
|
SUBCONTRACTOR_NAME = bu.UnitName,
|
|
PENALTY_DATE = tba.PenaltyDate,
|
|
PENALTY_TYPE = tba.PenaltyType,
|
|
PENALTY_CONTENT = tba.PenaltyContent,
|
|
PENALTY_AMOUNT = tba.PenaltyAmount,
|
|
PENALTY_AUTHORITY = tba.PenaltyAuthority,
|
|
PENALTY_STATUS = tba.PenaltyStatus,
|
|
SUBMITTER_ID_NUMBER = suc.IdentityCard,
|
|
SUBMITTER_NAME = suc.UserName,
|
|
//UPDATE_TIME = (DateTime)tba.CompileDate,
|
|
//CREATE_TIME = (DateTime)tba.CompileDate
|
|
};
|
|
var model = models.ToList().FirstOrDefault();
|
|
List<string> errMsgs = new List<string>();
|
|
if (model != null)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(model.PROJECT_CODE))
|
|
{
|
|
errMsgs.Add("项目未关联集团主数据");
|
|
}
|
|
if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE))
|
|
{
|
|
errMsgs.Add("处罚单位未关联主数据组织且统一社会信用代码为空");
|
|
}
|
|
else if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && !string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE) && model.SUBCONTRACTOR_CODE.Length != 18)
|
|
{
|
|
errMsgs.Add("处罚单位未关联主数据组织且统一社会信用代码异常");
|
|
}
|
|
|
|
//if (!string.IsNullOrWhiteSpace(model.SUBMITTER_ID_NUMBER) && model.SUBMITTER_ID_NUMBER.Length != 18)
|
|
//{
|
|
// errMsgs.Add("填报人身份证异常");
|
|
//}
|
|
if (errMsgs.Any())
|
|
{
|
|
message = $"无法更新三库,数据异常:{string.Join(",", errMsgs)}";
|
|
}
|
|
else
|
|
{
|
|
var exist = db.SANKU_ADMIN_PENALTY.Where(x => x.RECORD_ID == model.RECORD_ID).FirstOrDefault();
|
|
if (exist != null)
|
|
{
|
|
//更新三库
|
|
exist.RECORD_ID = model.RECORD_ID;
|
|
exist.PROJECT_CODE = model.PROJECT_CODE;
|
|
exist.PROJECT_NAME = model.PROJECT_NAME;
|
|
exist.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
exist.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
exist.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
exist.PENALTY_DATE = model.PENALTY_DATE;
|
|
exist.PENALTY_TYPE = model.PENALTY_TYPE;
|
|
exist.PENALTY_CONTENT = model.PENALTY_CONTENT;
|
|
exist.PENALTY_AMOUNT = model.PENALTY_AMOUNT;
|
|
exist.PENALTY_AUTHORITY = model.PENALTY_AUTHORITY;
|
|
exist.PENALTY_STATUS = model.PENALTY_STATUS;
|
|
exist.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
exist.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
exist.UPDATE_TIME = DateTime.Now;
|
|
//exist.UPDATE_TIME = model.UPDATE_TIME;
|
|
//exist.CREATE_TIME = model.CREATE_TIME;
|
|
exist.ReportDate = null;
|
|
}
|
|
else
|
|
{
|
|
//新增三库
|
|
var newModel = new SANKU_ADMIN_PENALTY();
|
|
newModel.RECORD_ID = model.RECORD_ID;
|
|
newModel.PROJECT_CODE = model.PROJECT_CODE;
|
|
newModel.PROJECT_NAME = model.PROJECT_NAME;
|
|
newModel.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
newModel.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
newModel.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
newModel.PENALTY_DATE = model.PENALTY_DATE;
|
|
newModel.PENALTY_TYPE = model.PENALTY_TYPE;
|
|
newModel.PENALTY_CONTENT = model.PENALTY_CONTENT;
|
|
newModel.PENALTY_AMOUNT = model.PENALTY_AMOUNT;
|
|
newModel.PENALTY_AUTHORITY = model.PENALTY_AUTHORITY;
|
|
newModel.PENALTY_STATUS = model.PENALTY_STATUS;
|
|
newModel.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
newModel.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
newModel.UPDATE_TIME = DateTime.Now;
|
|
//newModel.UPDATE_TIME = model.UPDATE_TIME;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_ADMIN_PENALTY.InsertOnSubmit(newModel);
|
|
}
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 隐患记录
|
|
|
|
/// <summary>
|
|
/// 更新隐患记录数据
|
|
/// </summary>
|
|
/// <param name="noticeId">隐患整改单id</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string UpdateHazardRecord(string noticeId, ref string message)
|
|
{
|
|
string result = string.Empty;
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
List<string> errMsgs = new List<string>();
|
|
var list = db.Check_RectifyNoticesItem.Where(x => x.RectifyNoticesId == noticeId).ToList();
|
|
if (list.Any())
|
|
{
|
|
foreach (var obj in list)
|
|
{
|
|
int err = 0;
|
|
var models = from tba in db.Check_RectifyNoticesItem
|
|
join tbb in db.Check_RectifyNotices on tba.RectifyNoticesId equals tbb.RectifyNoticesId
|
|
join bu in db.Base_Unit on tbb.UnitId equals bu.UnitId
|
|
join suzg in db.Sys_User on tbb.DutyPersonId equals suzg.UserId
|
|
join suc in db.Sys_User on tbb.CompleteManId equals suc.UserId
|
|
join bp in db.Base_Project on tbb.ProjectId equals bp.ProjectId
|
|
join pms in db.Ads_pms_pro_info_build on bp.MasterSysId equals pms.Pro_id
|
|
where tba.RectifyNoticesItemId == obj.RectifyNoticesItemId
|
|
select new SankuHazard
|
|
{
|
|
RECORD_ID = tba.RectifyNoticesItemId,
|
|
//PROJECT_CODE = pms.Pro_code.ToString(),
|
|
PROJECT_CODE = pms.Pro_code,
|
|
PROJECT_NAME = pms.Pro_name,
|
|
SUBCONTRACTOR_ID = bu.MasterAdOrgCode,
|
|
SUBCONTRACTOR_CODE = bu.CollCropCode,
|
|
SUBCONTRACTOR_NAME = bu.UnitName,
|
|
RESPONSIBLE_PERSONNEL_ID_NUMBER = suzg.IdentityCard,
|
|
RESPONSIBLE_PERSONNEL_NAME = suzg.UserName,
|
|
RECTIFIER_PERSONNEL_ID_NUMBER = suzg.IdentityCard,
|
|
RECTIFIER_PERSONNEL_NAME = suzg.UserName,
|
|
DISCOVERY_DATE = tbb.CheckedDate == null ? DateTime.Now : (DateTime)tbb.CheckedDate,
|
|
HAZARD_TYPE = HazardType(tba.RectifyId),
|
|
HAZARD_LEVEL = HazardLevel(tbb.HiddenHazardType),
|
|
HAZARD_CONTENT = tba.WrongContent,
|
|
RECTIFICATION_STATUS = HazardState(tbb.States),
|
|
RECTIFICATION_DEADLINE_ID = tba.LimitTime == null ? DateTime.Now.AddDays(7) : (DateTime)tba.LimitTime,
|
|
SUBMITTER_ID_NUMBER = suc.IdentityCard,
|
|
SUBMITTER_NAME = suc.UserName,
|
|
//UPDATE_TIME = (DateTime)tba.CompileDate,
|
|
//CREATE_TIME = (DateTime)tba.CompileDate
|
|
};
|
|
var model = models.ToList().FirstOrDefault();
|
|
if (model != null)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(model.PROJECT_CODE))
|
|
{
|
|
err++;
|
|
errMsgs.Add("项目未关联集团主数据");
|
|
}
|
|
if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE))
|
|
{
|
|
err++;
|
|
errMsgs.Add("受检单位单位未关联主数据组织且统一社会信用代码为空");
|
|
}
|
|
else if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && !string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE) && model.SUBCONTRACTOR_CODE.Length != 18)
|
|
{
|
|
err++;
|
|
errMsgs.Add("受检单位单位未关联主数据组织且统一社会信用代码异常");
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(model.SUBMITTER_ID_NUMBER) && model.SUBMITTER_ID_NUMBER.Length != 18)
|
|
//{
|
|
// errMsgs.Add("填报人身份证异常");
|
|
//}
|
|
if (err > 0)
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
var exist = db.SANKU_HAZARD.Where(x => x.RECORD_ID == model.RECORD_ID).FirstOrDefault();
|
|
if (exist != null)
|
|
{
|
|
//更新三库
|
|
exist.RECORD_ID = model.RECORD_ID;
|
|
exist.PROJECT_CODE = model.PROJECT_CODE;
|
|
exist.PROJECT_NAME = model.PROJECT_NAME;
|
|
exist.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
exist.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
exist.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
exist.RESPONSIBLE_PERSONNEL_ID_NUMBER = model.RESPONSIBLE_PERSONNEL_ID_NUMBER;
|
|
exist.RESPONSIBLE_PERSONNEL_NAME = model.RESPONSIBLE_PERSONNEL_NAME;
|
|
exist.RECTIFIER_PERSONNEL_ID_NUMBER = model.RECTIFIER_PERSONNEL_ID_NUMBER;
|
|
exist.RECTIFIER_PERSONNEL_NAME = model.RECTIFIER_PERSONNEL_NAME;
|
|
exist.DISCOVERY_DATE = model.DISCOVERY_DATE;
|
|
exist.HAZARD_TYPE = model.HAZARD_TYPE;
|
|
exist.HAZARD_LEVEL = model.HAZARD_LEVEL;
|
|
exist.HAZARD_CONTENT = model.HAZARD_CONTENT;
|
|
exist.RECTIFICATION_STATUS = model.RECTIFICATION_STATUS;
|
|
exist.RECTIFICATION_DEADLINE_ID = model.RECTIFICATION_DEADLINE_ID;
|
|
exist.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
exist.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
exist.UPDATE_TIME = DateTime.Now;
|
|
//exist.UPDATE_TIME = model.UPDATE_TIME;
|
|
//exist.CREATE_TIME = model.CREATE_TIME;
|
|
exist.ReportDate = null;
|
|
}
|
|
else
|
|
{
|
|
//新增三库
|
|
var newModel = new SANKU_HAZARD();
|
|
newModel.RECORD_ID = model.RECORD_ID;
|
|
newModel.PROJECT_CODE = model.PROJECT_CODE;
|
|
newModel.PROJECT_NAME = model.PROJECT_NAME;
|
|
newModel.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
newModel.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
newModel.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
newModel.PROJECT_NAME = model.PROJECT_NAME;
|
|
newModel.RESPONSIBLE_PERSONNEL_ID_NUMBER = model.RESPONSIBLE_PERSONNEL_ID_NUMBER;
|
|
newModel.RESPONSIBLE_PERSONNEL_NAME = model.RESPONSIBLE_PERSONNEL_NAME;
|
|
newModel.RECTIFIER_PERSONNEL_ID_NUMBER = model.RECTIFIER_PERSONNEL_ID_NUMBER;
|
|
newModel.RECTIFIER_PERSONNEL_NAME = model.RECTIFIER_PERSONNEL_NAME;
|
|
newModel.DISCOVERY_DATE = model.DISCOVERY_DATE;
|
|
newModel.HAZARD_TYPE = model.HAZARD_TYPE;
|
|
newModel.HAZARD_LEVEL = model.HAZARD_LEVEL;
|
|
newModel.HAZARD_CONTENT = model.HAZARD_CONTENT;
|
|
newModel.RECTIFICATION_STATUS = model.RECTIFICATION_STATUS;
|
|
newModel.RECTIFICATION_DEADLINE_ID = model.RECTIFICATION_DEADLINE_ID;
|
|
newModel.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
newModel.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
newModel.UPDATE_TIME = DateTime.Now;
|
|
//newModel.UPDATE_TIME = model.UPDATE_TIME;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_HAZARD.InsertOnSubmit(newModel);
|
|
}
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
|
|
errMsgs = errMsgs.Distinct().ToList();
|
|
if (errMsgs.Any())
|
|
{
|
|
message = $"部分无法更新三库,数据异常:{string.Join(",", errMsgs)}";
|
|
}
|
|
}
|
|
//else
|
|
//{
|
|
// message = $"不更新三库,整改单无隐患明细";
|
|
//}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 隐患状态
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
/// <returns></returns>
|
|
public static string HazardState(string state)
|
|
{
|
|
string result = string.Empty;
|
|
if (!string.IsNullOrWhiteSpace(state))
|
|
{
|
|
switch (state)
|
|
{
|
|
//case "1":
|
|
// result = "待提交";
|
|
// break;
|
|
case "2":
|
|
result = "未整改";
|
|
break;
|
|
case "3":
|
|
result = "整改中";
|
|
break;
|
|
case "4":
|
|
result = "已整改";
|
|
break;
|
|
case "5":
|
|
result = "已验收";
|
|
break;
|
|
default:
|
|
result = "未整改";
|
|
break;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 隐患等级
|
|
/// </summary>
|
|
/// <param name="type"></param>
|
|
/// <returns></returns>
|
|
public static string HazardLevel(string type)
|
|
{
|
|
string result = string.Empty;
|
|
if (!string.IsNullOrWhiteSpace(type))
|
|
{
|
|
switch (type)
|
|
{
|
|
case "1":
|
|
result = "一般隐患";
|
|
break;
|
|
case "2":
|
|
result = "较大隐患";
|
|
break;
|
|
case "3":
|
|
result = "重大隐患";
|
|
break;
|
|
//case "4":
|
|
// result = "特别重大隐患";
|
|
// break;
|
|
default:
|
|
result = "一般隐患";
|
|
break;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 隐患类型
|
|
/// </summary>
|
|
/// <param name="rectifyId"></param>
|
|
/// <returns></returns>
|
|
public static string HazardType(string rectifyId)
|
|
{
|
|
string result = string.Empty;
|
|
if (!string.IsNullOrWhiteSpace(rectifyId))
|
|
{
|
|
var db = Funs.DB;
|
|
var obj = db.Technique_Rectify.Where(x => x.SupRectifyId == "0" && x.RectifyId == rectifyId).FirstOrDefault();
|
|
if (obj != null)
|
|
{
|
|
result = obj.RectifyName;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 教育培训
|
|
|
|
/// <summary>
|
|
/// 更新教育培训数据
|
|
/// </summary>
|
|
/// <param name="trainingId">教育培训id</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string UpdateTrainingRecord(string trainingId, ref string message)
|
|
{
|
|
string result = string.Empty;
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
List<string> errMsgs = new List<string>();
|
|
var list = db.EduTrain_TrainRecordDetail.Where(x => x.TrainingId == trainingId).ToList();
|
|
if (list.Any())
|
|
{
|
|
foreach (var obj in list)
|
|
{
|
|
int err = 0;
|
|
var models = from tba in db.EduTrain_TrainRecordDetail
|
|
join tbb in db.EduTrain_TrainRecord on tba.TrainingId equals tbb.TrainingId
|
|
join bu in db.Base_Unit on tbb.UnitIds equals bu.UnitId
|
|
join spp in db.SitePerson_Person on tba.PersonId equals spp.PersonId
|
|
join spu in db.Base_Unit on spp.UnitId equals spu.UnitId
|
|
join bty in db.Base_TrainType on tbb.TrainTypeId equals bty.TrainTypeId
|
|
join suc in db.Sys_User on tbb.CompileMan equals suc.UserId
|
|
join bp in db.Base_Project on tbb.ProjectId equals bp.ProjectId
|
|
join pms in db.Ads_pms_pro_info_build on bp.MasterSysId equals pms.Pro_id
|
|
where tba.TrainDetailId == obj.TrainDetailId
|
|
select new SankuTraining
|
|
{
|
|
RECORD_ID = tba.TrainDetailId,
|
|
PROJECT_CODE = pms.Pro_code,
|
|
PROJECT_NAME = pms.Pro_name,
|
|
SUBCONTRACTOR_ID = spu.MasterAdOrgCode,
|
|
SUBCONTRACTOR_CODE = spu.CollCropCode,
|
|
SUBCONTRACTOR_NAME = spu.UnitName,
|
|
PERSONNEL_ID_NUMBER = spp.IdentityCard,
|
|
PERSONNEL_NAME = spp.PersonName,
|
|
TRAINING_DATE = tbb.TrainStartDate == null ? DateTime.Now : (DateTime)tbb.TrainStartDate,
|
|
TRAINING_NAME = TrainingName(tbb.TrainTitle, bty.TrainTypeName),
|
|
TRAINING_TYPE = bty.TrainTypeName,
|
|
TRAINING_DURATION = tbb.TeachHour,
|
|
TRAINING_ORGANIZER = bu.UnitName,
|
|
TRAINING_CONTENT = TrainingContent(tbb.TrainContent, bty.TrainTypeName),
|
|
TRAINING_RESULT = TrainingResult(tba.CheckResult),
|
|
SUBMITTER_ID_NUMBER = suc.IdentityCard,
|
|
SUBMITTER_NAME = suc.UserName,
|
|
//UPDATE_TIME = (DateTime)tba.CompileDate,
|
|
//CREATE_TIME = (DateTime)tba.CompileDate
|
|
};
|
|
var model = models.ToList().FirstOrDefault();
|
|
if (model != null)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(model.PROJECT_CODE))
|
|
{
|
|
err++;
|
|
errMsgs.Add("项目未关联集团主数据");
|
|
}
|
|
if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE))
|
|
{
|
|
err++;
|
|
errMsgs.Add("人员所属单位单位未关联主数据组织且统一社会信用代码为空");
|
|
}
|
|
else if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && !string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE) && model.SUBCONTRACTOR_CODE.Length != 18)
|
|
{
|
|
err++;
|
|
errMsgs.Add("人员所属单位单位未关联主数据组织且统一社会信用代码异常");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(model.PERSONNEL_ID_NUMBER) && model.PERSONNEL_ID_NUMBER.Length != 18)
|
|
{
|
|
err++;
|
|
errMsgs.Add($"培训人员{model.PERSONNEL_NAME}身份证异常");
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(model.SUBMITTER_ID_NUMBER) && model.SUBMITTER_ID_NUMBER.Length != 18)
|
|
//{
|
|
// errMsgs.Add("填报人身份证异常");
|
|
//}
|
|
if (err > 0)
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
var exist = db.SANKU_TRAINING.Where(x => x.RECORD_ID == model.RECORD_ID).FirstOrDefault();
|
|
if (exist != null)
|
|
{
|
|
//更新三库
|
|
exist.RECORD_ID = model.RECORD_ID;
|
|
exist.PROJECT_CODE = model.PROJECT_CODE;
|
|
exist.PROJECT_NAME = model.PROJECT_NAME;
|
|
exist.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
exist.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
exist.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
exist.PERSONNEL_ID_NUMBER = model.PERSONNEL_ID_NUMBER;
|
|
exist.PERSONNEL_NAME = model.PERSONNEL_NAME;
|
|
exist.TRAINING_DATE = model.TRAINING_DATE;
|
|
exist.TRAINING_NAME = model.TRAINING_NAME;
|
|
exist.TRAINING_TYPE = model.TRAINING_TYPE;
|
|
exist.TRAINING_DURATION = model.TRAINING_DURATION;
|
|
exist.TRAINING_ORGANIZER = model.TRAINING_ORGANIZER;
|
|
exist.TRAINING_CONTENT = model.TRAINING_CONTENT;
|
|
exist.TRAINING_RESULT = model.TRAINING_RESULT;
|
|
exist.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
exist.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
exist.UPDATE_TIME = DateTime.Now;
|
|
//exist.UPDATE_TIME = model.UPDATE_TIME;
|
|
//exist.CREATE_TIME = model.CREATE_TIME;
|
|
exist.ReportDate = null;
|
|
}
|
|
else
|
|
{
|
|
//新增三库
|
|
var newModel = new SANKU_TRAINING();
|
|
newModel.RECORD_ID = model.RECORD_ID;
|
|
newModel.PROJECT_CODE = model.PROJECT_CODE;
|
|
newModel.PROJECT_NAME = model.PROJECT_NAME;
|
|
newModel.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
newModel.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
newModel.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
newModel.PERSONNEL_ID_NUMBER = model.PERSONNEL_ID_NUMBER;
|
|
newModel.PERSONNEL_NAME = model.PERSONNEL_NAME;
|
|
newModel.TRAINING_DATE = model.TRAINING_DATE;
|
|
newModel.TRAINING_NAME = model.TRAINING_NAME;
|
|
newModel.TRAINING_TYPE = model.TRAINING_TYPE;
|
|
newModel.TRAINING_DURATION = model.TRAINING_DURATION;
|
|
newModel.TRAINING_ORGANIZER = model.TRAINING_ORGANIZER;
|
|
newModel.TRAINING_CONTENT = model.TRAINING_CONTENT;
|
|
newModel.TRAINING_RESULT = model.TRAINING_RESULT;
|
|
newModel.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
newModel.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
newModel.UPDATE_TIME = DateTime.Now;
|
|
//newModel.UPDATE_TIME = model.UPDATE_TIME;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_TRAINING.InsertOnSubmit(newModel);
|
|
}
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
|
|
errMsgs = errMsgs.Distinct().ToList();
|
|
if (errMsgs.Any())
|
|
{
|
|
message = $"部分无法更新三库,数据异常:{string.Join(",", errMsgs)}";
|
|
}
|
|
}
|
|
//else
|
|
//{
|
|
// message = $"不更新三库,整改单无隐患明细";
|
|
//}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 培训名称
|
|
/// </summary>
|
|
/// <param name="title"></param>
|
|
/// <param name="type"></param>
|
|
/// <returns></returns>
|
|
public static string TrainingName(string title, string type)
|
|
{
|
|
string result = type;
|
|
if (!string.IsNullOrWhiteSpace(title))
|
|
{
|
|
result = title;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 培训内容
|
|
/// </summary>
|
|
/// <param name="content"></param>
|
|
/// <param name="type"></param>
|
|
/// <returns></returns>
|
|
public static string TrainingContent(string content, string type)
|
|
{
|
|
string result = type;
|
|
if (!string.IsNullOrWhiteSpace(content))
|
|
{
|
|
result = content;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 培训结果
|
|
/// </summary>
|
|
/// <param name="value"></param>
|
|
/// <returns></returns>
|
|
public static string TrainingResult(bool? value)
|
|
{
|
|
string result = string.Empty;
|
|
switch (value)
|
|
{
|
|
case true:
|
|
result = "通过";
|
|
break;
|
|
case false:
|
|
result = "未通过";
|
|
break;
|
|
default:
|
|
result = "缺考";
|
|
break;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 考试考核
|
|
|
|
/// <summary>
|
|
/// 更新考试考核数据
|
|
/// </summary>
|
|
/// <param name="testPlanId">考试计划id</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string UpdateExaminationRecord(string testPlanId, ref string message)
|
|
{
|
|
string result = string.Empty;
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
List<string> errMsgs = new List<string>();
|
|
var list = db.Training_TestRecord.Where(x => x.TestPlanId == testPlanId).ToList();
|
|
if (list.Any())
|
|
{
|
|
foreach (var obj in list)
|
|
{
|
|
int err = 0;
|
|
var models = from tba in db.Training_TestRecord
|
|
join tbb in db.Training_TestPlan on tba.TestPlanId equals tbb.TestPlanId
|
|
join spp in db.SitePerson_Person on tba.TestManId equals spp.PersonId
|
|
join bu in db.Base_Unit on spp.UnitId equals bu.UnitId
|
|
join suc in db.Sys_User on tbb.PlanManId equals suc.UserId
|
|
join bp in db.Base_Project on tbb.ProjectId equals bp.ProjectId
|
|
join pms in db.Ads_pms_pro_info_build on bp.MasterSysId equals pms.Pro_id
|
|
where tba.TestRecordId == obj.TestRecordId
|
|
select new SankuExamination
|
|
{
|
|
RECORD_ID = tba.TestRecordId,
|
|
PROJECT_CODE = pms.Pro_code,
|
|
PROJECT_NAME = pms.Pro_name,
|
|
SUBCONTRACTOR_ID = bu.MasterAdOrgCode,
|
|
SUBCONTRACTOR_CODE = bu.CollCropCode,
|
|
SUBCONTRACTOR_NAME = bu.UnitName,
|
|
PERSONNEL_ID_NUMBER = spp.IdentityCard,
|
|
PERSONNEL_NAME = spp.PersonName,
|
|
EXAM_DATE = tbb.TestEndTime == null ? DateTime.Now : (DateTime)tbb.TestEndTime,
|
|
EXAM_NAME = tbb.PlanName,
|
|
EXAM_TYPE = "理论考试",
|
|
EXAM_SCORE = tba.TestScores,
|
|
EXAM_RESULT = ExamResult(tba.TestScores),
|
|
EXAM_ORGANIZER = tbb.UnitNames,
|
|
SUBMITTER_ID_NUMBER = suc.IdentityCard,
|
|
SUBMITTER_NAME = suc.UserName,
|
|
//UPDATE_TIME = (DateTime)tba.CompileDate,
|
|
//CREATE_TIME = (DateTime)tba.CompileDate
|
|
};
|
|
var model = models.ToList().FirstOrDefault();
|
|
if (model != null)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(model.PROJECT_CODE))
|
|
{
|
|
err++;
|
|
errMsgs.Add("项目未关联集团主数据");
|
|
}
|
|
if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE))
|
|
{
|
|
err++;
|
|
errMsgs.Add("人员所属单位单位未关联主数据组织且统一社会信用代码为空");
|
|
}
|
|
else if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && !string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE) && model.SUBCONTRACTOR_CODE.Length != 18)
|
|
{
|
|
err++;
|
|
errMsgs.Add("人员所属单位单位未关联主数据组织且统一社会信用代码异常");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(model.PERSONNEL_ID_NUMBER) && model.PERSONNEL_ID_NUMBER.Length != 18)
|
|
{
|
|
err++;
|
|
errMsgs.Add($"考试人员{model.PERSONNEL_NAME}身份证异常");
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(model.SUBMITTER_ID_NUMBER) && model.SUBMITTER_ID_NUMBER.Length != 18)
|
|
//{
|
|
// errMsgs.Add("填报人身份证异常");
|
|
//}
|
|
|
|
if (err > 0)
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
var exist = db.SANKU_EXAMINATION.Where(x => x.RECORD_ID == model.RECORD_ID).FirstOrDefault();
|
|
if (exist != null)
|
|
{
|
|
//更新三库
|
|
exist.RECORD_ID = model.RECORD_ID;
|
|
exist.PROJECT_CODE = model.PROJECT_CODE;
|
|
exist.PROJECT_NAME = model.PROJECT_NAME;
|
|
exist.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
exist.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
exist.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
exist.PERSONNEL_ID_NUMBER = model.PERSONNEL_ID_NUMBER;
|
|
exist.PERSONNEL_NAME = model.PERSONNEL_NAME;
|
|
exist.EXAM_DATE = model.EXAM_DATE;
|
|
exist.EXAM_NAME = model.EXAM_NAME;
|
|
exist.EXAM_TYPE = model.EXAM_TYPE;
|
|
exist.EXAM_SCORE = model.EXAM_SCORE;
|
|
exist.EXAM_RESULT = model.EXAM_RESULT;
|
|
exist.EXAM_ORGANIZER = model.EXAM_ORGANIZER;
|
|
exist.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
exist.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
exist.UPDATE_TIME = DateTime.Now;
|
|
//exist.UPDATE_TIME = model.UPDATE_TIME;
|
|
//exist.CREATE_TIME = model.CREATE_TIME;
|
|
exist.ReportDate = null;
|
|
}
|
|
else
|
|
{
|
|
//新增三库
|
|
var newModel = new SANKU_EXAMINATION();
|
|
newModel.RECORD_ID = model.RECORD_ID;
|
|
newModel.PROJECT_CODE = model.PROJECT_CODE;
|
|
newModel.PROJECT_NAME = model.PROJECT_NAME;
|
|
newModel.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
newModel.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
newModel.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
newModel.PERSONNEL_ID_NUMBER = model.PERSONNEL_ID_NUMBER;
|
|
newModel.PERSONNEL_NAME = model.PERSONNEL_NAME;
|
|
newModel.EXAM_DATE = model.EXAM_DATE;
|
|
newModel.EXAM_NAME = model.EXAM_NAME;
|
|
newModel.EXAM_TYPE = model.EXAM_TYPE;
|
|
newModel.EXAM_SCORE = model.EXAM_SCORE;
|
|
newModel.EXAM_RESULT = model.EXAM_RESULT;
|
|
newModel.EXAM_ORGANIZER = model.EXAM_ORGANIZER;
|
|
newModel.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
newModel.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
newModel.UPDATE_TIME = DateTime.Now;
|
|
//newModel.UPDATE_TIME = model.UPDATE_TIME;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_EXAMINATION.InsertOnSubmit(newModel);
|
|
}
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
errMsgs = errMsgs.Distinct().ToList();
|
|
if (errMsgs.Any())
|
|
{
|
|
message = $"部分无法更新三库,数据异常:{string.Join(",", errMsgs)}";
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新考试考核数据【单条】
|
|
/// </summary>
|
|
/// <param name="testRecordId">考试考核id</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string UpdateExaminationRecordItem(string testRecordId, ref string message)
|
|
{
|
|
string result = string.Empty;
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
List<string> errMsgs = new List<string>();
|
|
|
|
int err = 0;
|
|
var models = from tba in db.Training_TestRecord
|
|
join tbb in db.Training_TestPlan on tba.TestPlanId equals tbb.TestPlanId
|
|
join spp in db.SitePerson_Person on tba.TestManId equals spp.PersonId
|
|
join bu in db.Base_Unit on spp.UnitId equals bu.UnitId
|
|
join suc in db.Sys_User on tbb.PlanManId equals suc.UserId
|
|
join bp in db.Base_Project on tbb.ProjectId equals bp.ProjectId
|
|
join pms in db.Ads_pms_pro_info_build on bp.MasterSysId equals pms.Pro_id
|
|
where tba.TestRecordId == testRecordId
|
|
select new SankuExamination
|
|
{
|
|
RECORD_ID = tba.TestRecordId,
|
|
PROJECT_CODE = pms.Pro_code,
|
|
PROJECT_NAME = pms.Pro_name,
|
|
SUBCONTRACTOR_ID = bu.MasterAdOrgCode,
|
|
SUBCONTRACTOR_CODE = bu.CollCropCode,
|
|
SUBCONTRACTOR_NAME = bu.UnitName,
|
|
PERSONNEL_ID_NUMBER = spp.IdentityCard,
|
|
PERSONNEL_NAME = spp.PersonName,
|
|
EXAM_DATE = tbb.TestEndTime == null ? DateTime.Now : (DateTime)tbb.TestEndTime,
|
|
EXAM_NAME = tbb.PlanName,
|
|
EXAM_TYPE = "理论考试",
|
|
EXAM_SCORE = tba.TestScores,
|
|
EXAM_RESULT = ExamResult(tba.TestScores),
|
|
EXAM_ORGANIZER = tbb.UnitNames,
|
|
SUBMITTER_ID_NUMBER = suc.IdentityCard,
|
|
SUBMITTER_NAME = suc.UserName,
|
|
//UPDATE_TIME = (DateTime)tba.CompileDate,
|
|
//CREATE_TIME = (DateTime)tba.CompileDate
|
|
};
|
|
var model = models.ToList().FirstOrDefault();
|
|
if (model != null)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(model.PROJECT_CODE))
|
|
{
|
|
err++;
|
|
errMsgs.Add("项目未关联集团主数据");
|
|
}
|
|
if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE))
|
|
{
|
|
err++;
|
|
errMsgs.Add("人员所属单位未关联主数据组织且统一社会信用代码为空");
|
|
}
|
|
else if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && !string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE) && model.SUBCONTRACTOR_CODE.Length != 18)
|
|
{
|
|
err++;
|
|
errMsgs.Add("人员所属单位未关联主数据组织且统一社会信用代码异常");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(model.PERSONNEL_ID_NUMBER) && model.PERSONNEL_ID_NUMBER.Length != 18)
|
|
{
|
|
errMsgs.Add($"考试人员{model.PERSONNEL_NAME}身份证异常");
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(model.SUBMITTER_ID_NUMBER) && model.SUBMITTER_ID_NUMBER.Length != 18)
|
|
//{
|
|
// errMsgs.Add("填报人身份证异常");
|
|
//}
|
|
if (errMsgs.Any())
|
|
{
|
|
message = $"无法更新三库,数据异常:{string.Join(",", errMsgs)}";
|
|
}
|
|
else
|
|
{
|
|
var exist = db.SANKU_EXAMINATION.Where(x => x.RECORD_ID == model.RECORD_ID).FirstOrDefault();
|
|
if (exist != null)
|
|
{
|
|
//更新三库
|
|
exist.RECORD_ID = model.RECORD_ID;
|
|
exist.PROJECT_CODE = model.PROJECT_CODE;
|
|
exist.PROJECT_NAME = model.PROJECT_NAME;
|
|
exist.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
exist.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
exist.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
exist.PERSONNEL_ID_NUMBER = model.PERSONNEL_ID_NUMBER;
|
|
exist.PERSONNEL_NAME = model.PERSONNEL_NAME;
|
|
exist.EXAM_DATE = model.EXAM_DATE;
|
|
exist.EXAM_NAME = model.EXAM_NAME;
|
|
exist.EXAM_TYPE = model.EXAM_TYPE;
|
|
exist.EXAM_SCORE = model.EXAM_SCORE;
|
|
exist.EXAM_RESULT = model.EXAM_RESULT;
|
|
exist.EXAM_ORGANIZER = model.EXAM_ORGANIZER;
|
|
exist.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
exist.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
exist.UPDATE_TIME = DateTime.Now;
|
|
//exist.UPDATE_TIME = model.UPDATE_TIME;
|
|
//exist.CREATE_TIME = model.CREATE_TIME;
|
|
exist.ReportDate = null;
|
|
}
|
|
else
|
|
{
|
|
//新增三库
|
|
var newModel = new SANKU_EXAMINATION();
|
|
newModel.RECORD_ID = model.RECORD_ID;
|
|
newModel.PROJECT_CODE = model.PROJECT_CODE;
|
|
newModel.PROJECT_NAME = model.PROJECT_NAME;
|
|
newModel.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
newModel.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
newModel.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
newModel.PERSONNEL_ID_NUMBER = model.PERSONNEL_ID_NUMBER;
|
|
newModel.PERSONNEL_NAME = model.PERSONNEL_NAME;
|
|
newModel.EXAM_DATE = model.EXAM_DATE;
|
|
newModel.EXAM_NAME = model.EXAM_NAME;
|
|
newModel.EXAM_TYPE = model.EXAM_TYPE;
|
|
newModel.EXAM_SCORE = model.EXAM_SCORE;
|
|
newModel.EXAM_RESULT = model.EXAM_RESULT;
|
|
newModel.EXAM_ORGANIZER = model.EXAM_ORGANIZER;
|
|
newModel.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
newModel.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
newModel.UPDATE_TIME = DateTime.Now;
|
|
//newModel.UPDATE_TIME = model.UPDATE_TIME;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_EXAMINATION.InsertOnSubmit(newModel);
|
|
}
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 考试结果
|
|
/// </summary>
|
|
/// <param name="value"></param>
|
|
/// <returns></returns>
|
|
public static string ExamResult(decimal? value)
|
|
{
|
|
string result = string.Empty;
|
|
if (value != null)
|
|
{
|
|
if (value >= 80)
|
|
{
|
|
result = "通过";
|
|
}
|
|
else if (value == 0)
|
|
{
|
|
result = "缺考";
|
|
}
|
|
else
|
|
{
|
|
result = "未通过";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result = "缺考";
|
|
}
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 危大工程
|
|
|
|
/// <summary>
|
|
/// 更新危大工程数据
|
|
/// </summary>
|
|
/// <param name="hazardId">危大工程id</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string UpdateDangerousEngineeringRecord(string hazardId, ref string message)
|
|
{
|
|
string result = string.Empty;
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var models = from tba in db.Solution_LargerHazard
|
|
join bu in db.Base_Unit on tba.UnitId equals bu.UnitId
|
|
join spp in db.SitePerson_Person on tba.StandbyPersonnelId equals spp.PersonId
|
|
join suc in db.Sys_User on tba.RecardMan equals suc.UserId
|
|
join bp in db.Base_Project on tba.ProjectId equals bp.ProjectId
|
|
join pms in db.Ads_pms_pro_info_build on bp.MasterSysId equals pms.Pro_id
|
|
where tba.HazardId == hazardId
|
|
select new SankuDangerousEngineering
|
|
{
|
|
RECORD_ID = tba.HazardId,
|
|
//PROJECT_CODE = pms.Pro_code.ToString(),
|
|
PROJECT_CODE = pms.Pro_code,
|
|
PROJECT_NAME = pms.Pro_name,
|
|
SUBCONTRACTOR_ID = bu.MasterAdOrgCode,
|
|
SUBCONTRACTOR_CODE = bu.CollCropCode,
|
|
SUBCONTRACTOR_NAME = bu.UnitName,
|
|
ENGINEERING_DATE = tba.ExpectedTime == null ? DateTime.Now : (DateTime)tba.ExpectedTime,
|
|
ENGINEERING_NAME = tba.HazardName,
|
|
ENGINEERING_TYPE = LargerHazardType(tba.HazardType),
|
|
ENGINEERING_ADDRESS = tba.Address,
|
|
ENGINEERING_DESC = tba.Descriptions,
|
|
STANDBY_PERSONNEL_ID_NUMBER = spp.IdentityCard,
|
|
STANDBY_PERSONNEL_NAME = spp.PersonName,
|
|
SUBMITTER_ID_NUMBER = suc.IdentityCard,
|
|
SUBMITTER_NAME = suc.UserName,
|
|
UPDATE_TIME = (DateTime)tba.RecordTime,
|
|
CREATE_TIME = (DateTime)tba.RecordTime
|
|
};
|
|
string sql = db.GetCommand(models).CommandText;
|
|
var model = models.ToList().FirstOrDefault();
|
|
List<string> errMsgs = new List<string>();
|
|
if (model != null)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(model.PROJECT_CODE))
|
|
{
|
|
errMsgs.Add("项目未关联集团主数据");
|
|
}
|
|
if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE))
|
|
{
|
|
errMsgs.Add("施工单位未关联主数据组织且统一社会信用代码为空");
|
|
}
|
|
else if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && !string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE) && model.SUBCONTRACTOR_CODE.Length != 18)
|
|
{
|
|
errMsgs.Add("施工单位未关联主数据组织且统一社会信用代码异常");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(model.STANDBY_PERSONNEL_ID_NUMBER) && model.STANDBY_PERSONNEL_ID_NUMBER.Length != 18)
|
|
{
|
|
errMsgs.Add("旁站人员身份证异常");
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(model.SUBMITTER_ID_NUMBER) && model.SUBMITTER_ID_NUMBER.Length != 18)
|
|
//{
|
|
// errMsgs.Add("填报人身份证异常");
|
|
//}
|
|
if (errMsgs.Any())
|
|
{
|
|
message = $"无法更新三库,数据异常:{string.Join(",", errMsgs)}";
|
|
}
|
|
else
|
|
{
|
|
var exist = db.SANKU_DANGEROUS_ENGINEERING.Where(x => x.RECORD_ID == model.RECORD_ID).FirstOrDefault();
|
|
if (exist != null)
|
|
{
|
|
//更新三库
|
|
exist.RECORD_ID = model.RECORD_ID;
|
|
exist.PROJECT_CODE = model.PROJECT_CODE;
|
|
exist.PROJECT_NAME = model.PROJECT_NAME;
|
|
exist.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
exist.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
exist.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
exist.ENGINEERING_DATE = model.ENGINEERING_DATE;
|
|
exist.ENGINEERING_NAME = model.ENGINEERING_NAME;
|
|
exist.ENGINEERING_TYPE = model.ENGINEERING_TYPE;
|
|
exist.ENGINEERING_ADDRESS = model.ENGINEERING_ADDRESS;
|
|
exist.ENGINEERING_DESC = model.ENGINEERING_DESC;
|
|
exist.STANDBY_PERSONNEL_ID_NUMBER = model.STANDBY_PERSONNEL_ID_NUMBER;
|
|
exist.STANDBY_PERSONNEL_NAME = model.STANDBY_PERSONNEL_NAME;
|
|
//exist.SOURCE_SYSTEM_ID = model.SOURCE_SYSTEM_ID;
|
|
//exist.SOURCE_SYSTEM_NAME = model.SOURCE_SYSTEM_NAME;
|
|
exist.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
exist.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
exist.UPDATE_TIME = DateTime.Now;
|
|
//exist.UPDATE_TIME = model.UPDATE_TIME;
|
|
//exist.CREATE_TIME = model.CREATE_TIME;
|
|
exist.ReportDate = null;
|
|
}
|
|
else
|
|
{
|
|
//新增三库
|
|
var newModel = new SANKU_DANGEROUS_ENGINEERING();
|
|
newModel.RECORD_ID = model.RECORD_ID;
|
|
newModel.PROJECT_CODE = model.PROJECT_CODE;
|
|
newModel.PROJECT_NAME = model.PROJECT_NAME;
|
|
newModel.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
newModel.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
newModel.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
newModel.ENGINEERING_DATE = model.ENGINEERING_DATE;
|
|
newModel.ENGINEERING_NAME = model.ENGINEERING_NAME;
|
|
newModel.ENGINEERING_TYPE = model.ENGINEERING_TYPE;
|
|
newModel.ENGINEERING_ADDRESS = model.ENGINEERING_ADDRESS;
|
|
newModel.ENGINEERING_DESC = model.ENGINEERING_DESC;
|
|
newModel.STANDBY_PERSONNEL_ID_NUMBER = model.STANDBY_PERSONNEL_ID_NUMBER;
|
|
newModel.STANDBY_PERSONNEL_NAME = model.STANDBY_PERSONNEL_NAME;
|
|
//newModel.SOURCE_SYSTEM_ID = model.SOURCE_SYSTEM_ID;
|
|
//newModel.SOURCE_SYSTEM_NAME = model.SOURCE_SYSTEM_NAME;
|
|
newModel.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
newModel.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
newModel.UPDATE_TIME = DateTime.Now;
|
|
//newModel.UPDATE_TIME = model.UPDATE_TIME;
|
|
newModel.CREATE_TIME = model.CREATE_TIME;
|
|
db.SANKU_DANGEROUS_ENGINEERING.InsertOnSubmit(newModel);
|
|
}
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 危大工程类型
|
|
/// </summary>
|
|
/// <param name="type"></param>
|
|
/// <returns></returns>
|
|
public static string LargerHazardType(string type)
|
|
{
|
|
string result = string.Empty;
|
|
if (!string.IsNullOrWhiteSpace(type))
|
|
{
|
|
var db = Funs.DB;
|
|
var obj = db.Sys_Const.Where(x => x.GroupId == ConstValue.Group_LargerHazardType && x.ConstValue == type).FirstOrDefault();
|
|
if (obj != null)
|
|
{
|
|
result = obj.ConstText;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result = "其它";
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 网格化巡查
|
|
|
|
/// <summary>
|
|
/// 更新网格化巡查数据
|
|
/// </summary>
|
|
/// <param name="hazardId">网格化巡查id</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string UpdateGridPatrolRecord(string hazardId, ref string message)
|
|
{
|
|
string result = string.Empty;
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var models = from tba in db.HSSE_Hazard_HazardRegister
|
|
join bp in db.Base_Project on tba.ProjectId equals bp.ProjectId
|
|
join pms in db.Ads_pms_pro_info_build on bp.MasterSysId equals pms.Pro_id
|
|
join suzg in db.Sys_User on tba.CheckManId equals suzg.UserId
|
|
join bu in db.Base_Unit on suzg.UnitId equals bu.UnitId
|
|
where tba.HazardRegisterId == hazardId
|
|
select new SankuGridPatrol
|
|
{
|
|
RECORD_ID = tba.HazardRegisterId,
|
|
PROJECT_CODE = pms.Pro_code,
|
|
PROJECT_NAME = pms.Pro_name,
|
|
SUBCONTRACTOR_ID = bu.MasterAdOrgCode,
|
|
SUBCONTRACTOR_CODE = bu.CollCropCode,
|
|
SUBCONTRACTOR_NAME = bu.UnitName,
|
|
PERSONNEL_ID_NUMBER = suzg.IdentityCard,
|
|
PERSONNEL_NAME = suzg.UserName,
|
|
PATROL_TIME = tba.CheckTime == null ? DateTime.Now : (DateTime)tba.CheckTime,
|
|
PATROL_STATUS = "已完成",
|
|
SUBMITTER_ID_NUMBER = suzg.IdentityCard,
|
|
SUBMITTER_NAME = suzg.UserName,
|
|
UPDATE_TIME = (DateTime)tba.CheckTime,
|
|
CREATE_TIME = (DateTime)tba.CheckTime
|
|
};
|
|
string sql = db.GetCommand(models).CommandText;
|
|
var model = models.ToList().FirstOrDefault();
|
|
List<string> errMsgs = new List<string>();
|
|
if (model != null)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(model.PROJECT_CODE))
|
|
{
|
|
errMsgs.Add("项目未关联集团主数据");
|
|
}
|
|
if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE))
|
|
{
|
|
errMsgs.Add("检查人单位未关联主数据组织且统一社会信用代码为空");
|
|
}
|
|
else if (string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_ID) && !string.IsNullOrWhiteSpace(model.SUBCONTRACTOR_CODE) && model.SUBCONTRACTOR_CODE.Length != 18)
|
|
{
|
|
errMsgs.Add("检查人单位未关联主数据组织且统一社会信用代码异常");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(model.PERSONNEL_ID_NUMBER) && model.PERSONNEL_ID_NUMBER.Length != 18)
|
|
{
|
|
errMsgs.Add("检查人身份证异常");
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(model.SUBMITTER_ID_NUMBER) && model.SUBMITTER_ID_NUMBER.Length != 18)
|
|
//{
|
|
// errMsgs.Add("填报人身份证异常");
|
|
//}
|
|
if (errMsgs.Any())
|
|
{
|
|
message = $"无法更新三库,数据异常:{string.Join(",", errMsgs)}";
|
|
}
|
|
else
|
|
{
|
|
bool isExist = false;
|
|
var exist = db.SANKU_GRID_PATROL.Where(x => x.PERSONNEL_ID_NUMBER == model.PERSONNEL_ID_NUMBER).OrderByDescending(x => x.PATROL_TIME).FirstOrDefault();
|
|
if (exist != null)
|
|
{
|
|
isExist = exist.PATROL_TIME.ToString("yyyy-MM-dd") == model.PATROL_TIME.ToString("yyyy-MM-dd");
|
|
}
|
|
if (isExist == false)
|
|
{
|
|
//新增三库
|
|
var newModel = new SANKU_GRID_PATROL();
|
|
newModel.RECORD_ID = model.RECORD_ID;
|
|
newModel.PROJECT_CODE = model.PROJECT_CODE;
|
|
newModel.PROJECT_NAME = model.PROJECT_NAME;
|
|
exist.SUBCONTRACTOR_ID = model.SUBCONTRACTOR_ID;
|
|
newModel.SUBCONTRACTOR_CODE = model.SUBCONTRACTOR_CODE;
|
|
newModel.SUBCONTRACTOR_NAME = model.SUBCONTRACTOR_NAME;
|
|
newModel.PERSONNEL_ID_NUMBER = model.PERSONNEL_ID_NUMBER;
|
|
newModel.PERSONNEL_NAME = model.PERSONNEL_NAME;
|
|
newModel.PATROL_TIME = model.PATROL_TIME;
|
|
newModel.PATROL_STATUS = model.PATROL_STATUS;
|
|
//newModel.SOURCE_SYSTEM_ID = model.SOURCE_SYSTEM_ID;
|
|
//newModel.SOURCE_SYSTEM_NAME = model.SOURCE_SYSTEM_NAME;
|
|
newModel.SUBMITTER_ID_NUMBER = model.SUBMITTER_ID_NUMBER;
|
|
newModel.SUBMITTER_NAME = model.SUBMITTER_NAME;
|
|
newModel.UPDATE_TIME = DateTime.Now;
|
|
//newModel.UPDATE_TIME = model.UPDATE_TIME;
|
|
newModel.CREATE_TIME = model.CREATE_TIME;
|
|
db.SANKU_GRID_PATROL.InsertOnSubmit(newModel);
|
|
}
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region 汇总上报
|
|
|
|
#region 事故事件
|
|
|
|
/// <summary>
|
|
/// 汇总上报事故事件数据
|
|
/// </summary>
|
|
/// <param name="userName">操作人,为空:定时任务自动上报</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string ReportAccidentRecords(string userName, ref string message)
|
|
{
|
|
string code = "0";
|
|
string result = "失败";
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var thisUnit = CommonService.GetIsThisUnit();
|
|
string filePath = Funs.SGGLUrl;
|
|
|
|
//获取事故事件数据
|
|
List<Model.SANKU_ACCIDENT_RECORD> reportDatas = (from x in db.SANKU_ACCIDENT_RECORD where x.ReportDate == null select x).ToList();
|
|
int total = reportDatas.Count();
|
|
int succ = 0;
|
|
|
|
if (!reportDatas.Any())
|
|
{
|
|
message = "暂无需要上报的事故事件数据!无需上报!";
|
|
return code;
|
|
}
|
|
|
|
#region 上报数据
|
|
|
|
string opType = !string.IsNullOrWhiteSpace(userName) ? "手动上报" : "自动上报";
|
|
userName = !string.IsNullOrWhiteSpace(userName) ? userName : "定时任务";
|
|
try
|
|
{
|
|
string baseurl = $"{SysConstSetService.CNCECPath}/api/SanKu/ReportAccidentRecords";
|
|
string contenttype = "application/json;charset=unicode";
|
|
Hashtable newToken = new Hashtable
|
|
{
|
|
{ "token", ServerService.GetToken().Token }
|
|
};
|
|
var pushData = new SankuReportAccident
|
|
{
|
|
CollCropCode = thisUnit.CollCropCode,//分包单位社会统一信用码
|
|
UnitId = thisUnit.UnitId,//分包单位Id
|
|
UnitName = thisUnit.UnitName,//分包单位名称
|
|
OpType = opType,
|
|
Operator = userName,
|
|
Items = reportDatas,
|
|
};
|
|
var pushContent = JsonConvert.SerializeObject(pushData);
|
|
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报事故事件数据】:{pushContent}");
|
|
var strJosn = APIGetHttpService.Http(baseurl, "Post", contenttype, newToken, pushContent);
|
|
if (!string.IsNullOrEmpty(strJosn))
|
|
{
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报事故事件数据】:{strJosn}");
|
|
JObject obj = JObject.Parse(strJosn);
|
|
code = obj["code"].ToString();
|
|
message = obj["message"].ToString();
|
|
if (code == "1")
|
|
{
|
|
var dateNow = DateTime.Now;
|
|
foreach (var o in reportDatas)
|
|
{
|
|
var item = db.SANKU_ACCIDENT_RECORD.FirstOrDefault(e => e.ACCIDENT_RECORD_ID == o.ACCIDENT_RECORD_ID);
|
|
if (item != null)
|
|
{
|
|
item.ReportDate = dateNow;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
result = "成功";
|
|
//message = $"成功上报事故事件数据{total}条!";
|
|
|
|
//var getIds = Funs.GetStrListByStr(obj["data"].ToString(), ',');
|
|
//if (getIds.Any())
|
|
//{
|
|
// succ = getIds.Count;
|
|
// var dateNow = DateTime.Now;
|
|
// foreach (var id in getIds)
|
|
// {
|
|
// var item = db.SANKU_ACCIDENT_RECORD.FirstOrDefault(e => e.ACCIDENT_ID == id);
|
|
// if (item != null)
|
|
// {
|
|
// item.ReportDate = dateNow;
|
|
// db.SubmitChanges();
|
|
// }
|
|
// }
|
|
//}
|
|
//message = $"成功上报事故事件数据{succ}/{total}条!";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
message = "无返回结果";
|
|
}
|
|
|
|
////记录上报结果日志
|
|
//Model.SANKU_REPORT_LOG newModel = new Model.SANKU_REPORT_LOG();
|
|
//newModel.OPTYPE = opType;
|
|
//newModel.CONTENT = "上报事故事件数据";
|
|
//newModel.RESULT = code == "1" ? "成功" : "失败";
|
|
//newModel.DETAIL = message;
|
|
//newModel.OPERATOR = userName;
|
|
//newModel.CREATE_TIME = DateTime.Now;
|
|
//db.SANKU_REPORT_LOG.InsertOnSubmit(newModel);
|
|
//db.SubmitChanges();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result = "异常";
|
|
message = JsonConvert.SerializeObject(ex);
|
|
//message = ex.Message.ToString();
|
|
}
|
|
|
|
|
|
//记录上报结果日志
|
|
Model.SANKU_REPORT_LOG newModel = new Model.SANKU_REPORT_LOG();
|
|
newModel.OPTYPE = opType;
|
|
newModel.CONTENT = "上报事故事件数据";
|
|
newModel.RESULT = result;
|
|
newModel.DETAIL = message;
|
|
newModel.OPERATOR = userName;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_REPORT_LOG.InsertOnSubmit(newModel);
|
|
db.SubmitChanges();
|
|
|
|
#endregion
|
|
|
|
return code;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 违章作业
|
|
|
|
/// <summary>
|
|
/// 汇总上报违章作业数据
|
|
/// </summary>
|
|
/// <param name="userName">操作人,为空:定时任务自动上报</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string ReportViolationRecords(string userName, ref string message)
|
|
{
|
|
string code = "0";
|
|
string result = "失败";
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var thisUnit = CommonService.GetIsThisUnit();
|
|
string filePath = Funs.SGGLUrl;
|
|
|
|
//获取违章作业数据
|
|
List<Model.SANKU_VIOLATION> reportDatas = (from x in db.SANKU_VIOLATION where x.ReportDate == null select x).ToList();
|
|
int total = reportDatas.Count();
|
|
int succ = 0;
|
|
|
|
if (!reportDatas.Any())
|
|
{
|
|
message = "暂无需要上报的违章作业数据!无需上报!";
|
|
return code;
|
|
}
|
|
|
|
#region 上报数据
|
|
|
|
string opType = !string.IsNullOrWhiteSpace(userName) ? "手动上报" : "自动上报";
|
|
userName = !string.IsNullOrWhiteSpace(userName) ? userName : "定时任务";
|
|
try
|
|
{
|
|
string baseurl = $"{SysConstSetService.CNCECPath}/api/SanKu/ReportViolationRecords";
|
|
string contenttype = "application/json;charset=unicode";
|
|
Hashtable newToken = new Hashtable
|
|
{
|
|
{ "token", ServerService.GetToken().Token }
|
|
};
|
|
var pushData = new SankuReportViolation
|
|
{
|
|
CollCropCode = thisUnit.CollCropCode,//分包单位社会统一信用码
|
|
UnitId = thisUnit.UnitId,//分包单位Id
|
|
UnitName = thisUnit.UnitName,//分包单位名称
|
|
OpType = opType,
|
|
Operator = userName,
|
|
Items = reportDatas,
|
|
};
|
|
var pushContent = JsonConvert.SerializeObject(pushData);
|
|
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报违章作业数据】:{pushContent}");
|
|
var strJosn = APIGetHttpService.Http(baseurl, "Post", contenttype, newToken, pushContent);
|
|
if (!string.IsNullOrEmpty(strJosn))
|
|
{
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报违章作业数据】:{strJosn}");
|
|
JObject obj = JObject.Parse(strJosn);
|
|
code = obj["code"].ToString();
|
|
message = obj["message"].ToString();
|
|
if (code == "1")
|
|
{
|
|
var dateNow = DateTime.Now;
|
|
foreach (var o in reportDatas)
|
|
{
|
|
var item = db.SANKU_VIOLATION.FirstOrDefault(e => e.VIOLATION_ID == o.VIOLATION_ID);
|
|
if (item != null)
|
|
{
|
|
item.ReportDate = dateNow;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
result = "成功";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
message = "无返回结果";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result = "异常";
|
|
message = JsonConvert.SerializeObject(ex);
|
|
//message = ex.Message.ToString();
|
|
}
|
|
|
|
|
|
//记录上报结果日志
|
|
Model.SANKU_REPORT_LOG newModel = new Model.SANKU_REPORT_LOG();
|
|
newModel.OPTYPE = opType;
|
|
newModel.CONTENT = "上报违章作业数据";
|
|
newModel.RESULT = result;
|
|
newModel.DETAIL = message;
|
|
newModel.OPERATOR = userName;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_REPORT_LOG.InsertOnSubmit(newModel);
|
|
db.SubmitChanges();
|
|
|
|
#endregion
|
|
|
|
return code;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 安全奖惩
|
|
|
|
/// <summary>
|
|
/// 汇总上报安全奖惩数据
|
|
/// </summary>
|
|
/// <param name="userName">操作人,为空:定时任务自动上报</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string ReportSafetyRewardRecords(string userName, ref string message)
|
|
{
|
|
string code = "0";
|
|
string result = "失败";
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var thisUnit = CommonService.GetIsThisUnit();
|
|
string filePath = Funs.SGGLUrl;
|
|
|
|
//获取安全奖惩数据
|
|
List<Model.SANKU_SAFETY_REWARD> reportDatas = (from x in db.SANKU_SAFETY_REWARD where x.ReportDate == null select x).ToList();
|
|
int total = reportDatas.Count();
|
|
int succ = 0;
|
|
|
|
if (!reportDatas.Any())
|
|
{
|
|
message = "暂无需要上报的安全奖惩数据!无需上报!";
|
|
return code;
|
|
}
|
|
|
|
#region 上报数据
|
|
|
|
string opType = !string.IsNullOrWhiteSpace(userName) ? "手动上报" : "自动上报";
|
|
userName = !string.IsNullOrWhiteSpace(userName) ? userName : "定时任务";
|
|
try
|
|
{
|
|
string baseurl = $"{SysConstSetService.CNCECPath}/api/SanKu/ReportSafetyRewardRecords";
|
|
string contenttype = "application/json;charset=unicode";
|
|
Hashtable newToken = new Hashtable
|
|
{
|
|
{ "token", ServerService.GetToken().Token }
|
|
};
|
|
var pushData = new SankuReportSafetyReward
|
|
{
|
|
CollCropCode = thisUnit.CollCropCode,//分包单位社会统一信用码
|
|
UnitId = thisUnit.UnitId,//分包单位Id
|
|
UnitName = thisUnit.UnitName,//分包单位名称
|
|
OpType = opType,
|
|
Operator = userName,
|
|
Items = reportDatas,
|
|
};
|
|
var pushContent = JsonConvert.SerializeObject(pushData);
|
|
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报安全奖惩数据】:{pushContent}");
|
|
var strJosn = APIGetHttpService.Http(baseurl, "Post", contenttype, newToken, pushContent);
|
|
if (!string.IsNullOrEmpty(strJosn))
|
|
{
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报安全奖惩数据】:{strJosn}");
|
|
JObject obj = JObject.Parse(strJosn);
|
|
code = obj["code"].ToString();
|
|
message = obj["message"].ToString();
|
|
if (code == "1")
|
|
{
|
|
var dateNow = DateTime.Now;
|
|
foreach (var o in reportDatas)
|
|
{
|
|
var item = db.SANKU_SAFETY_REWARD.FirstOrDefault(e => e.REWARD_ID == o.REWARD_ID);
|
|
if (item != null)
|
|
{
|
|
item.ReportDate = dateNow;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
result = "成功";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
message = "无返回结果";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result = "异常";
|
|
message = JsonConvert.SerializeObject(ex);
|
|
//message = ex.Message.ToString();
|
|
}
|
|
|
|
//记录上报结果日志
|
|
Model.SANKU_REPORT_LOG newModel = new Model.SANKU_REPORT_LOG();
|
|
newModel.OPTYPE = opType;
|
|
newModel.CONTENT = "上报安全奖惩数据";
|
|
newModel.RESULT = result;
|
|
newModel.DETAIL = message;
|
|
newModel.OPERATOR = userName;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_REPORT_LOG.InsertOnSubmit(newModel);
|
|
db.SubmitChanges();
|
|
|
|
#endregion
|
|
|
|
return code;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 行政处罚
|
|
|
|
/// <summary>
|
|
/// 汇总上报行政处罚数据
|
|
/// </summary>
|
|
/// <param name="userName">操作人,为空:定时任务自动上报</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string ReportAdminPenaltyRecords(string userName, ref string message)
|
|
{
|
|
string code = "0";
|
|
string result = "失败";
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var thisUnit = CommonService.GetIsThisUnit();
|
|
string filePath = Funs.SGGLUrl;
|
|
|
|
//获取行政处罚数据
|
|
List<Model.SANKU_ADMIN_PENALTY> reportDatas = (from x in db.SANKU_ADMIN_PENALTY where x.ReportDate == null select x).ToList();
|
|
int total = reportDatas.Count();
|
|
int succ = 0;
|
|
|
|
if (!reportDatas.Any())
|
|
{
|
|
message = "暂无需要上报的行政处罚数据!无需上报!";
|
|
return code;
|
|
}
|
|
|
|
#region 上报数据
|
|
|
|
string opType = !string.IsNullOrWhiteSpace(userName) ? "手动上报" : "自动上报";
|
|
userName = !string.IsNullOrWhiteSpace(userName) ? userName : "定时任务";
|
|
try
|
|
{
|
|
string baseurl = $"{SysConstSetService.CNCECPath}/api/SanKu/ReportAdminPenaltyRecords";
|
|
string contenttype = "application/json;charset=unicode";
|
|
Hashtable newToken = new Hashtable
|
|
{
|
|
{ "token", ServerService.GetToken().Token }
|
|
};
|
|
var pushData = new SankuReportAdminPenalty
|
|
{
|
|
CollCropCode = thisUnit.CollCropCode,//分包单位社会统一信用码
|
|
UnitId = thisUnit.UnitId,//分包单位Id
|
|
UnitName = thisUnit.UnitName,//分包单位名称
|
|
OpType = opType,
|
|
Operator = userName,
|
|
Items = reportDatas,
|
|
};
|
|
var pushContent = JsonConvert.SerializeObject(pushData);
|
|
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报行政处罚数据】:{pushContent}");
|
|
var strJosn = APIGetHttpService.Http(baseurl, "Post", contenttype, newToken, pushContent);
|
|
if (!string.IsNullOrEmpty(strJosn))
|
|
{
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报行政处罚数据】:{strJosn}");
|
|
JObject obj = JObject.Parse(strJosn);
|
|
code = obj["code"].ToString();
|
|
message = obj["message"].ToString();
|
|
if (code == "1")
|
|
{
|
|
var dateNow = DateTime.Now;
|
|
foreach (var o in reportDatas)
|
|
{
|
|
var item = db.SANKU_ADMIN_PENALTY.FirstOrDefault(e => e.PENALTY_ID == o.PENALTY_ID);
|
|
if (item != null)
|
|
{
|
|
item.ReportDate = dateNow;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
result = "成功";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
message = "无返回结果";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result = "异常";
|
|
message = JsonConvert.SerializeObject(ex);
|
|
//message = ex.Message.ToString();
|
|
}
|
|
|
|
//记录上报结果日志
|
|
Model.SANKU_REPORT_LOG newModel = new Model.SANKU_REPORT_LOG();
|
|
newModel.OPTYPE = opType;
|
|
newModel.CONTENT = "上报行政处罚数据";
|
|
newModel.RESULT = result;
|
|
newModel.DETAIL = message;
|
|
newModel.OPERATOR = userName;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_REPORT_LOG.InsertOnSubmit(newModel);
|
|
db.SubmitChanges();
|
|
|
|
#endregion
|
|
|
|
return code;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 隐患记录
|
|
|
|
/// <summary>
|
|
/// 汇总上报隐患记录数据
|
|
/// </summary>
|
|
/// <param name="userName">操作人,为空:定时任务自动上报</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string ReportHazardRecords(string userName, ref string message)
|
|
{
|
|
string code = "0";
|
|
string result = "失败";
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var thisUnit = CommonService.GetIsThisUnit();
|
|
string filePath = Funs.SGGLUrl;
|
|
|
|
//获取隐患记录数据
|
|
List<Model.SANKU_HAZARD> reportDatas = (from x in db.SANKU_HAZARD where x.ReportDate == null select x).ToList();
|
|
int total = reportDatas.Count();
|
|
int succ = 0;
|
|
|
|
if (!reportDatas.Any())
|
|
{
|
|
message = "暂无需要上报的隐患记录数据!无需上报!";
|
|
return code;
|
|
}
|
|
|
|
#region 上报数据
|
|
|
|
string opType = !string.IsNullOrWhiteSpace(userName) ? "手动上报" : "自动上报";
|
|
userName = !string.IsNullOrWhiteSpace(userName) ? userName : "定时任务";
|
|
try
|
|
{
|
|
string baseurl = $"{SysConstSetService.CNCECPath}/api/SanKu/ReportHazardRecords";
|
|
string contenttype = "application/json;charset=unicode";
|
|
Hashtable newToken = new Hashtable
|
|
{
|
|
{ "token", ServerService.GetToken().Token }
|
|
};
|
|
var pushData = new SankuReportHazard
|
|
{
|
|
CollCropCode = thisUnit.CollCropCode,//分包单位社会统一信用码
|
|
UnitId = thisUnit.UnitId,//分包单位Id
|
|
UnitName = thisUnit.UnitName,//分包单位名称
|
|
OpType = opType,
|
|
Operator = userName,
|
|
Items = reportDatas,
|
|
};
|
|
var pushContent = JsonConvert.SerializeObject(pushData);
|
|
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报隐患记录数据】:{pushContent}");
|
|
var strJosn = APIGetHttpService.Http(baseurl, "Post", contenttype, newToken, pushContent);
|
|
if (!string.IsNullOrEmpty(strJosn))
|
|
{
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报隐患记录数据】:{strJosn}");
|
|
JObject obj = JObject.Parse(strJosn);
|
|
code = obj["code"].ToString();
|
|
message = obj["message"].ToString();
|
|
if (code == "1")
|
|
{
|
|
var dateNow = DateTime.Now;
|
|
foreach (var o in reportDatas)
|
|
{
|
|
var item = db.SANKU_HAZARD.FirstOrDefault(e => e.HAZARD_ID == o.HAZARD_ID);
|
|
if (item != null)
|
|
{
|
|
item.ReportDate = dateNow;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
result = "成功";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
message = "无返回结果";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result = "异常";
|
|
message = JsonConvert.SerializeObject(ex);
|
|
//message = ex.Message.ToString();
|
|
}
|
|
|
|
//记录上报结果日志
|
|
Model.SANKU_REPORT_LOG newModel = new Model.SANKU_REPORT_LOG();
|
|
newModel.OPTYPE = opType;
|
|
newModel.CONTENT = "上报隐患记录数据";
|
|
newModel.RESULT = result;
|
|
newModel.DETAIL = message;
|
|
newModel.OPERATOR = userName;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_REPORT_LOG.InsertOnSubmit(newModel);
|
|
db.SubmitChanges();
|
|
|
|
#endregion
|
|
|
|
return code;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 教育培训
|
|
|
|
/// <summary>
|
|
/// 汇总上报教育培训数据
|
|
/// </summary>
|
|
/// <param name="userName">操作人,为空:定时任务自动上报</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string ReportTrainingRecords(string userName, ref string message)
|
|
{
|
|
string code = "0";
|
|
string result = "失败";
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var thisUnit = CommonService.GetIsThisUnit();
|
|
string filePath = Funs.SGGLUrl;
|
|
|
|
//获取教育培训数据
|
|
List<Model.SANKU_TRAINING> reportDatas = (from x in db.SANKU_TRAINING where x.ReportDate == null select x).ToList();
|
|
int total = reportDatas.Count();
|
|
int succ = 0;
|
|
|
|
if (!reportDatas.Any())
|
|
{
|
|
message = "暂无需要上报的教育培训数据!无需上报!";
|
|
return code;
|
|
}
|
|
|
|
#region 上报数据
|
|
|
|
string opType = !string.IsNullOrWhiteSpace(userName) ? "手动上报" : "自动上报";
|
|
userName = !string.IsNullOrWhiteSpace(userName) ? userName : "定时任务";
|
|
try
|
|
{
|
|
string baseurl = $"{SysConstSetService.CNCECPath}/api/SanKu/ReportTrainingRecords";
|
|
string contenttype = "application/json;charset=unicode";
|
|
Hashtable newToken = new Hashtable
|
|
{
|
|
{ "token", ServerService.GetToken().Token }
|
|
};
|
|
var pushData = new SankuReportTraining
|
|
{
|
|
CollCropCode = thisUnit.CollCropCode,//分包单位社会统一信用码
|
|
UnitId = thisUnit.UnitId,//分包单位Id
|
|
UnitName = thisUnit.UnitName,//分包单位名称
|
|
OpType = opType,
|
|
Operator = userName,
|
|
Items = reportDatas,
|
|
};
|
|
var pushContent = JsonConvert.SerializeObject(pushData);
|
|
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报教育培训数据】:{pushContent}");
|
|
var strJosn = APIGetHttpService.Http(baseurl, "Post", contenttype, newToken, pushContent);
|
|
if (!string.IsNullOrEmpty(strJosn))
|
|
{
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报教育培训数据】:{strJosn}");
|
|
JObject obj = JObject.Parse(strJosn);
|
|
code = obj["code"].ToString();
|
|
message = obj["message"].ToString();
|
|
if (code == "1")
|
|
{
|
|
var dateNow = DateTime.Now;
|
|
foreach (var o in reportDatas)
|
|
{
|
|
var item = db.SANKU_TRAINING.FirstOrDefault(e => e.TRAINING_ID == o.TRAINING_ID);
|
|
if (item != null)
|
|
{
|
|
item.ReportDate = dateNow;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
result = "成功";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
message = "无返回结果";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result = "异常";
|
|
message = JsonConvert.SerializeObject(ex);
|
|
//message = ex.Message.ToString();
|
|
}
|
|
|
|
//记录上报结果日志
|
|
Model.SANKU_REPORT_LOG newModel = new Model.SANKU_REPORT_LOG();
|
|
newModel.OPTYPE = opType;
|
|
newModel.CONTENT = "上报教育培训数据";
|
|
newModel.RESULT = result;
|
|
newModel.DETAIL = message;
|
|
newModel.OPERATOR = userName;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_REPORT_LOG.InsertOnSubmit(newModel);
|
|
db.SubmitChanges();
|
|
|
|
#endregion
|
|
|
|
return code;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 考试考核
|
|
|
|
/// <summary>
|
|
/// 汇总上报考试考核数据
|
|
/// </summary>
|
|
/// <param name="userName">操作人,为空:定时任务自动上报</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string ReportExaminationRecords(string userName, ref string message)
|
|
{
|
|
string code = "0";
|
|
string result = "失败";
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var thisUnit = CommonService.GetIsThisUnit();
|
|
string filePath = Funs.SGGLUrl;
|
|
|
|
//获取考试考核数据
|
|
List<Model.SANKU_EXAMINATION> reportDatas = (from x in db.SANKU_EXAMINATION where x.ReportDate == null select x).ToList();
|
|
int total = reportDatas.Count();
|
|
int succ = 0;
|
|
|
|
if (!reportDatas.Any())
|
|
{
|
|
message = "暂无需要上报的考试考核数据!无需上报!";
|
|
return code;
|
|
}
|
|
|
|
#region 上报数据
|
|
|
|
string opType = !string.IsNullOrWhiteSpace(userName) ? "手动上报" : "自动上报";
|
|
userName = !string.IsNullOrWhiteSpace(userName) ? userName : "定时任务";
|
|
try
|
|
{
|
|
string baseurl = $"{SysConstSetService.CNCECPath}/api/SanKu/ReportExaminationRecords";
|
|
string contenttype = "application/json;charset=unicode";
|
|
Hashtable newToken = new Hashtable
|
|
{
|
|
{ "token", ServerService.GetToken().Token }
|
|
};
|
|
var pushData = new SankuReportExamination
|
|
{
|
|
CollCropCode = thisUnit.CollCropCode,//分包单位社会统一信用码
|
|
UnitId = thisUnit.UnitId,//分包单位Id
|
|
UnitName = thisUnit.UnitName,//分包单位名称
|
|
OpType = opType,
|
|
Operator = userName,
|
|
Items = reportDatas,
|
|
};
|
|
var pushContent = JsonConvert.SerializeObject(pushData);
|
|
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报考试考核数据】:{pushContent}");
|
|
var strJosn = APIGetHttpService.Http(baseurl, "Post", contenttype, newToken, pushContent);
|
|
if (!string.IsNullOrEmpty(strJosn))
|
|
{
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报考试考核数据】:{strJosn}");
|
|
JObject obj = JObject.Parse(strJosn);
|
|
code = obj["code"].ToString();
|
|
message = obj["message"].ToString();
|
|
if (code == "1")
|
|
{
|
|
var dateNow = DateTime.Now;
|
|
foreach (var o in reportDatas)
|
|
{
|
|
var item = db.SANKU_EXAMINATION.FirstOrDefault(e => e.EXAMINATION_ID == o.EXAMINATION_ID);
|
|
if (item != null)
|
|
{
|
|
item.ReportDate = dateNow;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
result = "成功";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
message = "无返回结果";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result = "异常";
|
|
message = JsonConvert.SerializeObject(ex);
|
|
//message = ex.Message.ToString();
|
|
}
|
|
|
|
//记录上报结果日志
|
|
Model.SANKU_REPORT_LOG newModel = new Model.SANKU_REPORT_LOG();
|
|
newModel.OPTYPE = opType;
|
|
newModel.CONTENT = "上报考试考核数据";
|
|
newModel.RESULT = result;
|
|
newModel.DETAIL = message;
|
|
newModel.OPERATOR = userName;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_REPORT_LOG.InsertOnSubmit(newModel);
|
|
db.SubmitChanges();
|
|
|
|
#endregion
|
|
|
|
return code;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 危大工程
|
|
|
|
/// <summary>
|
|
/// 汇总上报危大工程数据
|
|
/// </summary>
|
|
/// <param name="userName">操作人,为空:定时任务自动上报</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string ReportDangerousEngineeringRecords(string userName, ref string message)
|
|
{
|
|
string code = "0";
|
|
string result = "失败";
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var thisUnit = CommonService.GetIsThisUnit();
|
|
string filePath = Funs.SGGLUrl;
|
|
|
|
//获取危大工程数据
|
|
List<Model.SANKU_DANGEROUS_ENGINEERING> reportDatas = (from x in db.SANKU_DANGEROUS_ENGINEERING where x.ReportDate == null select x).ToList();
|
|
int total = reportDatas.Count();
|
|
int succ = 0;
|
|
|
|
if (!reportDatas.Any())
|
|
{
|
|
message = "暂无需要上报的危大工程数据!无需上报!";
|
|
return code;
|
|
}
|
|
|
|
#region 上报数据
|
|
|
|
string opType = !string.IsNullOrWhiteSpace(userName) ? "手动上报" : "自动上报";
|
|
userName = !string.IsNullOrWhiteSpace(userName) ? userName : "定时任务";
|
|
try
|
|
{
|
|
string baseurl = $"{SysConstSetService.CNCECPath}/api/SanKu/ReportDangerousEngineeringRecords";
|
|
string contenttype = "application/json;charset=unicode";
|
|
Hashtable newToken = new Hashtable
|
|
{
|
|
{ "token", ServerService.GetToken().Token }
|
|
};
|
|
var pushData = new SankuReportDangerousEngineering
|
|
{
|
|
CollCropCode = thisUnit.CollCropCode,//分包单位社会统一信用码
|
|
UnitId = thisUnit.UnitId,//分包单位Id
|
|
UnitName = thisUnit.UnitName,//分包单位名称
|
|
OpType = opType,
|
|
Operator = userName,
|
|
Items = reportDatas,
|
|
};
|
|
var pushContent = JsonConvert.SerializeObject(pushData);
|
|
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报危大工程数据】:{pushContent}");
|
|
var strJosn = APIGetHttpService.Http(baseurl, "Post", contenttype, newToken, pushContent);
|
|
if (!string.IsNullOrEmpty(strJosn))
|
|
{
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报危大工程数据】:{strJosn}");
|
|
JObject obj = JObject.Parse(strJosn);
|
|
code = obj["code"].ToString();
|
|
message = obj["message"].ToString();
|
|
if (code == "1")
|
|
{
|
|
var dateNow = DateTime.Now;
|
|
foreach (var o in reportDatas)
|
|
{
|
|
var item = db.SANKU_DANGEROUS_ENGINEERING.FirstOrDefault(e => e.DANGEROUS_ID == o.DANGEROUS_ID);
|
|
if (item != null)
|
|
{
|
|
item.ReportDate = dateNow;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
result = "成功";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
message = "无返回结果";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result = "异常";
|
|
message = JsonConvert.SerializeObject(ex);
|
|
//message = ex.Message.ToString();
|
|
}
|
|
|
|
//记录上报结果日志
|
|
Model.SANKU_REPORT_LOG newModel = new Model.SANKU_REPORT_LOG();
|
|
newModel.OPTYPE = opType;
|
|
newModel.CONTENT = "上报危大工程数据";
|
|
newModel.RESULT = result;
|
|
newModel.DETAIL = message;
|
|
newModel.OPERATOR = userName;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_REPORT_LOG.InsertOnSubmit(newModel);
|
|
db.SubmitChanges();
|
|
|
|
#endregion
|
|
|
|
return code;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 网格化巡查
|
|
|
|
/// <summary>
|
|
/// 汇总上报网格化巡查数据
|
|
/// </summary>
|
|
/// <param name="userName">操作人,为空:定时任务自动上报</param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static string ReportGridPatrolRecords(string userName, ref string message)
|
|
{
|
|
string code = "0";
|
|
string result = "失败";
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var thisUnit = CommonService.GetIsThisUnit();
|
|
string filePath = Funs.SGGLUrl;
|
|
|
|
//获取网格化巡查数据
|
|
List<Model.SANKU_GRID_PATROL> reportDatas = (from x in db.SANKU_GRID_PATROL where x.ReportDate == null select x).ToList();
|
|
int total = reportDatas.Count();
|
|
int succ = 0;
|
|
|
|
if (!reportDatas.Any())
|
|
{
|
|
message = "暂无需要上报的网格化巡查数据!无需上报!";
|
|
return code;
|
|
}
|
|
|
|
#region 上报数据
|
|
|
|
string opType = !string.IsNullOrWhiteSpace(userName) ? "手动上报" : "自动上报";
|
|
userName = !string.IsNullOrWhiteSpace(userName) ? userName : "定时任务";
|
|
try
|
|
{
|
|
string baseurl = $"{SysConstSetService.CNCECPath}/api/SanKu/ReportGridPatrolRecords";
|
|
string contenttype = "application/json;charset=unicode";
|
|
Hashtable newToken = new Hashtable
|
|
{
|
|
{ "token", ServerService.GetToken().Token }
|
|
};
|
|
var pushData = new SankuReportGridPatrol
|
|
{
|
|
CollCropCode = thisUnit.CollCropCode,//分包单位社会统一信用码
|
|
UnitId = thisUnit.UnitId,//分包单位Id
|
|
UnitName = thisUnit.UnitName,//分包单位名称
|
|
OpType = opType,
|
|
Operator = userName,
|
|
Items = reportDatas,
|
|
};
|
|
var pushContent = JsonConvert.SerializeObject(pushData);
|
|
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报网格化巡查数据】:{pushContent}");
|
|
var strJosn = APIGetHttpService.Http(baseurl, "Post", contenttype, newToken, pushContent);
|
|
if (!string.IsNullOrEmpty(strJosn))
|
|
{
|
|
//ErrLogInfo.WriteLog($"【三库:汇总上报网格化巡查数据】:{strJosn}");
|
|
JObject obj = JObject.Parse(strJosn);
|
|
code = obj["code"].ToString();
|
|
message = obj["message"].ToString();
|
|
if (code == "1")
|
|
{
|
|
var dateNow = DateTime.Now;
|
|
foreach (var o in reportDatas)
|
|
{
|
|
var item = db.SANKU_GRID_PATROL.FirstOrDefault(e => e.PATROL_ID == o.PATROL_ID);
|
|
if (item != null)
|
|
{
|
|
item.ReportDate = dateNow;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
result = "成功";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
message = "无返回结果";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result = "异常";
|
|
message = JsonConvert.SerializeObject(ex);
|
|
//message = ex.Message.ToString();
|
|
}
|
|
|
|
//记录上报结果日志
|
|
Model.SANKU_REPORT_LOG newModel = new Model.SANKU_REPORT_LOG();
|
|
newModel.OPTYPE = opType;
|
|
newModel.CONTENT = "上报网格化巡查数据";
|
|
newModel.RESULT = result;
|
|
newModel.DETAIL = message;
|
|
newModel.OPERATOR = userName;
|
|
newModel.CREATE_TIME = DateTime.Now;
|
|
db.SANKU_REPORT_LOG.InsertOnSubmit(newModel);
|
|
db.SubmitChanges();
|
|
|
|
#endregion
|
|
|
|
return code;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
}
|
|
} |