SGGL_JT/SUBQHSE/BLL/WebService/CNCECHSSEWebService.txt

185 lines
11 KiB
Plaintext

#region 中央企业安全生产治本攻坚三年行动工作台账上报
/// <summary>
/// 中央企业安全生产治本攻坚三年行动工作台账上报
/// </summary>
public static string UpActionWorkLedger(string actionWorkLedgerId, Model.Sys_User CurrUser)
{
string code = "0";
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var upReport = from x in db.Information_ActionWorkLedger
where x.ActionWorkLedgerId == actionWorkLedgerId
select new Model.ActionWorkLedger
{
ActionWorkLedgerId = x.ActionWorkLedgerId,
UnitId = x.UnitId,
ReportDate = x.ReportDate,
Quarter = x.Quarter,
YearId = x.YearId,
CompileMan = x.CompileMan,
};
var upReportItem = from x in db.Information_ActionWorkLedgerItem
where x.ActionWorkLedgerId == actionWorkLedgerId
select new Model.ActionWorkLedgerItem
{
ActionWorkLedgerItemId = x.ActionWorkLedgerItemId,
ActionWorkLedgerId = x.ActionWorkLedgerId,
SortIndex = x.SortIndex,
Focus = x.Focus,
SpecialTask = x.SpecialTask,
WorkPoints = x.WorkPoints,
FillingRequirements = x.FillingRequirements,
CompletionDeadline = x.CompletionDeadline,
ImplementationStatus = x.ImplementationStatus,
};
//var getR = hsseC.DataInsertInformation_DrillConductedQuarterlyReportTable(upReport.ToList(), upReportItem.ToList());
//新接口Api
code = UpApiSaveActionWorkLedger(upReport, upReportItem).ToString();
if (code == "1")
{
foreach (var item in upReport.Select(p => p.ActionWorkLedgerId))
{
var report = db.Information_ActionWorkLedger.FirstOrDefault(e => e.ActionWorkLedgerId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
////更新 当前人要处理的意见
ProjectDataFlowSetService.CloseFlowOperate(Const.ActionWorkLedgerMenuId, item, string.Empty);
////更新催报信息
UrgeReportService.SetComplete(report.UnitId, Const.ReportType_11, report.YearId.ToString(), report.Quarter.ToString());
}
}
LogService.AddSys_Log(CurrUser, "【中央企业安全生产治本攻坚三年行动工作台账上报】上传到服务器" + upReport.Count().ToString() + "条数据;", null, BLL.Const.MillionsMonthlyReportMenuId, BLL.Const.BtnUploadResources);
}
else
{
LogService.AddSys_Log(CurrUser, "【中央企业安全生产治本攻坚三年行动工作台账上报】上传到服务器失败;", null, BLL.Const.MillionsMonthlyReportMenuId, BLL.Const.BtnUploadResources);
}
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【中央企业安全生产治本攻坚三年行动工作台账上报】上传到服务器", ex);
LogService.AddSys_Log(CurrUser, "【中央企业安全生产治本攻坚三年行动工作台账上报】上传到服务器失败;", null, BLL.Const.MillionsMonthlyReportMenuId, BLL.Const.BtnUploadResources);
}
return code;
}
}
/// <summary>
/// DrillConductedQuarterlyReportApi调用
/// </summary>
/// <param name="upReport">主表</param>
/// <param name="upReportItem">明细表</param>
/// <returns></returns>
private static int UpApiSaveActionWorkLedger(IQueryable<Model.ActionWorkLedger> upReport, IQueryable<Model.ActionWorkLedgerItem> upReportItem)
{
string baseurl = "/api/InformationData/SaveActionWorkLedger";
//合并
//var resultJson = JsonConvert.SerializeObject(new { upReport, ReportItem = upReportItem });
var resultJson = JsonConvert.SerializeObject(upReport.FirstOrDefault());
var resultJson1 = JsonConvert.SerializeObject(new { actionWorkLedgerItem = upReportItem });
resultJson = "{\"InformationDataItems\":[" + (resultJson + resultJson1).Replace("}{", ",") + "]}";
var responeData = BLL.ServerService.PushCNCEC(resultJson, baseurl);
return responeData.code;
}
#endregion
#region 中央企业安全生产管理评价工作调度台账上报
/// <summary>
/// 中央企业安全生产管理评价工作调度台账上报
/// </summary>
public static string UpSafetyProductionEvaluation(string safetyProductionEvaluationId, Model.Sys_User CurrUser)
{
string code = "0";
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var upReport = from x in db.Information_SafetyProductionEvaluation
where x.SafetyProductionEvaluationId == safetyProductionEvaluationId
select new Model.SafetyProductionEvaluation
{
SafetyProductionEvaluationId = x.SafetyProductionEvaluationId,
UnitId = x.UnitId,
ReportDate = x.ReportDate,
Quarter = x.Quarter,
YearId = x.YearId,
CompileMan = x.CompileMan,
};
var upReportItem = from x in db.Information_SafetyProductionEvaluationItem
where x.SafetyProductionEvaluationId == safetyProductionEvaluationId
select new Model.SafetyProductionEvaluationItem
{
SafetyProductionEvaluationItemId = x.SafetyProductionEvaluationItemId,
SafetyProductionEvaluationId = x.SafetyProductionEvaluationId,
SortIndex = x.SortIndex,
Type = x.Type,
EvaluateWork = x.EvaluateWork,
EvaluationContent = x.EvaluationContent,
FillingRequirements = x.FillingRequirements,
CompletionDeadline = x.CompletionDeadline,
ImplementationStatus = x.ImplementationStatus,
};
//var getR = hsseC.DataInsertInformation_DrillConductedQuarterlyReportTable(upReport.ToList(), upReportItem.ToList());
//新接口Api
code = UpApiSaveSafetyProductionEvaluation(upReport, upReportItem).ToString();
if (code == "1")
{
foreach (var item in upReport.Select(p => p.SafetyProductionEvaluationId))
{
var report = db.Information_SafetyProductionEvaluation.FirstOrDefault(e => e.SafetyProductionEvaluationId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
////更新 当前人要处理的意见
ProjectDataFlowSetService.CloseFlowOperate(Const.SafetyProductionEvaluationMenuId, item, string.Empty);
////更新催报信息
UrgeReportService.SetComplete(report.UnitId, Const.ReportType_12, report.YearId.ToString(), report.Quarter.ToString());
}
}
LogService.AddSys_Log(CurrUser, "【中央企业安全生产管理评价工作调度台账上报】上传到服务器" + upReport.Count().ToString() + "条数据;", null, BLL.Const.MillionsMonthlyReportMenuId, BLL.Const.BtnUploadResources);
}
else
{
LogService.AddSys_Log(CurrUser, "【中央企业安全生产管理评价工作调度台账上报】上传到服务器失败;", null, BLL.Const.MillionsMonthlyReportMenuId, BLL.Const.BtnUploadResources);
}
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【中央企业安全生产管理评价工作调度台账上报】上传到服务器", ex);
LogService.AddSys_Log(CurrUser, "【中央企业安全生产管理评价工作调度台账上报】上传到服务器失败;", null, BLL.Const.MillionsMonthlyReportMenuId, BLL.Const.BtnUploadResources);
}
return code;
}
}
/// <summary>
/// DrillConductedQuarterlyReportApi调用
/// </summary>
/// <param name="upReport">主表</param>
/// <param name="upReportItem">明细表</param>
/// <returns></returns>
private static int UpApiSaveSafetyProductionEvaluation(IQueryable<Model.SafetyProductionEvaluation> upReport, IQueryable<Model.SafetyProductionEvaluationItem> upReportItem)
{
string baseurl = "/api/InformationData/SaveSafetyProductionEvaluation";
//合并
//var resultJson = JsonConvert.SerializeObject(new { upReport, ReportItem = upReportItem });
var resultJson = JsonConvert.SerializeObject(upReport.FirstOrDefault());
var resultJson1 = JsonConvert.SerializeObject(new { safetyProductionEvaluationItem = upReportItem });
resultJson = "{\"InformationDataItems\":[" + (resultJson + resultJson1).Replace("}{", ",") + "]}";
var responeData = BLL.ServerService.PushCNCEC(resultJson, baseurl);
return responeData.code;
}
#endregion