CNCEC_SUBQHSE_WUHUAN/SGGL/BLL/WebService/CNCECHSSEWebService.cs

3642 lines
208 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace BLL
{
using Apache.NMS.ActiveMQ.Commands;
using BLL.CNCECHSSEService;
using Newtonsoft.Json;
using NPOI.POIFS.Crypt.Dsig;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
//using System.Net.Http.Headers;
//using System.Net.Http;
using System.Web;
using RestSharp;
using System.Net;
using System.Collections;
using Newtonsoft.Json.Linq;
public static class CNCECHSSEWebService
{
public static void upFile()
{
//int l = HttpContext.Current.Request.Files["testdoc"].ContentLength;
//byte[] buffer = new byte[l];
//Stream s = HttpContext.Current.Request.Files["testdoc"].InputStream;
//HttpClient client = new HttpClient();
//MultipartFormDataContent form = new MultipartFormDataContent();
//StreamContent fileContent = new StreamContent(s);
//fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
//fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
//fileContent.Headers.ContentDisposition.FileName = s.filename;
//form.Add(fileContent);
//HttpResponseMessage res = client.PostAsync("http://192.168.8.9/llb/api/FileUpload/PostFile", form).Result;
//var msg = res.Content.ReadAsStringAsync().Result;
//if (msg.ToString() != "true")
//{
// return Content(msg);
//}
}
public static string UploadFile(string file)
{
string result = string.Empty;
try
{
string CNCECPath = SysConstSetService.CNCECPath;
string baseurl = CNCECPath + "/api/FileUpload/Post";
var client = new RestClient(baseurl);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
request.AddHeader("Content-Type", "multipart/form-data");//注意头部必须是form-data
// client.UserAgent = "apifox/1.0.0 (https://www.apifox.cn)";
//request.AddFile("file", @"E:\微信\WeChat\WeChat Files\wxid_9140361403112\FileStorage\File\2022-08\焊接管理尾项20220809.docx");
var filelist = file.Split(',');
foreach (var item in filelist)
{
if (File.Exists(item))
{
request.AddFile("file", item);
}
}
request.AddParameter("typeName", "SafetyQuarterlyReport");
var tokenItem = BLL.ServerService.GetToken();
request.AddHeader("token", tokenItem.Token);
IRestResponse response = client.Execute(request);
var contentPost = response.Content.Replace('"', ' ');
result = contentPost;
}
catch (System.Exception)
{
result = "";
}
return result;
}
#region
#region
/// <summary>
/// 百万工时上报
/// </summary>
public static string UpMillionsMonthlyReport(string millionsMonthlyReportId, 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_MillionsMonthlyReport
where x.MillionsMonthlyReportId == millionsMonthlyReportId
select new CNCECHSSEService.Information_MillionsMonthlyReport
{
MillionsMonthlyReportId = x.MillionsMonthlyReportId,
UnitId = x.UnitId,
Year = x.Year,
Month = x.Month,
FillingMan = x.FillingMan,
FillingDate = x.FillingDate,
DutyPerson = x.DutyPerson,
RecordableIncidentRate = x.RecordableIncidentRate,
LostTimeRate = x.LostTimeRate,
LostTimeInjuryRate = x.LostTimeInjuryRate,
DeathAccidentFrequency = x.DeathAccidentFrequency,
AccidentMortality = x.AccidentMortality,
//InputCosts = x.InputCosts,
//TrainNum = x.TrainNum,
//GeneralHazardNum = x.GeneralHazardNum,
//MajorHazardNum = x.MajorHazardNum,
//NotProofLargeProjectNum = x.NotProofLargeProjectNum,
//ProofLargeProjectNum = x.ProofLargeProjectNum,
//FireLicenseNum = x.FireLicenseNum,
//LimitLicenseNum = x.LimitLicenseNum,
//HighLicenseNum = x.HighLicenseNum,
//HoistingLicenseNum = x.HoistingLicenseNum,
//BreakGroundLicenseNum = x.BreakGroundLicenseNum,
//ElectricityLicenseNum = x.ElectricityLicenseNum,
//RTLicenseNum = x.RTLicenseNum,
//NightLicenseNum = x.NightLicenseNum,
//CommissionerNum = x.CommissionerNum,
//SoleDutyNum = x.SoleDutyNum,
};
var upReportItem = from x in db.Information_MillionsMonthlyReportItem
where x.MillionsMonthlyReportId == millionsMonthlyReportId
select new CNCECHSSEService.Information_MillionsMonthlyReportItem
{
MillionsMonthlyReportItemId = x.MillionsMonthlyReportItemId,
MillionsMonthlyReportId = x.MillionsMonthlyReportId,
SortIndex = x.SortIndex,
Affiliation = x.Affiliation,
Name = x.Name,
PostPersonNum = x.PostPersonNum,
SnapPersonNum = x.SnapPersonNum,
ContractorNum = x.ContractorNum,
SumPersonNum = x.SumPersonNum,
TotalWorkNum = x.TotalWorkNum,
SeriousInjuriesNum = x.SeriousInjuriesNum,
SeriousInjuriesPersonNum = x.SeriousInjuriesPersonNum,
SeriousInjuriesLossHour = x.SeriousInjuriesLossHour,
MinorAccidentNum = x.MinorAccidentNum,
MinorAccidentPersonNum = x.MinorAccidentPersonNum,
MinorAccidentLossHour = x.MinorAccidentLossHour,
OtherAccidentNum = x.DeathAccidentNum,
OtherAccidentPersonNum = x.DeathAccidentPersonNum,
OtherAccidentLossHour = x.DeathAccidentLossHour,
RestrictedWorkPersonNum = x.RestrictedWorkPersonNum,
RestrictedWorkLossHour = x.RestrictedWorkLossHour,
MedicalTreatmentPersonNum = x.MedicalTreatmentPersonNum,
MedicalTreatmentLossHour = x.MedicalTreatmentLossHour,
FireNum = x.FireNum,
ExplosionNum = x.EnvironmenNum,
TrafficNum = x.TrafficNum,
EquipmentNum = x.EquipmentNum,
QualityNum = x.QualityNum,
OtherNum = x.OtherNum,
FirstAidDressingsNum = x.FirstAidDressingsNum,
AttemptedEventNum = x.AttemptedEventNum,
LossDayNum = x.LossDayNum,
};
//老接口Serveice
//var getR = hsseC.DataInsertInformation_MillionsMonthlyReportTable(upReport.ToList(), upReportItem.ToList());
//新接口Api
code = UpApiMillionsMonthlyReport(upReport, upReportItem).ToString();
if (code == "1")
{
foreach (var item in upReport.Select(p => p.MillionsMonthlyReportId))
{
var report = db.Information_MillionsMonthlyReport.FirstOrDefault(e => e.MillionsMonthlyReportId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
////更新 当前人要处理的意见
ProjectDataFlowSetService.CloseFlowOperate(Const.MillionsMonthlyReportMenuId, item, string.Empty);
// //更新催报信息
UrgeReportService.SetComplete(report.UnitId, Const.ReportType_1, report.Year.ToString(), report.Month.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>
/// UpApiMillionsMonthlyReportApi调用
/// </summary>
/// <param name="upReport">主表</param>
/// <param name="upReportItem">明细表</param>
/// <returns></returns>
private static int UpApiMillionsMonthlyReport(IQueryable<CNCECHSSEService.Information_MillionsMonthlyReport> upReport, IQueryable<Information_MillionsMonthlyReportItem> upReportItem)
{
string baseurl = "/api/InformationData/SaveMillionsMonthlyReport";
//合并
//var resultJson = JsonConvert.SerializeObject(new { upReport, ReportItem = upReportItem });
var resultJsonReport = JsonConvert.SerializeObject(upReport.FirstOrDefault());
var resultJsonReportItem = JsonConvert.SerializeObject(new { MillionsMonthlyReportItem = upReportItem });
resultJsonReport = "{\"InformationDataItems\":[" + (resultJsonReport + resultJsonReportItem).Replace("}{", ",") + "]}";
var responeData = BLL.ServerService.PushCNCEC(resultJsonReport, baseurl);
return responeData.code;
}
#endregion
#region
/// <summary>
/// 职工伤亡事故原因分析报表上报
/// </summary>
public static string UpAccidentCauseReport(string accidentCauseReportId, 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_AccidentCauseReport
where x.AccidentCauseReportId == accidentCauseReportId
select new CNCECHSSEService.Information_AccidentCauseReport
{
AccidentCauseReportId = x.AccidentCauseReportId,
UnitId = x.UnitId,
AccidentCauseReportCode = x.AccidentCauseReportCode,
Year = x.Year,
Month = x.Month,
DeathAccident = x.DeathAccident,
DeathToll = x.DeathToll,
InjuredAccident = x.InjuredAccident,
InjuredToll = x.InjuredToll,
MinorWoundAccident = x.MinorWoundAccident,
MinorWoundToll = x.MinorWoundToll,
AverageTotalHours = x.AverageTotalHours,
AverageManHours = x.AverageManHours,
TotalLossMan = x.TotalLossMan,
LastMonthLossHoursTotal = x.LastMonthLossHoursTotal,
KnockOffTotal = x.KnockOffTotal,
DirectLoss = x.DirectLoss,
IndirectLosses = x.IndirectLosses,
TotalLoss = x.TotalLoss,
TotalLossTime = x.TotalLossTime,
FillCompanyPersonCharge = x.FillCompanyPersonCharge,
TabPeople = x.TabPeople,
AuditPerson = x.AuditPerson,
FillingDate = x.FillingDate,
};
var upReportItem = from x in db.Information_AccidentCauseReportItem
where x.AccidentCauseReportId == accidentCauseReportId
select new CNCECHSSEService.Information_AccidentCauseReportItem
{
AccidentCauseReportItemId = x.AccidentCauseReportItemId,
AccidentCauseReportId = x.AccidentCauseReportId,
AccidentType = x.AccidentType,
TotalDeath = x.TotalDeath,
TotalInjuries = x.TotalInjuries,
TotalMinorInjuries = x.TotalMinorInjuries,
Death1 = x.Death1,
Injuries1 = x.Injuries1,
MinorInjuries1 = x.MinorInjuries1,
Death2 = x.Death2,
Injuries2 = x.Injuries2,
MinorInjuries2 = x.MinorInjuries2,
Death3 = x.Death3,
Injuries3 = x.Injuries3,
MinorInjuries3 = x.MinorInjuries3,
Death4 = x.Death4,
Injuries4 = x.Injuries4,
MinorInjuries4 = x.MinorInjuries4,
Death5 = x.Death5,
Injuries5 = x.Injuries5,
MinorInjuries5 = x.MinorInjuries5,
Death6 = x.Death6,
Injuries6 = x.Injuries6,
MinorInjuries6 = x.MinorInjuries6,
Death7 = x.Death7,
Injuries7 = x.Injuries7,
MinorInjuries7 = x.MinorInjuries7,
Death8 = x.Death8,
Injuries8 = x.Injuries8,
MinorInjuries8 = x.MinorInjuries8,
Death9 = x.Death9,
Injuries9 = x.Injuries9,
MinorInjuries9 = x.MinorInjuries9,
Death10 = x.Death10,
Injuries10 = x.Injuries10,
MinorInjuries10 = x.MinorInjuries10,
Death11 = x.Death11,
Injuries11 = x.Injuries11,
MinorInjuries11 = x.MinorInjuries11,
};
//老接口Serveice
// var getR = hsseC.DataInsertInformation_AccidentCauseReportTable(upReport.ToList(), upReportItem.ToList());
//新接口Api
code = UpApiAccidentCauseReport(upReport, upReportItem).ToString();
if (code == "1")
{
foreach (var item in upReport.Select(p => p.AccidentCauseReportId))
{
var report = db.Information_AccidentCauseReport.FirstOrDefault(e => e.AccidentCauseReportId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
////更新 当前人要处理的意见
ProjectDataFlowSetService.CloseFlowOperate(Const.MillionsMonthlyReportMenuId, item, string.Empty);
////更新催报信息
UrgeReportService.SetComplete(report.UnitId, Const.ReportType_2, report.Year.ToString(), report.Month.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>
/// AccidentCauseReportApi调用
/// </summary>
/// <param name="upReport">主表</param>
/// <param name="upReportItem">明细表</param>
/// <returns></returns>
private static int UpApiAccidentCauseReport(IQueryable<Information_AccidentCauseReport> upReport, IQueryable<Information_AccidentCauseReportItem> upReportItem)
{
string baseurl = "/api/InformationData/SaveAccidentCauseReport";
//合并
//var resultJson = JsonConvert.SerializeObject(new { upReport, ReportItem = upReportItem });
var resultJson = JsonConvert.SerializeObject(upReport.FirstOrDefault());
var resultJson1 = JsonConvert.SerializeObject(new { AccidentCauseReportItem = upReportItem });
resultJson = "{\"InformationDataItems\":[" + (resultJson + resultJson1).Replace("}{", ",") + "]}";
var responeData = BLL.ServerService.PushCNCEC(resultJson, baseurl);
return responeData.code;
}
#endregion
#region
/// <summary>
/// 安全生产数据季报上报
/// </summary>
public static string UpSafetyQuarterlyReport(string safetyQuarterlyReportId, 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_SafetyQuarterlyReport
where x.SafetyQuarterlyReportId == safetyQuarterlyReportId
select new CNCECHSSEService.Information_SafetyQuarterlyReport
{
SafetyQuarterlyReportId = x.SafetyQuarterlyReportId,
UnitId = x.UnitId,
YearId = x.YearId,
Quarters = x.Quarters,
TotalInWorkHours = x.TotalInWorkHours,
TotalInWorkHoursRemark = x.TotalInWorkHoursRemark,
TotalOutWorkHours = x.TotalOutWorkHours,
TotalOutWorkHoursRemark = x.TotalOutWorkHoursRemark,
WorkHoursLossRate = x.WorkHoursLossRate,
WorkHoursLossRateRemark = x.WorkHoursLossRateRemark,
WorkHoursAccuracy = x.WorkHoursAccuracy,
WorkHoursAccuracyRemark = x.WorkHoursAccuracyRemark,
MainBusinessIncome = x.MainBusinessIncome,
MainBusinessIncomeRemark = x.MainBusinessIncomeRemark,
FillingDate = x.FillingDate,
ConstructionRevenue = x.ConstructionRevenue,
ConstructionRevenueRemark = x.ConstructionRevenueRemark,
UnitTimeIncome = x.UnitTimeIncome,
UnitTimeIncomeRemark = x.UnitTimeIncomeRemark,
BillionsOutputMortality = x.BillionsOutputMortality,
BillionsOutputMortalityRemark = x.BillionsOutputMortalityRemark,
MajorFireAccident = x.MajorFireAccident,
MajorFireAccidentRemark = x.MajorFireAccidentRemark,
MajorEquipAccident = x.MajorEquipAccident,
MajorEquipAccidentRemark = x.MajorEquipAccidentRemark,
AccidentFrequency = x.AccidentFrequency,
AccidentFrequencyRemark = x.AccidentFrequencyRemark,
SeriousInjuryAccident = x.SeriousInjuryAccident,
SeriousInjuryAccidentRemark = x.SeriousInjuryAccidentRemark,
FireAccident = x.FireAccident,
FireAccidentRemark = x.FireAccidentRemark,
EquipmentAccident = x.EquipmentAccident,
EquipmentAccidentRemark = x.EquipmentAccidentRemark,
PoisoningAndInjuries = x.PoisoningAndInjuries,
PoisoningAndInjuriesRemark = x.PoisoningAndInjuriesRemark,
ProductionSafetyInTotal = x.ProductionSafetyInTotal,
ProductionSafetyInTotalRemark = x.ProductionSafetyInTotalRemark,
ProtectionInput = x.ProtectionInput,
ProtectionInputRemark = x.ProtectionInputRemark,
LaboAndHealthIn = x.LaboAndHealthIn,
LaborAndHealthInRemark = x.LaborAndHealthInRemark,
TechnologyProgressIn = x.TechnologyProgressIn,
TechnologyProgressInRemark = x.TechnologyProgressInRemark,
EducationTrainIn = x.EducationTrainIn,
EducationTrainInRemark = x.EducationTrainInRemark,
ProjectCostRate = x.ProjectCostRate,
ProjectCostRateRemark = x.ProjectCostRateRemark,
ProductionInput = x.ProductionInput,
ProductionInputRemark = x.ProductionInputRemark,
Revenue = x.Revenue,
RevenueRemark = x.RevenueRemark,
FullTimeMan = x.FullTimeMan,
FullTimeManRemark = x.FullTimeManRemark,
FullTimeManAttachUrl = x.FullTimeManAttachUrl,
PMMan = x.PMMan,
PMManRemark = x.PMManRemark,
PMManAttachUrl = x.PMManAttachUrl,
CorporateDirectorEdu = x.CorporateDirectorEdu,
CorporateDirectorEduRemark = x.CorporateDirectorEduRemark,
ProjectLeaderEdu = x.ProjectLeaderEdu,
ProjectLeaderEduRemark = x.ProjectLeaderEduRemark,
FullTimeEdu = x.FullTimeEdu,
FullTimeEduRemark = x.FullTimeEduRemark,
ThreeKidsEduRate = x.ThreeKidsEduRate,
ThreeKidsEduRateRemark = x.ThreeKidsEduRateRemark,
UplinReportRate = x.UplinReportRate,
UplinReportRateRemark = x.UplinReportRateRemark,
Remarks = x.Remarks,
CompileMan = x.CompileMan,
////附件转为字节传送
//FullTimeManAttachUrlFileContext = FileStructService.GetFileStructByAttachUrl(x.FullTimeManAttachUrl),
// PMManAttachUrlFileContext = FileStructService.GetFileStructByAttachUrl(x.PMManAttachUrl),
KeyEquipmentTotal = x.KeyEquipmentTotal,
KeyEquipmentTotalRemark = x.KeyEquipmentTotalRemark,
KeyEquipmentReportCount = x.KeyEquipmentReportCount,
KeyEquipmentReportCountRemark = x.KeyEquipmentReportCountRemark,
ChemicalAreaProjectCount = x.ChemicalAreaProjectCount,
ChemicalAreaProjectCountRemark = x.ChemicalAreaProjectCountRemark,
HarmfulMediumCoverCount = x.HarmfulMediumCoverCount,
HarmfulMediumCoverCountRemark = x.HarmfulMediumCoverCountRemark,
HarmfulMediumCoverRate = x.HarmfulMediumCoverRate,
HarmfulMediumCoverRateRemark = x.HarmfulMediumCoverRateRemark
};
//老接口Serveice
// var getR = hsseC.DataInsertInformation_SafetyQuarterlyReportTable(upReport.ToList());
//新接口Api
string FullTimeManAttachUrl = string.Empty;
string PMManAttachUrl = string.Empty;
string physicalpath = Funs.RootPath;
FullTimeManAttachUrl = physicalpath + upReport.FirstOrDefault().FullTimeManAttachUrl;
PMManAttachUrl = physicalpath + upReport.FirstOrDefault().PMManAttachUrl;
FullTimeManAttachUrl = UploadFile(FullTimeManAttachUrl);
PMManAttachUrl = UploadFile(PMManAttachUrl);
upReport = from x in upReport
select new CNCECHSSEService.Information_SafetyQuarterlyReport
{
SafetyQuarterlyReportId = x.SafetyQuarterlyReportId,
UnitId = x.UnitId,
YearId = x.YearId,
Quarters = x.Quarters,
TotalInWorkHours = x.TotalInWorkHours,
TotalInWorkHoursRemark = x.TotalInWorkHoursRemark,
TotalOutWorkHours = x.TotalOutWorkHours,
TotalOutWorkHoursRemark = x.TotalOutWorkHoursRemark,
WorkHoursLossRate = x.WorkHoursLossRate,
WorkHoursLossRateRemark = x.WorkHoursLossRateRemark,
WorkHoursAccuracy = x.WorkHoursAccuracy,
WorkHoursAccuracyRemark = x.WorkHoursAccuracyRemark,
MainBusinessIncome = x.MainBusinessIncome,
MainBusinessIncomeRemark = x.MainBusinessIncomeRemark,
FillingDate = x.FillingDate,
ConstructionRevenue = x.ConstructionRevenue,
ConstructionRevenueRemark = x.ConstructionRevenueRemark,
UnitTimeIncome = x.UnitTimeIncome,
UnitTimeIncomeRemark = x.UnitTimeIncomeRemark,
BillionsOutputMortality = x.BillionsOutputMortality,
BillionsOutputMortalityRemark = x.BillionsOutputMortalityRemark,
MajorFireAccident = x.MajorFireAccident,
MajorFireAccidentRemark = x.MajorFireAccidentRemark,
MajorEquipAccident = x.MajorEquipAccident,
MajorEquipAccidentRemark = x.MajorEquipAccidentRemark,
AccidentFrequency = x.AccidentFrequency,
AccidentFrequencyRemark = x.AccidentFrequencyRemark,
SeriousInjuryAccident = x.SeriousInjuryAccident,
SeriousInjuryAccidentRemark = x.SeriousInjuryAccidentRemark,
FireAccident = x.FireAccident,
FireAccidentRemark = x.FireAccidentRemark,
EquipmentAccident = x.EquipmentAccident,
EquipmentAccidentRemark = x.EquipmentAccidentRemark,
PoisoningAndInjuries = x.PoisoningAndInjuries,
PoisoningAndInjuriesRemark = x.PoisoningAndInjuriesRemark,
ProductionSafetyInTotal = x.ProductionSafetyInTotal,
ProductionSafetyInTotalRemark = x.ProductionSafetyInTotalRemark,
ProtectionInput = x.ProtectionInput,
ProtectionInputRemark = x.ProtectionInputRemark,
LaboAndHealthIn = x.LaboAndHealthIn,
LaborAndHealthInRemark = x.LaborAndHealthInRemark,
TechnologyProgressIn = x.TechnologyProgressIn,
TechnologyProgressInRemark = x.TechnologyProgressInRemark,
EducationTrainIn = x.EducationTrainIn,
EducationTrainInRemark = x.EducationTrainInRemark,
ProjectCostRate = x.ProjectCostRate,
ProjectCostRateRemark = x.ProjectCostRateRemark,
ProductionInput = x.ProductionInput,
ProductionInputRemark = x.ProductionInputRemark,
Revenue = x.Revenue,
RevenueRemark = x.RevenueRemark,
FullTimeMan = x.FullTimeMan,
FullTimeManRemark = x.FullTimeManRemark,
FullTimeManAttachUrl = FullTimeManAttachUrl,
PMMan = x.PMMan,
PMManRemark = x.PMManRemark,
PMManAttachUrl = PMManAttachUrl,
CorporateDirectorEdu = x.CorporateDirectorEdu,
CorporateDirectorEduRemark = x.CorporateDirectorEduRemark,
ProjectLeaderEdu = x.ProjectLeaderEdu,
ProjectLeaderEduRemark = x.ProjectLeaderEduRemark,
FullTimeEdu = x.FullTimeEdu,
FullTimeEduRemark = x.FullTimeEduRemark,
ThreeKidsEduRate = x.ThreeKidsEduRate,
ThreeKidsEduRateRemark = x.ThreeKidsEduRateRemark,
UplinReportRate = x.UplinReportRate,
UplinReportRateRemark = x.UplinReportRateRemark,
Remarks = x.Remarks,
CompileMan = x.CompileMan,
KeyEquipmentTotal = x.KeyEquipmentTotal,
KeyEquipmentTotalRemark = x.KeyEquipmentTotalRemark,
KeyEquipmentReportCount = x.KeyEquipmentReportCount,
KeyEquipmentReportCountRemark = x.KeyEquipmentReportCountRemark,
ChemicalAreaProjectCount = x.ChemicalAreaProjectCount,
ChemicalAreaProjectCountRemark = x.ChemicalAreaProjectCountRemark,
HarmfulMediumCoverCount = x.HarmfulMediumCoverCount,
HarmfulMediumCoverCountRemark = x.HarmfulMediumCoverCountRemark,
HarmfulMediumCoverRate = x.HarmfulMediumCoverRate,
HarmfulMediumCoverRateRemark = x.HarmfulMediumCoverRateRemark
};
code = UpApiSaveSafetyQuarterlyReport(upReport).ToString();
; LogService.AddSys_Log(CurrUser, "【安全生产数据季报上报】上传", code, BLL.Const.MillionsMonthlyReportMenuId, BLL.Const.BtnUploadResources);
if (code == "1")
{
foreach (var item in upReport.Select(p => p.SafetyQuarterlyReportId))
{
var report = db.Information_SafetyQuarterlyReport.FirstOrDefault(e => e.SafetyQuarterlyReportId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
////更新 当前人要处理的意见
ProjectDataFlowSetService.CloseFlowOperate(Const.MillionsMonthlyReportMenuId, item, string.Empty);
////更新催报信息
UrgeReportService.SetComplete(report.UnitId, Const.ReportType_3, report.YearId.ToString(), report.Quarters.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, "【安全生产数据季报上报】上传到服务器失败err", 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 UpApiSaveSafetyQuarterlyReport(IQueryable<Information_SafetyQuarterlyReport> upReport)
{
string baseurl = "/api/InformationData/SaveSafetyQuarterlyReport";
var resultJson = JsonConvert.SerializeObject(new { InformationDataItems = upReport });
APICommonService.SaveSysHttpLog("api_In", baseurl, resultJson);
var responeData = BLL.ServerService.PushCNCEC(resultJson, baseurl);
return responeData.code;
}
#endregion
#region
/// <summary>
/// 应急演练开展情况季报表上报
/// </summary>
public static string UpDrillConductedQuarterlyReport(string drillConductedQuarterlyReportId, 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_DrillConductedQuarterlyReport
where x.DrillConductedQuarterlyReportId == drillConductedQuarterlyReportId
select new CNCECHSSEService.Information_DrillConductedQuarterlyReport
{
DrillConductedQuarterlyReportId = x.DrillConductedQuarterlyReportId,
UnitId = x.UnitId,
ReportDate = x.ReportDate,
Quarter = x.Quarter,
YearId = x.YearId,
CompileMan = x.CompileMan,
};
var upReportItem = from x in db.Information_DrillConductedQuarterlyReportItem
where x.DrillConductedQuarterlyReportId == drillConductedQuarterlyReportId
select new CNCECHSSEService.Information_DrillConductedQuarterlyReportItem
{
DrillConductedQuarterlyReportItemId = x.DrillConductedQuarterlyReportItemId,
DrillConductedQuarterlyReportId = x.DrillConductedQuarterlyReportId,
IndustryType = x.IndustryType,
TotalConductCount = x.TotalConductCount,
TotalPeopleCount = x.TotalPeopleCount,
TotalInvestment = x.TotalInvestment,
HQConductCount = x.HQConductCount,
HQPeopleCount = x.HQPeopleCount,
HQInvestment = x.HQInvestment,
BasicConductCount = x.BasicConductCount,
BasicPeopleCount = x.BasicPeopleCount,
BasicInvestment = x.BasicInvestment,
ComprehensivePractice = x.ComprehensivePractice,
CPScene = x.CPScene,
CPDesktop = x.CPDesktop,
SpecialDrill = x.SpecialDrill,
SDScene = x.SDScene,
SDDesktop = x.SDDesktop,
SortIndex = x.SortIndex,
};
//老接口Serveice
//var getR = hsseC.DataInsertInformation_DrillConductedQuarterlyReportTable(upReport.ToList(), upReportItem.ToList());
//新接口Api
code = UpApiSaveDrillConductedQuarterlyReport(upReport, upReportItem).ToString();
if (code == "1")
{
foreach (var item in upReport.Select(p => p.DrillConductedQuarterlyReportId))
{
var report = db.Information_DrillConductedQuarterlyReport.FirstOrDefault(e => e.DrillConductedQuarterlyReportId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
////更新 当前人要处理的意见
ProjectDataFlowSetService.CloseFlowOperate(Const.MillionsMonthlyReportMenuId, item, string.Empty);
////更新催报信息
UrgeReportService.SetComplete(report.UnitId, Const.ReportType_4, 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 UpApiSaveDrillConductedQuarterlyReport(IQueryable<Information_DrillConductedQuarterlyReport> upReport, IQueryable<Information_DrillConductedQuarterlyReportItem> upReportItem)
{
string baseurl = "/api/InformationData/SaveDrillConductedQuarterlyReport";
//合并
//var resultJson = JsonConvert.SerializeObject(new { upReport, ReportItem = upReportItem });
var resultJson = JsonConvert.SerializeObject(upReport.FirstOrDefault());
var resultJson1 = JsonConvert.SerializeObject(new { drillConductedQuarterlyReportItem = upReportItem });
resultJson = "{\"InformationDataItems\":[" + (resultJson + resultJson1).Replace("}{", ",") + "]}";
var responeData = BLL.ServerService.PushCNCEC(resultJson, baseurl);
return responeData.code;
}
#endregion
#region
/// <summary>
/// 应急演练工作计划半年报表
/// </summary>
public static string UpDrillPlanHalfYearReport(string drillPlanHalfYearReportId, 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_DrillPlanHalfYearReport
where x.DrillPlanHalfYearReportId == drillPlanHalfYearReportId
select new CNCECHSSEService.Information_DrillPlanHalfYearReport
{
DrillPlanHalfYearReportId = x.DrillPlanHalfYearReportId,
UnitId = x.UnitId,
CompileMan = x.CompileMan,
CompileDate = x.CompileDate,
YearId = x.YearId,
HalfYearId = x.HalfYearId,
Telephone = x.Telephone,
};
var upReportItem = from x in db.Information_DrillPlanHalfYearReportItem
where x.DrillPlanHalfYearReportId == drillPlanHalfYearReportId
select new CNCECHSSEService.Information_DrillPlanHalfYearReportItem
{
DrillPlanHalfYearReportItemId = x.DrillPlanHalfYearReportItemId,
DrillPlanHalfYearReportId = x.DrillPlanHalfYearReportId,
DrillPlanName = x.DrillPlanName,
OrganizationUnit = x.OrganizationUnit,
DrillPlanDate = x.DrillPlanDate,
AccidentScene = x.AccidentScene,
ExerciseWay = x.ExerciseWay,
SortIndex = x.SortIndex,
};
//老接口Serveice
// var getR = hsseC.DataInsertInformation_DrillPlanHalfYearReportTable(upReport.ToList(), upReportItem.ToList());
//新接口Api
code = UpApiDrillPlanHalfYearReport(upReport, upReportItem).ToString();
if (code == "1")
{
foreach (var item in upReport.Select(p => p.DrillPlanHalfYearReportId))
{
var report = db.Information_DrillPlanHalfYearReport.FirstOrDefault(e => e.DrillPlanHalfYearReportId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
////更新 当前人要处理的意见
ProjectDataFlowSetService.CloseFlowOperate(Const.DrillPlanHalfYearReportMenuId, item, string.Empty);
////更新催报信息
UrgeReportService.SetComplete(report.UnitId, Const.ReportType_5, report.YearId.ToString(), report.HalfYearId.ToString());
}
}
LogService.AddSys_Log(CurrUser, "【应急演练工作计划半年报表】上传到服务器" + upReport.Count().ToString() + "条数据;", null, BLL.Const.DrillPlanHalfYearReportMenuId, BLL.Const.BtnUploadResources);
}
else
{
LogService.AddSys_Log(CurrUser, "【应急演练工作计划半年报表】上传到服务器失败;", null, BLL.Const.DrillPlanHalfYearReportMenuId, BLL.Const.BtnUploadResources);
}
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【应急演练工作计划半年报表】上传到服务器", ex);
LogService.AddSys_Log(CurrUser, "【应急演练工作计划半年报表】上传到服务器失败;", null, BLL.Const.DrillPlanHalfYearReportMenuId, BLL.Const.BtnUploadResources);
}
return code;
}
}
/// <summary>
/// DrillPlanHalfYearReportApi调用
/// </summary>
/// <param name="upReport">主表</param>
/// <param name="upReportItem">明细表</param>
/// <returns></returns>
private static int UpApiDrillPlanHalfYearReport(IQueryable<Information_DrillPlanHalfYearReport> upReport, IQueryable<Information_DrillPlanHalfYearReportItem> upReportItem)
{
string baseurl = "/api/InformationData/SaveDrillPlanHalfYearReport";
//合并
//var resultJson = JsonConvert.SerializeObject(new { upReport, ReportItem = upReportItem });
var resultJson = JsonConvert.SerializeObject(upReport.FirstOrDefault());
var resultJson1 = JsonConvert.SerializeObject(new { drillPlanHalfYearReportItem = upReportItem });
resultJson = "{\"InformationDataItems\":[" + (resultJson + resultJson1).Replace("}{", ",") + "]}";
var responeData = BLL.ServerService.PushCNCEC(resultJson, baseurl);
return responeData.code;
}
#endregion
#region
/// <summary>
/// 化工行业能源节约与生态环境保护汇总表上报
/// </summary>
public static string UpChemicalReport(string chemicalReportId, 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.Environmental_ChemicalReport
where x.ChemicalReportId == chemicalReportId
select new Model.ChemicalReport
{
ChemicalReportId = x.ChemicalReportId,
UnitId = x.UnitId,
Year = x.Year,
Month = x.Month,
FillingMan = x.FillingMan,
FillingDate = x.FillingDate,
DutyPerson = x.DutyPerson,
};
var upReportItem = from x in db.Environmental_ChemicalReportItem
where x.ChemicalReportId == chemicalReportId
select new Model.ChemicalReportItem
{
ChemicalReportItemId = x.ChemicalReportItemId,
ChemicalReportId = x.ChemicalReportId,
SortIndex = x.SortIndex,
BaseNumber = x.BaseNumber,
LastYearValue = x.LastYearValue,
ThisYearValue = x.ThisYearValue,
Rate = x.Rate,
};
//老接口Serveice
//var getR = hsseC.DataInsertInformation_ChemicalReportTable(upReport.ToList(), upReportItem.ToList());
//新接口Api
code = UpApiChemicalReport(upReport, upReportItem).ToString();
if (code == "1")
{
foreach (var item in upReport.Select(p => p.ChemicalReportId))
{
var report = db.Environmental_ChemicalReport.FirstOrDefault(e => e.ChemicalReportId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
////更新 当前人要处理的意见
ProjectDataFlowSetService.CloseFlowOperate(Const.ChemicalReportMenuId, item, string.Empty);
// //更新催报信息
UrgeReportService.SetComplete(report.UnitId, Const.ReportType_1, report.Year.ToString(), report.Month.ToString());
}
}
LogService.AddSys_Log(CurrUser, "【化工行业能源节约与生态环境保护汇总表】上传到服务器" + upReport.Count().ToString() + "条数据;", null, BLL.Const.ChemicalReportMenuId, BLL.Const.BtnUploadResources);
}
else
{
LogService.AddSys_Log(CurrUser, "【化工行业能源节约与生态环境保护汇总表】上传到服务器失败;", null, BLL.Const.ChemicalReportMenuId, BLL.Const.BtnUploadResources);
}
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【化工行业能源节约与生态环境保护汇总表】上传到服务器", ex);
LogService.AddSys_Log(CurrUser, "【化工行业能源节约与生态环境保护汇总表】上传到服务器失败;", null, BLL.Const.ChemicalReportMenuId, BLL.Const.BtnUploadResources);
}
return code;
}
}
/// <summary>
/// UpApiChemicalReportApi调用
/// </summary>
/// <param name="upReport">主表</param>
/// <param name="upReportItem">明细表</param>
/// <returns></returns>
private static int UpApiChemicalReport(IQueryable<Model.ChemicalReport> upReport, IQueryable<Model.ChemicalReportItem> upReportItem)
{
string baseurl = "/api/InformationData/SaveChemicalReport";
//合并
//var resultJson = JsonConvert.SerializeObject(new { upReport, ReportItem = upReportItem });
var resultJsonReport = JsonConvert.SerializeObject(upReport.FirstOrDefault());
var resultJsonReportItem = JsonConvert.SerializeObject(new { ChemicalReportItem = upReportItem });
resultJsonReport = "{\"InformationDataItems\":[" + (resultJsonReport + resultJsonReportItem).Replace("}{", ",") + "]}";
var responeData = BLL.ServerService.PushCNCEC(resultJsonReport, baseurl);
return responeData.code;
}
#endregion
#region
private static List<Model.reportItemListDto> getreportItemList(string BusinessReportId)
{
return Funs.DB.Environmental_OperationReportItem.Where(x => x.BusinessReportId == BusinessReportId)
.OrderBy(x => x.SortIndex).OrderBy(x => x.SortUnitName).Select(x => new Model.reportItemListDto()
{
BusinessReportItemId = x.BusinessReportItemId,
BusinessReportId = x.BusinessReportId,
SortIndex = x.SortIndex,
Code = x.Code,
UnitLevel = x.UnitLevel,
CreateDate = x.CreateDate,
Place = x.Place,
PersonNum = x.PersonNum,
TotalAssets = x.TotalAssets,
TotalValue = x.TotalValue,
NewInvestment = x.NewInvestment,
UnitName = x.UnitName,
SortUnitName = x.SortUnitName
}).ToList();
}
public static string UpOperationReport(string businessReportId, Model.Sys_User CurrUser)
{
string code = "0";
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
try
{
var upReport = from x in db.Environmental_OperationReport
where x.BusinessReportId == businessReportId
select new Model.Environmental_OperationReportDto
{
BusinessReportId = x.BusinessReportId,
UnitId = x.UnitId,
Year = x.Year,
Quarters = x.Quarters,
FillingMan = x.FillingMan,
FillingDate = x.FillingDate,
StatisticsDutyPerson = x.StatisticsDutyPerson,
UnitDutyPerson = x.UnitDutyPerson,
Remark = x.Remark,
reportItemList = getreportItemList(x.BusinessReportId)
};
//新接口Api
code = UpApiOperationReportNew(upReport).ToString();
if (code == "1")
{
var report = db.Environmental_OperationReport.FirstOrDefault(e => e.BusinessReportId == businessReportId);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
}
LogService.AddSys_Log(CurrUser, "【中央企业环保产业企业基本情况和经营情况汇总表】上传到服务器" + upReport.Count().ToString() + "条数据;", null, BLL.Const.OperationReportMenuId, BLL.Const.BtnUploadResources);
}
else
{
LogService.AddSys_Log(CurrUser, "【中央企业环保产业企业基本情况和经营情况汇总表】上传到服务器失败;", null, BLL.Const.OperationReportMenuId, BLL.Const.BtnUploadResources);
}
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【中央企业环保产业企业基本情况和经营情况汇总表】上传到服务器", ex);
LogService.AddSys_Log(CurrUser, "【中央企业环保产业企业基本情况和经营情况汇总表】上传到服务器失败;", null, BLL.Const.OperationReportMenuId, BLL.Const.BtnUploadResources);
}
return code;
}
}
#region
private static int UpApiOperationReport(IQueryable<Model.OperationReportDto> upReport)
{
string baseurl = "/api/InformationData/SaveOperationReport";
var resultJsonReport = JsonConvert.SerializeObject(upReport.FirstOrDefault());
var responeData = BLL.ServerService.PushCNCEC(resultJsonReport, baseurl);
return responeData.code;
}
private static int UpApiOperationReportNew(IQueryable<Model.Environmental_OperationReportDto> upReport)
{
string baseurl = "/api/InformationData/SaveOperationReportNew";
var resultJsonReport = JsonConvert.SerializeObject(upReport.FirstOrDefault());
var responeData = BLL.ServerService.PushCNCEC(resultJsonReport, baseurl);
return responeData.code;
}
#endregion
#endregion
#region
/// <summary>
/// 中央企业节能环保产业企业生产和服务业务情况报表上报
/// </summary>
public static string UpEnergyReport(string energyReportId, Model.Sys_User CurrUser)
{
string code = "0";
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
try
{
var upReport = from x in db.Environmental_EnergyReport
where x.EnergyReportId == energyReportId
select new Model.EnergyReport
{
EnergyReportId = x.EnergyReportId,
UnitId = x.UnitId,
Year = x.Year,
Quarters = x.Quarters,
FillingMan = x.FillingMan,
FillingDate = x.FillingDate,
DutyPerson = x.DutyPerson,
};
var upReportItem = from x in db.Environmental_EnergyReportItem
where x.EnergyReportId == energyReportId
select new Model.EnergyReportItem
{
EnergyReportItemId = x.EnergyReportItemId,
EnergyReportId = x.EnergyReportId,
SortIndex = x.SortIndex,
BusinessCategory = x.BusinessCategory,
Throughput_BasePeriod = x.Throughput_BasePeriod,
Throughput_LastPeriod = x.Throughput_LastPeriod,
Throughput_ThisPeriod = x.Throughput_ThisPeriod,
Throughput_UnitOfMeasurement = x.Throughput_UnitOfMeasurement,
Yield_BasePeriod = x.Yield_BasePeriod,
Yield_LastPeriod = x.Yield_LastPeriod,
Yield_ThisPeriod = x.Yield_ThisPeriod,
Yield_UnitOfMeasurement = x.Yield_UnitOfMeasurement,
OutputValue_BasePeriod = x.OutputValue_BasePeriod,
OutputValue_LastYear = x.OutputValue_LastYear,
OutputValue_ThisYear = x.OutputValue_ThisYear,
OperationScale_BasePeriod = x.OperationScale_BasePeriod,
OperationScale_LastYear = x.OperationScale_LastYear,
OperationScale_ThisYear = x.OperationScale_ThisYear,
OperationScale_UnitOfMeasurement = x.OperationScale_UnitOfMeasurement,
ServiceOperatingIncome_BasePeriod = x.ServiceOperatingIncome_BasePeriod,
ServiceOperatingIncome_LastYear = x.ServiceOperatingIncome_LastYear,
ServiceOperatingIncome_ThisYear = x.ServiceOperatingIncome_ThisYear,
SortUnit = x.SortUnit
};
//老接口Serveice
//var getR = hsseC.DataInsertInformation_ChemicalReportTable(upReport.ToList(), upReportItem.ToList());
//新接口Api
code = UpApiEnergyReport(upReport, upReportItem).ToString();
if (code == "1")
{
foreach (var item in upReport.Select(p => p.EnergyReportId))
{
var report = db.Environmental_EnergyReport.FirstOrDefault(e => e.EnergyReportId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
////更新 当前人要处理的意见
//ProjectDataFlowSetService.CloseFlowOperate(Const.ChemicalReportMenuId, item, string.Empty);
// //更新催报信息
//UrgeReportService.SetComplete(report.UnitId, Const.ReportType_1, report.Year.ToString(), report.Quarters.ToString());
}
}
LogService.AddSys_Log(CurrUser, "【中央企业节能环保产业企业生产和服务业务情况报表上报】上传到服务器" + upReport.Count().ToString() + "条数据;", null, BLL.Const.EnergyReportMenuId, BLL.Const.BtnUploadResources);
}
else
{
LogService.AddSys_Log(CurrUser, "【中央企业节能环保产业企业生产和服务业务情况报表上报】上传到服务器失败;", null, BLL.Const.EnergyReportMenuId, BLL.Const.BtnUploadResources);
}
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【中央企业节能环保产业企业生产和服务业务情况报表上报】上传到服务器", ex);
LogService.AddSys_Log(CurrUser, "【中央企业节能环保产业企业生产和服务业务情况报表上报】上传到服务器失败;", null, BLL.Const.EnergyReportMenuId, BLL.Const.BtnUploadResources);
}
return code;
}
}
/// <summary>
/// UpApiChemicalReportApi调用
/// </summary>
/// <param name="upReport">主表</param>
/// <param name="upReportItem">明细表</param>
/// <returns></returns>
private static int UpApiEnergyReport(IQueryable<Model.EnergyReport> upReport, IQueryable<Model.EnergyReportItem> upReportItem)
{
string baseurl = "/api/InformationData/SaveEnergyReport";
//合并
//var resultJson = JsonConvert.SerializeObject(new { upReport, ReportItem = upReportItem });
var resultJsonReport = JsonConvert.SerializeObject(upReport.FirstOrDefault());
var resultJsonReportItem = JsonConvert.SerializeObject(new { EnergyReportItem = upReportItem });
resultJsonReport = "{\"InformationDataItems\":[" + (resultJsonReport + resultJsonReportItem).Replace("}{", ",") + "]}";
var responeData = BLL.ServerService.PushCNCEC(resultJsonReport, baseurl);
return responeData.code;
}
#endregion
#region
/// <summary>
/// 建筑行业能源节约与生态环境保护汇总表上报
/// </summary>
public static string UpArchitectureReport(string chemicalReportId, 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.Environmental_ArchitectureReport
where x.ArchitectureReportId == chemicalReportId
select new Model.ArchitectureReport
{
ArchitectureReportId = x.ArchitectureReportId,
UnitId = x.UnitId,
Year = x.Year,
Quarters = x.Quarters,
FillingMan = x.FillingMan,
FillingDate = x.FillingDate,
DutyPerson = x.DutyPerson,
};
var upReportItem = from x in db.Environmental_ArchitectureReportItem
where x.ArchitectureReportId == chemicalReportId
select new Model.ArchitectureReportItem
{
ArchitectureReportItemId = x.ArchitectureReportItemId,
ArchitectureReportId = x.ArchitectureReportId,
BaseNumber = x.BaseNumber,
SortIndex = x.SortIndex,
LastYearValue = x.LastYearValue,
ThisYearValue = x.ThisYearValue,
Rate = x.Rate,
};
//老接口Serveice
//var getR = hsseC.DataInsertInformation_ArchitectureReportTable(upReport.ToList(), upReportItem.ToList());
//新接口Api
code = UpApiArchitectureReport(upReport, upReportItem).ToString();
if (code == "1")
{
foreach (var item in upReport.Select(p => p.ArchitectureReportId))
{
var report = db.Environmental_ArchitectureReport.FirstOrDefault(e => e.ArchitectureReportId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
////更新 当前人要处理的意见
ProjectDataFlowSetService.CloseFlowOperate(Const.ArchitectureReportMenuId, item, string.Empty);
// //更新催报信息
UrgeReportService.SetComplete(report.UnitId, Const.ReportType_1, report.Year.ToString(), report.Quarters.ToString());
}
}
LogService.AddSys_Log(CurrUser, "【建筑行业能源节约与生态环境保护汇总表】上传到服务器" + upReport.Count().ToString() + "条数据;", null, BLL.Const.ArchitectureReportMenuId, BLL.Const.BtnUploadResources);
}
else
{
LogService.AddSys_Log(CurrUser, "【建筑行业能源节约与生态环境保护汇总表】上传到服务器失败;", null, BLL.Const.ArchitectureReportMenuId, BLL.Const.BtnUploadResources);
}
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【建筑行业能源节约与生态环境保护汇总表】上传到服务器", ex);
LogService.AddSys_Log(CurrUser, "【建筑行业能源节约与生态环境保护汇总表】上传到服务器失败;", null, BLL.Const.ArchitectureReportMenuId, BLL.Const.BtnUploadResources);
}
return code;
}
}
/// <summary>
/// UpApiArchitectureReportApi调用
/// </summary>
/// <param name="upReport">主表</param>
/// <param name="upReportItem">明细表</param>
/// <returns></returns>
private static int UpApiArchitectureReport(IQueryable<Model.ArchitectureReport> upReport, IQueryable<Model.ArchitectureReportItem> upReportItem)
{
string baseurl = "/api/InformationData/SaveArchitectureReport";
//合并
//var resultJson = JsonConvert.SerializeObject(new { upReport, ReportItem = upReportItem });
var resultJsonReport = JsonConvert.SerializeObject(upReport.FirstOrDefault());
var resultJsonReportItem = JsonConvert.SerializeObject(new { ArchitectureReportItem = upReportItem });
resultJsonReport = "{\"InformationDataItems\":[" + (resultJsonReport + resultJsonReportItem).Replace("}{", ",") + "]}";
var responeData = BLL.ServerService.PushCNCEC(resultJsonReport, baseurl);
return responeData.code;
}
#endregion
#region
/// <summary>
/// 企业监督检查报告上报
/// </summary>
public static string UpCheckReport(string upCheckReportId, Model.Sys_User CurrUser)
{
string code = "0";
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var upCheckReport = from x in db.Supervise_UpCheckReport
where x.UpCheckReportId == upCheckReportId
select new CNCECHSSEService.Supervise_UpCheckReport
{
UpCheckReportId = x.UpCheckReportId,
UnitId = x.UnitId,
CheckStartTime = x.CheckStartTime,
CheckEndTime = x.CheckEndTime,
Values1 = x.Values1,
Values2 = x.Values2,
Values3 = x.Values3,
Values4 = x.Values4,
Values5 = x.Values5,
Values6 = x.Values6,
Values7 = x.Values7,
CompileDate = x.CompileDate,
AuditDate = x.AuditDate,
};
var upCheckReportItem = from x in db.Supervise_UpCheckReportItem
where x.UpCheckReportId == upCheckReportId
select new CNCECHSSEService.Supervise_UpCheckReportItem
{
UpCheckReportItemId = x.UpCheckReportItemId,
UpCheckReportId = x.UpCheckReportId,
SortIndex = x.SortIndex,
Name = x.Name,
Sex = x.Sex,
UnitName = x.UnitName,
PostName = x.PostName,
WorkTitle = x.WorkTitle,
CheckPostName = x.CheckPostName,
CheckDate = x.CheckDate,
};
var upCheckReportItem2 = from x in db.Supervise_UpCheckReportItem2
where x.UpCheckReportId == upCheckReportId
select new CNCECHSSEService.Supervise_UpCheckReportItem2
{
UpCheckReportItem2Id = x.UpCheckReportItem2Id,
UpCheckReportId = x.UpCheckReportId,
SortIndex = x.SortIndex,
SubjectObject = x.SubjectObject,
SubjectObjectInfo = x.SubjectObjectInfo,
UnitMan = x.UnitMan,
UnitManTel = x.UnitManTel,
UnitHSSEMan = x.UnitHSSEMan,
UnitHSSEManTel = x.UnitHSSEManTel,
CheckDate = x.CheckDate,
RectifyCount = x.RectifyCount,
CompRectifyCount = x.CompRectifyCount,
TotalGetScore = x.TotalGetScore,
ResultLevel = x.ResultLevel,
};
var getR = hsseC.DataInsertSupervise_UpCheckReportTable(upCheckReport.ToList(), upCheckReportItem.ToList(), upCheckReportItem2.ToList());
foreach (var item in getR)
{
var report = db.Supervise_UpCheckReport.FirstOrDefault(e => e.UpCheckReportId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
report.UpDateTime = System.DateTime.Now;
db.SubmitChanges();
////更新 当前人要处理的意见
ProjectDataFlowSetService.CloseFlowOperate(Const.DrillPlanHalfYearReportMenuId, item, string.Empty);
}
}
code = "1";
LogService.AddSys_Log(CurrUser, "【安全监督检查评价报告】上传到服务器" + getR.Count.ToString() + "条数据;", null, BLL.Const.UpCheckReportMenuId, BLL.Const.BtnUploadResources);
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【安全监督检查评价报告】上传到服务器", ex);
LogService.AddSys_Log(CurrUser, "【安全监督检查评价报告】上传到服务器失败;", null, BLL.Const.UpCheckReportMenuId, BLL.Const.BtnUploadResources);
}
return code;
}
}
#endregion
#region
/// <summary>
/// 企业监督检查报告上报
/// </summary>
public static string UpCheck_CheckRectify(string checkRectifyId, Model.Sys_User CurrUser)
{
string code = "0";
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
try
{
// CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var upCheckReport = from x in db.View_CheckRectifyListFromSUB
where x.RealEndDate.HasValue && x.CheckRectifyId == checkRectifyId
select new Model.CheckRectifyItem
{
CheckRectifyId = x.CheckRectifyId,
CheckRectifyCode = x.CheckRectifyCode,
ProjectId = x.ProjectId,
UnitId = x.UnitId,
CheckDate = x.CheckDate,
IssueMan = x.IssueMan,
IssueDate = x.IssueDate,
HandleState = x.HandleState,
CheckRectifyItemId = x.CheckRectifyItemId,
ConfirmMan = x.ConfirmMan,
ConfirmDate = x.ConfirmDate,
OrderEndDate = x.OrderEndDate,
OrderEndPerson = x.OrderEndPerson,
RealEndDate = x.RealEndDate,
Verification = x.Verification,
AttachFileId = x.AttachFileId2,
ToKeyId = x.ToKeyId2,
AttachSource = x.AttachSource2,
AttachUrl = x.AttachUrl2,
////附件转为字节传送
FileContext = FileStructService.GetMoreFileStructByAttachUrl(x.AttachUrl2),
};
string baseurl = SysConstSetService.CNCECPath + "/api/HSSEData/UpCheckRectifyTable";
string contenttype = "application/json;charset=unicode";
Hashtable newToken = new Hashtable
{
{ "token", ServerService.GetToken().Token }
};
var pushContent = JsonConvert.SerializeObject(upCheckReport.ToList());
var strJosn = APIGetHttpService.Http(baseurl, "Post", contenttype, newToken, pushContent);
if (!string.IsNullOrEmpty(strJosn))
{
JObject obj = JObject.Parse(strJosn);
code = obj["code"].ToString();
if (code == "1")
{
var getIds = Funs.GetStrListByStr(obj["data"].ToString(), ',');
if (getIds.Count() > 0)
{
foreach (var item in getIds)
{
var newCheckRectify = db.Check_CheckRectify.FirstOrDefault(e => e.CheckRectifyId == item);
if (newCheckRectify != null)
{
newCheckRectify.HandleState = BLL.Const.State_3; //已完成
db.SubmitChanges();
}
}
}
LogService.AddSys_Log(CurrUser, "【集团检查整改】上传到服务器" + getIds.Count.ToString() + "条数据;", null, BLL.Const.UpCheckReportMenuId, BLL.Const.BtnUploadResources);
}
}
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【集团检查整改】上传到服务器", ex);
LogService.AddSys_Log(CurrUser, "【集团检查整改】上传到服务器失败;", null, BLL.Const.UpCheckReportMenuId, BLL.Const.BtnUploadResources);
}
return code;
}
}
#endregion
#region
/// <summary>
/// 企业安全文件上报
/// </summary>
public static string UpSupervise_SubUnitReportItem(string subUnitReportId, Model.Sys_User CurrUser)
{
string code = "0";
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var upCheckReport = from x in db.View_Supervise_SubUnitReportItem
where x.SubUnitReportId == subUnitReportId && (x.UpState == BLL.Const.UpState_2 || x.UpState == BLL.Const.UpState_4 || x.UpState == null)
select new CNCECHSSEService.Supervise_SubUnitReportItem
{
SubUnitReportItemId = x.SubUnitReportItemId,
ReportTitle = x.ReportTitle,
ReportContent = x.ReportContent,
// AttachUrl = x.AttachUrl,
ReportDate = x.ReportDate,
State = x.State,
////附件转为字节传送
//FileContext = FileStructService.GetFileStructByAttachUrl(x.AttachUrl)
AttachFileId = x.AttachFileId,
ToKeyId = x.ToKeyId,
AttachSource = x.AttachSource,
AttachUrl = x.AttachUrl,
////附件转为字节传送
FileContext = FileStructService.GetMoreFileStructByAttachUrl(x.AttachUrl),
};
if (upCheckReport.Count() > 0)
{
var getR = hsseC.DataInsertSupervise_SubUnitReportItemItemTable(upCheckReport.ToList());
foreach (var item in getR)
{
var subUnitReportItem = db.Supervise_SubUnitReportItem.FirstOrDefault(e => e.SubUnitReportItemId == item);
if (subUnitReportItem != null)
{
subUnitReportItem.UpState = BLL.Const.UpState_3;
subUnitReportItem.State = BLL.Const.UpState_3;
db.SubmitChanges();
}
}
}
code = "1";
LogService.AddSys_Log(CurrUser, "【企业安全文件上报】上传到服务器" + upCheckReport.Count().ToString() + "条数据;", null, BLL.Const.UpCheckReportMenuId, BLL.Const.BtnUploadResources);
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【企业安全文件上报】上传到服务器", ex);
LogService.AddSys_Log(CurrUser, "【企业安全文件上报】上传到服务器失败;", null, BLL.Const.UpCheckReportMenuId, BLL.Const.BtnUploadResources);
}
return code;
}
}
#endregion
#region
/// <summary>
/// 安全管理工作总结报告
/// </summary>
/// <param name="workSummaryReportId"></param>
/// <param name="CurrUser"></param>
/// <returns></returns>
public static string UpWorkSummaryReport(string workSummaryReportId, 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_WorkSummaryReport
where x.WorkSummaryReportId == workSummaryReportId
select new Model.WorkSummaryReport
{
WorkSummaryReportId = x.WorkSummaryReportId,
UnitId = x.UnitId,
YearId = x.YearId,
ResponsiblePerson = x.ResponsiblePerson,
ResponsiblePersonTel = x.ResponsiblePersonTel,
ContactPerson = x.ContactPerson,
ContactPersonTel = x.ContactPersonTel,
ReportDate = x.ReportDate,
SafeLaborTime = x.SafeLaborTime,
SafetyObjectives = x.SafetyObjectives,
AccidentSituation = x.AccidentSituation,
Awards = x.Awards,
WorkDevelopment = x.WorkDevelopment,
PersonnelTraining = x.PersonnelTraining,
GovernanceSituation = x.GovernanceSituation,
ManagementActivity = x.ManagementActivity,
WorkExperience = x.WorkExperience,
Countermeasures = x.Countermeasures,
NextYearWorkPlan = x.NextYearWorkPlan,
JobSuggestion = x.JobSuggestion
};
//老接口Serveice
//var getR = hsseC.DataInsertInformation_ChemicalReportTable(upReport.ToList(), upReportItem.ToList());
//新接口Api
code = UpApiWorkSummaryReport(upReport).ToString();
if (code == "1")
{
foreach (var item in upReport.Select(p => p.WorkSummaryReportId))
{
var report = db.Information_WorkSummaryReport.FirstOrDefault(e => e.WorkSummaryReportId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
////更新 当前人要处理的意见
ProjectDataFlowSetService.CloseFlowOperate(Const.WorkSummaryReportMenuId, item, string.Empty);
// //更新催报信息
UrgeReportService.SetComplete(report.UnitId, Const.ReportType_6, report.YearId.ToString(), string.Empty);
}
}
LogService.AddSys_Log(CurrUser, "【安全管理工作总结报告】上传到服务器" + upReport.Count().ToString() + "条数据;", null, BLL.Const.WorkSummaryReportMenuId, BLL.Const.BtnUploadResources);
}
else
{
LogService.AddSys_Log(CurrUser, "【安全管理工作总结报告】上传到服务器失败;", null, BLL.Const.WorkSummaryReportMenuId, BLL.Const.BtnUploadResources);
}
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【安全管理工作总结报告】上传到服务器", ex);
LogService.AddSys_Log(CurrUser, "【安全管理工作总结报告】上传到服务器失败;", null, BLL.Const.WorkSummaryReportMenuId, BLL.Const.BtnUploadResources);
}
return code;
}
}
/// <summary>
/// UpApiWorkSummaryReportApi调用
/// </summary>
/// <param name="upReport">主表</param>
/// <returns></returns>
private static int UpApiWorkSummaryReport(IQueryable<Model.WorkSummaryReport> upReport)
{
string baseurl = "/api/InformationData/SaveWorkSummaryReport";
var resultJsonReport = JsonConvert.SerializeObject(upReport.FirstOrDefault());
//var resultJsonReportItem = JsonConvert.SerializeObject(new { ChemicalReportItem = upReportItem });
resultJsonReport = "{\"InformationDataItems\":[" + resultJsonReport.Replace("}{", ",") + "]}";
var responeData = BLL.ServerService.PushCNCEC(resultJsonReport, baseurl);
return responeData.code;
}
#endregion
#region
/// <summary>
/// 质量管理工作总结报告
/// </summary>
/// <param name="qualityWorkSummaryReportId"></param>
/// <param name="CurrUser"></param>
/// <returns></returns>
public static string UpQualityWorkSummaryReport(string qualityWorkSummaryReportId, 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_QualityWorkSummaryReport
where x.QualityWorkSummaryReportId == qualityWorkSummaryReportId
select new Model.QualityWorkSummaryReport
{
QualityWorkSummaryReportId = x.QualityWorkSummaryReportId,
UnitId = x.UnitId,
YearId = x.YearId,
ResponsiblePerson = x.ResponsiblePerson,
ResponsiblePersonTel = x.ResponsiblePersonTel,
ContactPerson = x.ContactPerson,
ContactPersonTel = x.ContactPersonTel,
ReportDate = x.ReportDate,
Performance = x.Performance,
AccidentSituation = x.AccidentSituation,
Awards = x.Awards,
WorkDevelopment = x.WorkDevelopment,
PersonnelTraining = x.PersonnelTraining,
CheckSituation = x.CheckSituation,
ManagementActivity = x.ManagementActivity,
WorkExperience = x.WorkExperience,
Countermeasures = x.Countermeasures,
NextYearWorkPlan = x.NextYearWorkPlan,
JobSuggestion = x.JobSuggestion
};
//老接口Serveice
//var getR = hsseC.DataInsertInformation_ChemicalReportTable(upReport.ToList(), upReportItem.ToList());
//新接口Api
code = UpApiQualityWorkSummaryReport(upReport).ToString();
if (code == "1")
{
foreach (var item in upReport.Select(p => p.QualityWorkSummaryReportId))
{
var report = db.Information_QualityWorkSummaryReport.FirstOrDefault(e => e.QualityWorkSummaryReportId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
////更新 当前人要处理的意见
ProjectDataFlowSetService.CloseFlowOperate(Const.QualityWorkSummaryReportMenuId, item, string.Empty);
// //更新催报信息
UrgeReportService.SetComplete(report.UnitId, Const.ReportType_7, report.YearId.ToString(), string.Empty);
}
}
LogService.AddSys_Log(CurrUser, "【质量管理工作总结报告】上传到服务器" + upReport.Count().ToString() + "条数据;", null, BLL.Const.QualityWorkSummaryReportMenuId, BLL.Const.BtnUploadResources);
}
else
{
LogService.AddSys_Log(CurrUser, "【质量管理工作总结报告】上传到服务器失败;", null, BLL.Const.QualityWorkSummaryReportMenuId, BLL.Const.BtnUploadResources);
}
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【质量管理工作总结报告】上传到服务器", ex);
LogService.AddSys_Log(CurrUser, "【质量管理工作总结报告】上传到服务器失败;", null, BLL.Const.QualityWorkSummaryReportMenuId, BLL.Const.BtnUploadResources);
}
return code;
}
}
/// <summary>
/// UpApiQualityWorkSummaryReport
/// </summary>
/// <param name="upReport">主表</param>
/// <returns></returns>
private static int UpApiQualityWorkSummaryReport(IQueryable<Model.QualityWorkSummaryReport> upReport)
{
string baseurl = "/api/InformationData/SaveQualityWorkSummaryReport";
var resultJsonReport = JsonConvert.SerializeObject(upReport.FirstOrDefault());
//var resultJsonReportItem = JsonConvert.SerializeObject(new { ChemicalReportItem = upReportItem });
resultJsonReport = "{\"InformationDataItems\":[" + resultJsonReport.Replace("}{", ",") + "]}";
var responeData = BLL.ServerService.PushCNCEC(resultJsonReport, baseurl);
return responeData.code;
}
#endregion
#region
/// <summary>
/// 实业安全简报
/// </summary>
/// <param name="safetyBriefingId"></param>
/// <param name="CurrUser"></param>
/// <returns></returns>
public static string UpSafetyBriefing(string safetyBriefingId, 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_SafetyBriefing
where x.SafetyBriefingId == safetyBriefingId
select new Model.SafetyBriefing
{
SafetyBriefingId = x.SafetyBriefingId,
UnitId = x.UnitId,
YearId = x.YearId,
Month = x.Month,
CompileMan = BLL.UserService.GetUserNameByUserId(x.CompileMan),
CompileDate = x.CompileDate,
Auditor = x.Auditor,
Approver = x.Approver,
MainWork = x.MainWork,
HazardRecording = x.HazardRecording,
SafetyAccident = x.SafetyAccident,
EPAccident = x.EPAccident,
OHAccident = x.OHAccident,
WorkPermitNum = x.WorkPermitNum,
HiddenDangerDetection = x.HiddenDangerDetection,
RectificationSituation = x.RectificationSituation,
CheckProblemsRectification = x.CheckProblemsRectification,
PendingProject = x.PendingProject,
ContractorManagement = x.ContractorManagement,
EnvironmentalEmissions = x.EnvironmentalEmissions,
NextMonthWorkPlan = x.NextMonthWorkPlan
};
//老接口Serveice
//var getR = hsseC.DataInsertInformation_ChemicalReportTable(upReport.ToList(), upReportItem.ToList());
//新接口Api
code = UpApiSafetyBriefing(upReport).ToString();
if (code == "1")
{
foreach (var item in upReport.Select(p => p.SafetyBriefingId))
{
var report = db.Information_SafetyBriefing.FirstOrDefault(e => e.SafetyBriefingId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
////更新 当前人要处理的意见
ProjectDataFlowSetService.CloseFlowOperate(Const.SafetyBriefingMenuId, item, string.Empty);
// //更新催报信息
UrgeReportService.SetComplete(report.UnitId, Const.ReportType_7, report.YearId.ToString(), report.Month.ToString());
}
}
LogService.AddSys_Log(CurrUser, "【实业安全简报】上传到服务器" + upReport.Count().ToString() + "条数据;", null, BLL.Const.SafetyBriefingMenuId, BLL.Const.BtnUploadResources);
}
else
{
LogService.AddSys_Log(CurrUser, "【实业安全简报】上传到服务器失败;", null, BLL.Const.SafetyBriefingMenuId, BLL.Const.BtnUploadResources);
}
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【实业安全简报】上传到服务器", ex);
LogService.AddSys_Log(CurrUser, "【实业安全简报】上传到服务器失败;", null, BLL.Const.SafetyBriefingMenuId, BLL.Const.BtnUploadResources);
}
return code;
}
}
/// <summary>
/// UpApiSafetyBriefing
/// </summary>
/// <param name="upReport">主表</param>
/// <returns></returns>
private static int UpApiSafetyBriefing(IQueryable<Model.SafetyBriefing> upReport)
{
string baseurl = "/api/InformationData/SaveSafetyBriefing";
var resultJsonReport = JsonConvert.SerializeObject(upReport.FirstOrDefault());
//var resultJsonReportItem = JsonConvert.SerializeObject(new { ChemicalReportItem = upReportItem });
resultJsonReport = "{\"InformationDataItems\":[" + resultJsonReport.Replace("}{", ",") + "]}";
var responeData = BLL.ServerService.PushCNCEC(resultJsonReport, baseurl);
return responeData.code;
}
#endregion
#region
/// <summary>
/// 季度工程项目质量信息表
/// </summary>
/// <param name="quarterlyProjectQualityId"></param>
/// <param name="CurrUser"></param>
/// <returns></returns>
public static string UpQuarterlyProjectQuality(string quarterlyProjectQualityId, 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_QuarterlyProjectQuality
where x.QuarterlyProjectQualityId == quarterlyProjectQualityId
select new Model.QuarterlyProjectQuality
{
QuarterlyProjectQualityId = x.QuarterlyProjectQualityId,
UnitId = x.UnitId,
Year = x.Year,
Quarter = x.Quarter,
QualityManagePersonNum = x.QualityManagePersonNum,
AdvancedTitlePersonNum = x.AdvancedTitlePersonNum,
IntermediateTitlePersonNum = x.IntermediateTitlePersonNum,
BeImplementedProjectNum = x.BeImplementedProjectNum,
StartImplementedProjectNum = x.StartImplementedProjectNum,
AccumulativeStartImplemented = x.AccumulativeStartImplemented,
CompleteProjectNum = x.CompleteProjectNum,
YearCompleteProjectNum = x.YearCompleteProjectNum,
QuarterTotal = x.QuarterTotal,
QuarterFirstPassNum = x.QuarterFirstPassNum,
QuarterFirstPassRate = x.QuarterFirstPassRate,
YearTotal = x.YearTotal,
YearFirstPassNum = x.YearFirstPassNum,
YearFirstPassRate = x.YearFirstPassRate,
QuaterCheckSuperviseNum = x.QuaterCheckSuperviseNum,
QuaterCorrectiveNoticeNum = x.QuaterCorrectiveNoticeNum,
QuaterQualityProblemNum = x.QuaterQualityProblemNum,
QuaterClosedQualityProblemNum = x.QuaterClosedQualityProblemNum,
YearCheckSuperviseNum = x.YearCheckSuperviseNum,
YearCorrectiveNoticeNum = x.YearCorrectiveNoticeNum,
YearQualityProblemNum = x.YearQualityProblemNum,
YearClosedQualityProblemNum = x.YearClosedQualityProblemNum,
QuaterQualityAccidentNum = x.QuaterQualityAccidentNum,
QuaterDirectEconomicLoss = x.QuaterDirectEconomicLoss,
YearQualityAccidentNum = x.YearQualityAccidentNum,
YearDirectEconomicLoss = x.YearDirectEconomicLoss,
ResponsiblePerson = BLL.UserService.GetUserNameByUserId(x.ResponsiblePerson),
CompileMan = BLL.UserService.GetUserNameByUserId(x.CompileMan),
CompileDate = x.CompileDate,
Tel = x.Tel
};
//老接口Serveice
//var getR = hsseC.DataInsertInformation_ChemicalReportTable(upReport.ToList(), upReportItem.ToList());
//新接口Api
code = UpApiQuarterlyProjectQuality(upReport).ToString();
if (code == "1")
{
foreach (var item in upReport.Select(p => p.QuarterlyProjectQualityId))
{
var report = db.Information_QuarterlyProjectQuality.FirstOrDefault(e => e.QuarterlyProjectQualityId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
////更新 当前人要处理的意见
ProjectDataFlowSetService.CloseFlowOperate(Const.QuarterlyProjectQualityMenuId, item, string.Empty);
// //更新催报信息
UrgeReportService.SetComplete(report.UnitId, Const.ReportType_9, report.Year.ToString(), report.Quarter.ToString());
}
}
LogService.AddSys_Log(CurrUser, "【季度工程项目质量信息表】上传到服务器" + upReport.Count().ToString() + "条数据;", null, BLL.Const.QuarterlyProjectQualityMenuId, BLL.Const.BtnUploadResources);
}
else
{
LogService.AddSys_Log(CurrUser, "【季度工程项目质量信息表】上传到服务器失败;", null, BLL.Const.QuarterlyProjectQualityMenuId, BLL.Const.BtnUploadResources);
}
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【季度工程项目质量信息表】上传到服务器", ex);
LogService.AddSys_Log(CurrUser, "【季度工程项目质量信息表】上传到服务器失败;", null, BLL.Const.QuarterlyProjectQualityMenuId, BLL.Const.BtnUploadResources);
}
return code;
}
}
/// <summary>
/// UpApiSafetyBriefing
/// </summary>
/// <param name="upReport">主表</param>
/// <returns></returns>
private static int UpApiQuarterlyProjectQuality(IQueryable<Model.QuarterlyProjectQuality> upReport)
{
string baseurl = "/api/InformationData/SaveQuarterlyProjectQuality";
var resultJsonReport = JsonConvert.SerializeObject(upReport.FirstOrDefault());
//var resultJsonReportItem = JsonConvert.SerializeObject(new { ChemicalReportItem = upReportItem });
resultJsonReport = "{\"InformationDataItems\":[" + resultJsonReport.Replace("}{", ",") + "]}";
var responeData = BLL.ServerService.PushCNCEC(resultJsonReport, baseurl);
return responeData.code;
}
#endregion
#region
/// <summary>
/// 生态环保工作总结报告
/// </summary>
/// <param name="ePSummaryReportId"></param>
/// <param name="CurrUser"></param>
/// <returns></returns>
public static string UpEPSummaryReport(string ePSummaryReportId, 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_EPSummaryReport
where x.EPSummaryReportId == ePSummaryReportId
select new Model.EPSummaryReport
{
EPSummaryReportId = x.EPSummaryReportId,
UnitId = x.UnitId,
YearId = x.YearId,
Quarter = x.Quarter,
ResponsiblePerson = x.ResponsiblePerson,
ResponsiblePersonTel = x.ResponsiblePersonTel,
ContactPerson = x.ContactPerson,
ContactPersonTel = x.ContactPersonTel,
ReportDate = x.ReportDate,
Description1 = x.Description1,
Description2 = x.Description2,
Description3 = x.Description3,
Description4 = x.Description4,
Description5 = x.Description5,
Description6 = x.Description6,
Description7 = x.Description7,
Description8 = x.Description8,
Description9 = x.Description9
};
//老接口Serveice
//var getR = hsseC.DataInsertInformation_ChemicalReportTable(upReport.ToList(), upReportItem.ToList());
//新接口Api
code = UpApiEPSummaryReport(upReport).ToString();
if (code == "1")
{
foreach (var item in upReport.Select(p => p.EPSummaryReportId))
{
var report = db.Information_EPSummaryReport.FirstOrDefault(e => e.EPSummaryReportId == item);
if (report != null)
{
report.UpState = BLL.Const.UpState_3;
db.SubmitChanges();
////更新 当前人要处理的意见
ProjectDataFlowSetService.CloseFlowOperate(Const.EPSummaryReportMenuId, item, string.Empty);
// //更新催报信息
UrgeReportService.SetComplete(report.UnitId, Const.ReportType_10, report.YearId.ToString(), string.Empty);
}
}
LogService.AddSys_Log(CurrUser, "【生态环保工作总结报告】上传到服务器" + upReport.Count().ToString() + "条数据;", null, BLL.Const.EPSummaryReportMenuId, BLL.Const.BtnUploadResources);
}
else
{
LogService.AddSys_Log(CurrUser, "【生态环保工作总结报告】上传到服务器失败;", null, BLL.Const.EPSummaryReportMenuId, BLL.Const.BtnUploadResources);
}
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【生态环保工作总结报告】上传到服务器", ex);
LogService.AddSys_Log(CurrUser, "【生态环保工作总结报告】上传到服务器失败;", null, BLL.Const.EPSummaryReportMenuId, BLL.Const.BtnUploadResources);
}
return code;
}
}
/// <summary>
/// UpApiEPSummaryReport
/// </summary>
/// <param name="upReport">主表</param>
/// <returns></returns>
private static int UpApiEPSummaryReport(IQueryable<Model.EPSummaryReport> upReport)
{
string baseurl = "/api/InformationData/SaveEPSummaryReport";
var resultJsonReport = JsonConvert.SerializeObject(upReport.FirstOrDefault());
//var resultJsonReportItem = JsonConvert.SerializeObject(new { ChemicalReportItem = upReportItem });
resultJsonReport = "{\"InformationDataItems\":[" + resultJsonReport.Replace("}{", ",") + "]}";
var responeData = BLL.ServerService.PushCNCEC(resultJsonReport, baseurl);
return responeData.code;
}
#endregion
#endregion
#region
#region
/// <summary>
/// 催报信息从集团公司提取到企业
/// </summary>
/// <returns></returns>
public static Model.ResponeData getInformation_UrgeReport()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
string thisUnitId = BLL.Const.UnitId_CWCEC;
var getData = hsseC.GetInformation_UrgeReportToSUB(thisUnitId);
if (getData.Count() > 0)
{
foreach (var item in getData)
{
var urg = db.Information_UrgeReport.FirstOrDefault(x => x.UrgeReportId == item.UrgeReportId);
if (urg == null)
{
Model.Information_UrgeReport newUrgeReport = new Model.Information_UrgeReport
{
UrgeReportId = item.UrgeReportId,
UnitId = item.UnitId,
ReprotType = item.ReprotType,
YearId = item.YearId,
MonthId = item.MonthId,
QuarterId = item.QuarterId,
HalfYearId = item.HalfYearId,
UrgeDate = item.UrgeDate,
IsComplete = null,
IsCancel = item.IsCancel
};
db.Information_UrgeReport.InsertOnSubmit(newUrgeReport);
db.SubmitChanges();
}
else
{
urg.IsCancel = item.IsCancel;
db.SubmitChanges();
}
}
}
responeData.message = "获取成功:记录" + getData.Count().ToString() + "条";
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("催报信息从集团公司提取到企业!", ex);
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 安全监督检查整改信息从集团公司提取
/// </summary>
/// <returns></returns>
public static Model.ResponeData getCheck_CheckRectify()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
string thisUnitId = BLL.Const.UnitId_CWCEC;
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var getData = hsseC.GetCheck_CheckRectifyListToSUB(thisUnitId);
if (getData.Count() > 0)
{
List<string> ids = new List<string>();
foreach (var item in getData)
{
if (!ids.Contains(item.CheckRectifyId))
{
var newRectify = db.Check_CheckRectify.FirstOrDefault(e => e.CheckRectifyId == item.CheckRectifyId);
if (newRectify == null)
{
ids.Add(item.CheckRectifyId);
Model.Check_CheckRectify newCheckRectify = new Model.Check_CheckRectify
{
CheckRectifyId = item.CheckRectifyId,
CheckRectifyCode = item.CheckRectifyCode,
ProjectId = item.ProjectId,
UnitId = item.UnitId,
CheckDate = item.CheckDate,
IssueMan = item.IssueMan,
IssueDate = item.IssueDate,
HandleState = item.HandleState
};
db.Check_CheckRectify.InsertOnSubmit(newCheckRectify);
db.SubmitChanges();
//获取对应主表主键的明细集合
var table5Items = getData.Where(x => x.CheckRectifyId == item.CheckRectifyId);
foreach (var newItem in table5Items)
{
var oldItem5 = db.Check_CheckInfo_Table5Item.FirstOrDefault(x => x.ID == newItem.Table5ItemId);
if (oldItem5 == null)
{
Model.Check_CheckInfo_Table5Item newCheckRectifyItem = new Model.Check_CheckInfo_Table5Item
{
ID = newItem.Table5ItemId,
SortIndex = newItem.SortIndex,
WorkType = newItem.WorkType,
DangerPoint = newItem.DangerPoint,
RiskExists = newItem.RiskExists,
IsProject = newItem.IsProject,
CheckMan = newItem.CheckMan,
SubjectUnitMan = newItem.SubjectUnitMan
};
db.Check_CheckInfo_Table5Item.InsertOnSubmit(newCheckRectifyItem);
db.SubmitChanges();
////上传附件
if (!string.IsNullOrEmpty(newItem.AttachFileId))
{
BLL.FileInsertService.InsertAttachFile(newItem.AttachFileId, newItem.Table5ItemId, newItem.AttachSource, newItem.AttachUrl, newItem.FileContext);
}
}
var oldItem = db.Check_CheckRectifyItem.FirstOrDefault(e => e.CheckRectifyItemId == newItem.CheckRectifyItemId);
if (oldItem == null)
{
Model.Check_CheckRectifyItem newCheckRectifyItem = new Model.Check_CheckRectifyItem
{
CheckRectifyItemId = newItem.CheckRectifyItemId,
CheckRectifyId = newItem.CheckRectifyId,
Table5ItemId = newItem.Table5ItemId,
ConfirmMan = newItem.ConfirmMan,
ConfirmDate = newItem.ConfirmDate,
OrderEndDate = newItem.OrderEndDate,
OrderEndPerson = newItem.OrderEndPerson,
RealEndDate = newItem.RealEndDate
};
db.Check_CheckRectifyItem.InsertOnSubmit(newCheckRectifyItem);
db.SubmitChanges();
}
}
}
}
}
}
responeData.message = "获取成功:整改明细记录" + getData.Count().ToString() + "条";
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("安全监督检查整改信息从集团公司提取!", ex);
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 安全监督检查报告信息从集团公司提取
/// </summary>
/// <returns></returns>
public static Model.ResponeData getCheck_CheckInfo_Table8Item()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
string thisUnitId = BLL.Const.UnitId_CWCEC;
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var getData = hsseC.GetCheck_CheckInfo_Table8ItemListToSUB(thisUnitId);
if (getData.Count() > 0)
{
List<string> ids = new List<string>();
foreach (var item in getData)
{
if (!ids.Contains(item.CheckInfoId))
{
var updateCheckInfo = db.Check_CheckInfo.FirstOrDefault(x => x.CheckInfoId == item.CheckInfoId);
if (updateCheckInfo == null)
{
ids.Add(item.CheckInfoId);
Model.Check_CheckInfo newCheckInfo = new Model.Check_CheckInfo
{
CheckInfoId = item.CheckInfoId,
CheckTypeName = item.CheckTypeName,
SubjectUnitId = item.SubjectUnitId,
SubjectUnitAdd = item.SubjectUnitAdd,
SubjectUnitMan = item.SubjectUnitMan,
SubjectUnitTel = item.SubjectUnitTel,
CheckStartTime = item.CheckStartTime,
CheckEndTime = item.CheckEndTime,
SubjectObject = item.SubjectObject
};
db.Check_CheckInfo.InsertOnSubmit(newCheckInfo);
db.SubmitChanges();
}
else
{
updateCheckInfo.CheckInfoId = item.CheckInfoId;
updateCheckInfo.CheckTypeName = item.CheckTypeName;
updateCheckInfo.SubjectUnitId = item.SubjectUnitId;
updateCheckInfo.SubjectUnitAdd = item.SubjectUnitAdd;
updateCheckInfo.SubjectUnitMan = item.SubjectUnitMan;
updateCheckInfo.SubjectUnitTel = item.SubjectUnitTel;
updateCheckInfo.CheckStartTime = item.CheckStartTime;
updateCheckInfo.CheckEndTime = item.CheckEndTime;
updateCheckInfo.SubjectObject = item.SubjectObject;
db.SubmitChanges();
}
}
var updateTable8 = db.Check_CheckInfo_Table8.FirstOrDefault(x => x.CheckItemId == item.CheckItemId);
if (updateTable8 == null)
{
Model.Check_CheckInfo_Table8 newTable8 = new Model.Check_CheckInfo_Table8
{
CheckItemId = item.CheckItemId,
CheckInfoId = item.CheckInfoId,
Values1 = item.Values1,
Values2 = item.Values2,
Values3 = item.Values3,
Values4 = item.Values4,
Values5 = item.Values5,
Values6 = item.Values6,
Values7 = item.Values7,
Values8 = item.Values8
};
db.Check_CheckInfo_Table8.InsertOnSubmit(newTable8);
db.SubmitChanges();
}
else
{
updateTable8.Values1 = item.Values1;
updateTable8.Values2 = item.Values2;
updateTable8.Values3 = item.Values3;
updateTable8.Values4 = item.Values4;
updateTable8.Values5 = item.Values5;
updateTable8.Values6 = item.Values6;
updateTable8.Values7 = item.Values7;
updateTable8.Values8 = item.Values8;
db.SubmitChanges();
}
var updateTable8Item = db.Check_CheckInfo_Table8Item.FirstOrDefault(x => x.ID == item.ID);
if (updateTable8Item == null)
{
Model.Check_CheckInfo_Table8Item newTable8Item = new Model.Check_CheckInfo_Table8Item
{
ID = item.ID,
CheckInfoId = item.CheckInfoId,
Name = item.Name,
Sex = item.Sex,
UnitName = item.UnitName,
PostName = item.PostName,
WorkTitle = item.WorkTitle,
CheckPostName = item.CheckPostName,
CheckDate = item.CheckDate,
SortIndex = item.SortIndex
};
db.Check_CheckInfo_Table8Item.InsertOnSubmit(newTable8Item);
db.SubmitChanges();
}
else
{
updateTable8Item.ID = item.ID;
updateTable8Item.CheckInfoId = item.CheckInfoId;
updateTable8Item.Name = item.Name;
updateTable8Item.Sex = item.Sex;
updateTable8Item.UnitName = item.UnitName;
updateTable8Item.PostName = item.PostName;
updateTable8Item.WorkTitle = item.WorkTitle;
updateTable8Item.CheckPostName = item.CheckPostName;
updateTable8Item.CheckDate = item.CheckDate;
updateTable8Item.SortIndex = item.SortIndex;
db.SubmitChanges();
}
}
responeData.message = "获取成功:记录" + getData.Count().ToString() + "条";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("安全监督检查报告信息从集团公司提取!", ex);
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 企业安全文件上报
/// </summary>
/// <returns></returns>
public static Model.ResponeData getSupervise_SubUnitReport()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var getData = hsseC.GetSupervise_SubUnitReportListToSUB();
if (getData.Count() > 0)
{
foreach (var item in getData)
{
var newSubUnitReport = db.Supervise_SubUnitReport.FirstOrDefault(e => e.SubUnitReportId == item.SubUnitReportId);
if (newSubUnitReport == null)
{
Model.Supervise_SubUnitReport newSubUnitReport1 = new Model.Supervise_SubUnitReport
{
SubUnitReportId = item.SubUnitReportId,
SubUnitReportCode = item.SubUnitReportCode,
SubUnitReportName = item.SubUnitReportName,
SupSubUnitReportId = item.SupSubUnitReportId,
IsEndLever = item.IsEndLever
};
db.Supervise_SubUnitReport.InsertOnSubmit(newSubUnitReport1);
db.SubmitChanges();
}
else
{
newSubUnitReport.SubUnitReportCode = item.SubUnitReportCode;
newSubUnitReport.SubUnitReportName = item.SubUnitReportName;
newSubUnitReport.SupSubUnitReportId = item.SupSubUnitReportId;
newSubUnitReport.IsEndLever = item.IsEndLever;
db.SubmitChanges();
}
}
}
string thisUnitId = BLL.Const.UnitId_CWCEC;
var getDataItem = hsseC.GetSupervise_SubUnitReportItemListToSUB(thisUnitId);
foreach (var item in getDataItem)
{
var newItem = db.Supervise_SubUnitReportItem.FirstOrDefault(e => e.SubUnitReportItemId == item.SubUnitReportItemId);
if (newItem == null)
{
var newSubUnitReport = db.Supervise_SubUnitReport.FirstOrDefault(e => e.SubUnitReportId == item.SubUnitReportId);
if (newSubUnitReport != null)
{
Model.Supervise_SubUnitReportItem newItem1 = new Model.Supervise_SubUnitReportItem
{
SubUnitReportItemId = item.SubUnitReportItemId,
SubUnitReportId = item.SubUnitReportId,
UnitId = item.UnitId,
PlanReortDate = item.PlanReortDate,
State = item.State
};
db.Supervise_SubUnitReportItem.InsertOnSubmit(newItem1);
db.SubmitChanges();
}
}
else
{
newItem.SubUnitReportId = item.SubUnitReportId;
newItem.UnitId = item.UnitId;
newItem.PlanReortDate = item.PlanReortDate;
newItem.State = item.State;
db.SubmitChanges();
}
}
responeData.message = "获取成功:类型记录" + getData.Count().ToString() + "条;明细记录" + getDataItem.Count().ToString() + "条";
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("企业安全文件上报!", ex);
}
return responeData;
}
}
#endregion
#endregion
#region
#region
/// <summary>
/// 法律法规从集团公司提取到企业
/// </summary>
/// <returns></returns>
public static Model.ResponeData getLaw_LawRegulationList()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var getData = hsseC.GetLaw_LawRegulationListToSUB();
if (getData.Count() > 0)
{
List<Model.Law_LawRegulationList> LawRegulationLists = new List<Model.Law_LawRegulationList>();
foreach (var item in getData)
{
var getLawRegulationList = db.Law_LawRegulationList.FirstOrDefault(x => x.LawRegulationId == item.LawRegulationId);
if (getLawRegulationList == null)
{
var type = db.Base_LawsRegulationsType.FirstOrDefault(e => e.Id == item.LawsRegulationsTypeId);
if (!string.IsNullOrEmpty(item.LawsRegulationsTypeId) && type == null)
{
Model.Base_LawsRegulationsType new_LawsRegulationsType = new Model.Base_LawsRegulationsType
{
Id = item.LawsRegulationsTypeId,
Code = item.LawsRegulationsTypeCode,
Name = item.LawsRegulationsTypeName
};
db.Base_LawsRegulationsType.InsertOnSubmit(new_LawsRegulationsType);
db.SubmitChanges();
}
Model.Law_LawRegulationList newLawRegulationList = new Model.Law_LawRegulationList
{
LawRegulationId = item.LawRegulationId,
LawsRegulationsTypeId = item.LawsRegulationsTypeId,
ApprovalDate = item.ApprovalDate,
CompileDate = item.CompileDate,
CompileMan = item.CompileMan,
Description = item.Description,
EffectiveDate = item.EffectiveDate,
IsPass = true,
LawRegulationCode = item.LawRegulationCode,
LawRegulationName = item.LawRegulationName,
UnitId = item.UnitId,
IsBuild = true
};
LawRegulationLists.Add(newLawRegulationList);
////上传附件
BLL.FileInsertService.InsertAttachFile(item.AttachFileId, item.LawRegulationId, item.AttachSource, item.AttachUrl, item.FileContext);
}
}
if (LawRegulationLists.Count() > 0)
{
db.Law_LawRegulationList.InsertAllOnSubmit(LawRegulationLists);
db.SubmitChanges();
}
responeData.message = "获取成功:记录" + LawRegulationLists.Count().ToString() + "条";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("法律法规从集团公司提取到企业!", ex);
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 标准规范从集团公司提取到企业
/// </summary>
/// <returns></returns>
public static Model.ResponeData getLaw_HSSEStandardsList()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var getData = hsseC.GetLaw_HSSEStandardsListToSUB();
if (getData.Count() > 0)
{
List<Model.Law_HSSEStandardsList> HSSEStandardsLists = new List<Model.Law_HSSEStandardsList>();
foreach (var item in getData)
{
var getHSSEStandardsList = db.Law_HSSEStandardsList.FirstOrDefault(x => x.StandardId == item.StandardId);
if (getHSSEStandardsList == null)
{
var type = db.Base_HSSEStandardListType.FirstOrDefault(e => e.TypeId == item.TypeId);
if (!string.IsNullOrEmpty(item.TypeId) && type == null)
{
Model.Base_HSSEStandardListType new_Type = new Model.Base_HSSEStandardListType
{
TypeId = item.TypeId,
TypeCode = item.TypeCode,
TypeName = item.TypeName
};
db.Base_HSSEStandardListType.InsertOnSubmit(new_Type);
db.SubmitChanges();
}
Model.Law_HSSEStandardsList newHSSEStandardsList = new Model.Law_HSSEStandardsList
{
StandardId = item.StandardId,
StandardGrade = item.StandardGrade,
StandardNo = item.StandardNo,
StandardName = item.StandardName,
TypeId = item.TypeId,
IsSelected1 = item.IsSelected1,
IsSelected2 = item.IsSelected2,
IsSelected3 = item.IsSelected3,
IsSelected4 = item.IsSelected4,
IsSelected5 = item.IsSelected5,
IsSelected6 = item.IsSelected6,
IsSelected7 = item.IsSelected7,
IsSelected8 = item.IsSelected8,
IsSelected9 = item.IsSelected9,
IsSelected10 = item.IsSelected10,
IsSelected11 = item.IsSelected11,
IsSelected12 = item.IsSelected12,
IsSelected13 = item.IsSelected13,
IsSelected14 = item.IsSelected14,
IsSelected15 = item.IsSelected15,
IsSelected16 = item.IsSelected16,
IsSelected17 = item.IsSelected17,
IsSelected18 = item.IsSelected18,
IsSelected19 = item.IsSelected19,
IsSelected20 = item.IsSelected20,
IsSelected21 = item.IsSelected21,
IsSelected22 = item.IsSelected22,
IsSelected23 = item.IsSelected23,
IsSelected24 = item.IsSelected24,
IsSelected25 = item.IsSelected25,
IsSelected90 = item.IsSelected90,
CompileMan = item.CompileMan,
CompileDate = item.CompileDate,
IsPass = true,
UnitId = item.UnitId,
IsBuild = true
};
HSSEStandardsLists.Add(newHSSEStandardsList);
////上传附件
BLL.FileInsertService.InsertAttachFile(item.AttachFileId, item.StandardId, item.AttachSource, item.AttachUrl, item.FileContext);
}
}
if (HSSEStandardsLists.Count() > 0)
{
db.Law_HSSEStandardsList.InsertAllOnSubmit(HSSEStandardsLists);
db.SubmitChanges();
}
responeData.message = "获取成功:记录" + HSSEStandardsLists.Count().ToString() + "条";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("标准规范从集团公司提取到企业!", ex);
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 安全生产规章制度从集团公司提取
/// </summary>
/// <returns></returns>
public static Model.ResponeData getLaw_RulesRegulations()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var getData = hsseC.GetLaw_RulesRegulationsToSUB();
if (getData.Count() > 0)
{
List<Model.Law_RulesRegulations> RulesRegulationsLists = new List<Model.Law_RulesRegulations>();
foreach (var item in getData)
{
var getRulesRegulationsList = db.Law_RulesRegulations.FirstOrDefault(x => x.RulesRegulationsId == item.RulesRegulationsId);
if (getRulesRegulationsList == null)
{
var type = db.Base_RulesRegulationsType.FirstOrDefault(e => e.RulesRegulationsTypeId == item.RulesRegulationsTypeId);
if (!string.IsNullOrEmpty(item.RulesRegulationsTypeId) && type == null)
{
Model.Base_RulesRegulationsType new_Type = new Model.Base_RulesRegulationsType
{
RulesRegulationsTypeId = item.RulesRegulationsTypeId,
RulesRegulationsTypeCode = item.RulesRegulationsTypeCode,
RulesRegulationsTypeName = item.RulesRegulationsTypeName
};
db.Base_RulesRegulationsType.InsertOnSubmit(new_Type);
db.SubmitChanges();
}
Model.Law_RulesRegulations newRulesRegulationsList = new Model.Law_RulesRegulations
{
RulesRegulationsId = item.RulesRegulationsId,
RulesRegulationsCode = item.RulesRegulationsCode,
RulesRegulationsName = item.RulesRegulationsName,
RulesRegulationsTypeId = item.RulesRegulationsTypeId,
CustomDate = item.CustomDate,
ApplicableScope = item.ApplicableScope,
Remark = item.Remark,
CompileMan = item.CompileMan,
CompileDate = item.CompileDate,
IsPass = true,
UnitId = item.UnitId,
IsBuild = true
};
RulesRegulationsLists.Add(newRulesRegulationsList);
////上传附件
BLL.FileInsertService.InsertAttachFile(item.AttachFileId, item.RulesRegulationsId, item.AttachSource, item.AttachUrl, item.FileContext);
}
}
if (RulesRegulationsLists.Count() > 0)
{
db.Law_RulesRegulations.InsertAllOnSubmit(RulesRegulationsLists);
db.SubmitChanges();
}
responeData.message = "获取成功:记录" + RulesRegulationsLists.Count().ToString() + "条";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("安全生产规章制度从集团公司提取!", ex);
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 安全管理规定从集团公司提取
/// </summary>
/// <returns></returns>
public static Model.ResponeData getLaw_ManageRule()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var getData = hsseC.GetLaw_ManageRuleToSUB();
if (getData.Count() > 0)
{
List<Model.Law_ManageRule> ManageRuleLists = new List<Model.Law_ManageRule>();
foreach (var item in getData)
{
var getManageRuleList = db.Law_ManageRule.FirstOrDefault(x => x.ManageRuleId == item.ManageRuleId);
if (getManageRuleList == null)
{
var type = db.Base_ManageRuleType.FirstOrDefault(e => e.ManageRuleTypeId == item.ManageRuleTypeId);
if (!string.IsNullOrEmpty(item.ManageRuleTypeId) && type == null)
{
Model.Base_ManageRuleType new_Type = new Model.Base_ManageRuleType
{
ManageRuleTypeId = item.ManageRuleTypeId,
ManageRuleTypeCode = item.ManageRuleTypeCode,
ManageRuleTypeName = item.ManageRuleTypeName
};
db.Base_ManageRuleType.InsertOnSubmit(new_Type);
db.SubmitChanges();
}
Model.Law_ManageRule newManageRuleList = new Model.Law_ManageRule
{
ManageRuleId = item.ManageRuleId,
ManageRuleCode = item.ManageRuleCode,
ManageRuleName = item.ManageRuleName,
ManageRuleTypeId = item.ManageRuleTypeId,
VersionNo = item.VersionNo,
CompileMan = item.CompileMan,
CompileDate = item.CompileDate,
Remark = item.Remark,
IsPass = true,
UnitId = item.UnitId,
IsBuild = true
};
ManageRuleLists.Add(newManageRuleList);
////上传附件
BLL.FileInsertService.InsertAttachFile(item.AttachFileId, item.ManageRuleId, item.AttachSource, item.AttachUrl, item.FileContext);
}
}
if (ManageRuleLists.Count() > 0)
{
db.Law_ManageRule.InsertAllOnSubmit(ManageRuleLists);
db.SubmitChanges();
}
responeData.message = "获取成功:记录" + ManageRuleLists.Count().ToString() + "条";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("安全管理规定从集团公司提取!", ex);
}
return responeData;
}
}
#endregion
#region HAZOP管理从集团公司提取
/// <summary>
/// HAZOP管理从集团公司提取
/// </summary>
/// <returns></returns>
public static Model.ResponeData getTechnique_HAZOP()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var getData = hsseC.GetTechnique_HAZOPToSUB();
if (getData.Count() > 0)
{
List<Model.Technique_HAZOP> ManageRuleLists = new List<Model.Technique_HAZOP>();
foreach (var item in getData)
{
var getHAZOP = db.Technique_HAZOP.FirstOrDefault(e => e.HAZOPId == item.HAZOPId); ;
if (getHAZOP == null)
{
Model.Technique_HAZOP newManageRuleList = new Model.Technique_HAZOP
{
HAZOPId = item.HAZOPId,
UnitId = item.UnitId,
Abstract = item.Abstract,
HAZOPDate = item.HAZOPDate,
HAZOPTitle = item.HAZOPTitle,
CompileMan = item.CompileMan,
CompileDate = item.CompileDate,
IsPass = true,
IsBuild = true
};
ManageRuleLists.Add(newManageRuleList);
////上传附件
BLL.FileInsertService.InsertAttachFile(item.AttachFileId, item.HAZOPId, item.AttachSource, item.AttachUrl, item.FileContext);
}
}
if (ManageRuleLists.Count() > 0)
{
db.Technique_HAZOP.InsertAllOnSubmit(ManageRuleLists);
db.SubmitChanges();
}
responeData.message = "获取成功:记录" + ManageRuleLists.Count().ToString() + "条";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("HAZOP管理从集团公司提取", ex);
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 管理评价从集团公司提取
/// </summary>
/// <returns></returns>
public static Model.ResponeData getTechnique_Appraise()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var getData = hsseC.GetTechnique_AppraiseToSUB();
if (getData.Count() > 0)
{
List<Model.Technique_Appraise> ManageRuleLists = new List<Model.Technique_Appraise>();
foreach (var item in getData)
{
var getAppraise = db.Technique_Appraise.FirstOrDefault(e => e.AppraiseId == item.AppraiseId); ;
if (getAppraise == null)
{
Model.Technique_Appraise newManageRuleList = new Model.Technique_Appraise
{
AppraiseId = item.AppraiseId,
AppraiseCode = item.AppraiseCode,
AppraiseTitle = item.AppraiseTitle,
Abstract = item.Abstract,
AppraiseDate = item.AppraiseDate,
ArrangementPerson = item.ArrangementPerson,
ArrangementDate = item.ArrangementDate,
CompileMan = item.CompileMan,
CompileDate = item.CompileDate,
UnitId = item.UnitId,
IsPass = true,
IsBuild = true
};
ManageRuleLists.Add(newManageRuleList);
////上传附件
BLL.FileInsertService.InsertAttachFile(item.AttachFileId, item.AppraiseId, item.AttachSource, item.AttachUrl, item.FileContext);
}
}
if (ManageRuleLists.Count() > 0)
{
db.Technique_Appraise.InsertAllOnSubmit(ManageRuleLists);
db.SubmitChanges();
}
responeData.message = "获取成功:记录" + ManageRuleLists.Count().ToString() + "条";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("管理评价从集团公司提取!", ex);
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 应急预案从集团公司提取
/// </summary>
/// <returns></returns>
public static Model.ResponeData getTechnique_Emergency()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var getData = hsseC.GetTechnique_EmergencyToSUB();
if (getData.Count() > 0)
{
List<Model.Technique_Emergency> EmergencyLists = new List<Model.Technique_Emergency>();
foreach (var item in getData)
{
var getEmergencyList = db.Technique_Emergency.FirstOrDefault(x => x.EmergencyId == item.EmergencyId);
if (getEmergencyList == null)
{
var type = db.Base_EmergencyType.FirstOrDefault(e => e.EmergencyTypeId == item.EmergencyTypeId);
if (!string.IsNullOrEmpty(item.EmergencyTypeId) && type == null)
{
Model.Base_EmergencyType new_Type = new Model.Base_EmergencyType
{
EmergencyTypeId = item.EmergencyTypeId,
EmergencyTypeCode = item.EmergencyTypeCode,
EmergencyTypeName = item.EmergencyTypeName
};
db.Base_EmergencyType.InsertOnSubmit(new_Type);
db.SubmitChanges();
}
Model.Technique_Emergency newEmergencyList = new Model.Technique_Emergency
{
EmergencyId = item.EmergencyId,
EmergencyTypeId = item.EmergencyTypeId,
EmergencyCode = item.EmergencyCode,
EmergencyName = item.EmergencyName,
Summary = item.Summary,
Remark = item.Remark,
CompileMan = item.CompileMan,
CompileDate = item.CompileDate,
IsPass = true,
UnitId = item.UnitId,
IsBuild = true
};
EmergencyLists.Add(newEmergencyList);
////上传附件
BLL.FileInsertService.InsertAttachFile(item.AttachFileId, item.EmergencyId, item.AttachSource, item.AttachUrl, item.FileContext);
}
}
if (EmergencyLists.Count() > 0)
{
db.Technique_Emergency.InsertAllOnSubmit(EmergencyLists);
db.SubmitChanges();
}
responeData.message = "获取成功:记录" + EmergencyLists.Count().ToString() + "条";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("应急预案从集团公司提取!", ex);
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 专项方案从集团公司提取
/// </summary>
/// <returns></returns>
public static Model.ResponeData getTechnique_SpecialScheme()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
var getData = hsseC.GetTechnique_SpecialSchemeToSUB();
if (getData.Count() > 0)
{
List<Model.Technique_SpecialScheme> SpecialSchemeLists = new List<Model.Technique_SpecialScheme>();
foreach (var item in getData)
{
var getSpecialSchemeList = db.Technique_SpecialScheme.FirstOrDefault(x => x.SpecialSchemeId == item.SpecialSchemeId);
if (getSpecialSchemeList == null)
{
var type = db.Base_SpecialSchemeType.FirstOrDefault(e => e.SpecialSchemeTypeId == item.SpecialSchemeTypeId);
if (!string.IsNullOrEmpty(item.SpecialSchemeTypeId) && type == null)
{
Model.Base_SpecialSchemeType new_Type = new Model.Base_SpecialSchemeType
{
SpecialSchemeTypeId = item.SpecialSchemeTypeId,
SpecialSchemeTypeCode = item.SpecialSchemeTypeCode,
SpecialSchemeTypeName = item.SpecialSchemeTypeName
};
db.Base_SpecialSchemeType.InsertOnSubmit(new_Type);
db.SubmitChanges();
}
Model.Technique_SpecialScheme newSpecialSchemeList = new Model.Technique_SpecialScheme
{
SpecialSchemeId = item.SpecialSchemeId,
SpecialSchemeTypeId = item.SpecialSchemeTypeId,
SpecialSchemeCode = item.SpecialSchemeCode,
SpecialSchemeName = item.SpecialSchemeName,
UnitId = item.UnitId,
CompileMan = item.CompileMan,
CompileDate = item.CompileDate,
Summary = item.Summary,
IsPass = true,
IsBuild = true
};
SpecialSchemeLists.Add(newSpecialSchemeList);
////上传附件
BLL.FileInsertService.InsertAttachFile(item.AttachFileId, item.SpecialSchemeId, item.AttachSource, item.AttachUrl, item.FileContext);
}
}
if (SpecialSchemeLists.Count() > 0)
{
db.Technique_SpecialScheme.InsertAllOnSubmit(SpecialSchemeLists);
db.SubmitChanges();
}
responeData.message = "获取成功:记录" + SpecialSchemeLists.Count().ToString() + "条";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("专项方案从集团公司提取!", ex);
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 培训教材库信息从集团公司提取
/// </summary>
/// <returns></returns>
public static Model.ResponeData getTraining_TrainingList()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
///获取教材类别
var getData = hsseC.GetTraining_TrainingListToSUB();
if (getData.Count() > 0)
{
List<Model.Training_Training> newLists = new List<Model.Training_Training>();
foreach (var item in getData)
{
var getTraining = db.Training_Training.FirstOrDefault(x => x.TrainingId == item.TrainingId);
if (getTraining == null)
{
Model.Training_Training newList = new Model.Training_Training
{
TrainingId = item.TrainingId,
TrainingCode = item.TrainingCode,
TrainingName = item.TrainingName,
SupTrainingId = item.SupTrainingId,
IsEndLever = item.IsEndLever,
IsBuild = true
};
newLists.Add(newList);
}
}
if (newLists.Count() > 0)
{
db.Training_Training.InsertAllOnSubmit(newLists);
db.SubmitChanges();
}
responeData.message = "获取成功:培训教材库类别" + newLists.Count().ToString() + "条";
}
///获取明细
var getDataItem = hsseC.GetTraining_TrainingItemListToSUB();
if (getDataItem.Count() > 0)
{
List<Model.Training_TrainingItem> newItemLists = new List<Model.Training_TrainingItem>();
foreach (var item in getDataItem)
{
var getItem = db.Training_TrainingItem.FirstOrDefault(x => x.TrainingId == item.TrainingId);
if (getItem == null)
{
Model.Training_TrainingItem newItemList = new Model.Training_TrainingItem
{
TrainingItemId = item.TrainingItemId,
TrainingId = item.TrainingId,
TrainingItemCode = item.TrainingItemCode,
TrainingItemName = item.TrainingItemName,
VersionNum = item.VersionNum,
ApproveState = item.ApproveState,
ResourcesFrom = item.ResourcesFrom,
CompileMan = item.CompileMan,
CompileDate = item.CompileDate,
ResourcesFromType = item.ResourcesFromType,
UnitId = item.UnitId,
IsPass = true,
AttachUrl = item.AttachUrl
};
newItemLists.Add(newItemList);
if (item.FileContext != null)
{ ////上传附件
BLL.FileInsertService.InsertAttachFile(item.AttachFileId, item.TrainingItemId, item.AttachSource, item.AttachUrl, item.FileContext);
}
}
}
if (newItemLists.Count() > 0)
{
db.Training_TrainingItem.InsertAllOnSubmit(newItemLists);
db.SubmitChanges();
}
responeData.message += ";明细" + newItemLists.Count().ToString() + "条";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("培训教材" +
"库信息从集团公司提取!", ex);
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 安全试题库信息从集团公司提取
/// </summary>
/// <returns></returns>
public static Model.ResponeData getTraining_TrainTestDBList()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
///获取类别
var getData = hsseC.GetTraining_TrainTestDBListToSUB();
if (getData.Count() > 0)
{
List<Model.Training_TrainTestDB> newLists = new List<Model.Training_TrainTestDB>();
foreach (var item in getData)
{
var getTrainTestDB = db.Training_TrainTestDB.FirstOrDefault(x => x.TrainTestId == item.TrainTestId);
if (getTrainTestDB == null)
{
Model.Training_TrainTestDB newList = new Model.Training_TrainTestDB
{
TrainTestId = item.TrainTestId,
TrainTestCode = item.TrainTestCode,
TrainTestName = item.TrainTestName,
SupTrainTestId = item.SupTrainTestId,
IsEndLever = item.IsEndLever,
IsBuild = true
};
newLists.Add(newList);
}
}
if (newLists.Count() > 0)
{
db.Training_TrainTestDB.InsertAllOnSubmit(newLists);
db.SubmitChanges();
}
responeData.message = "获取成功:安全试题类别" + newLists.Count().ToString() + "条";
}
///获取明细
var getDataItem = hsseC.GetTraining_TrainTestDBItemListToSUB();
if (getDataItem.Count() > 0)
{
List<Model.Training_TrainTestDBItem> newItemLists = new List<Model.Training_TrainTestDBItem>();
foreach (var item in getDataItem)
{
var getItem = db.Training_TrainTestDBItem.FirstOrDefault(x => x.TrainTestItemId == item.TrainTestItemId);
if (getItem == null)
{
Model.Training_TrainTestDBItem newItemList = new Model.Training_TrainTestDBItem
{
TrainTestItemId = item.TrainTestItemId,
TrainTestId = item.TrainTestId,
TrainTestItemCode = item.TrainTestItemCode,
TraiinTestItemName = item.TraiinTestItemName,
CompileMan = item.CompileMan,
CompileDate = item.CompileDate,
UnitId = item.UnitId,
IsPass = true
};
newItemLists.Add(newItemList);
if (item.FileContext != null)
{ ////上传附件
BLL.FileInsertService.InsertAttachFile(item.AttachFileId, item.TrainTestId, item.AttachSource, item.AttachUrl, item.FileContext);
}
}
}
if (newItemLists.Count() > 0)
{
db.Training_TrainTestDBItem.InsertAllOnSubmit(newItemLists);
db.SubmitChanges();
}
responeData.message += ";明细" + newItemLists.Count().ToString() + "条";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("安全试题库信息从集团公司提取!", ex);
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 事故案例库信息从集团公司提取
/// </summary>
/// <returns></returns>
public static Model.ResponeData getEduTrain_AccidentCaseList()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
///获取类别
var getData = hsseC.GetEduTrain_AccidentCaseListToSUB();
if (getData.Count() > 0)
{
List<Model.EduTrain_AccidentCase> newLists = new List<Model.EduTrain_AccidentCase>();
foreach (var item in getData)
{
var getAccidentCase = db.EduTrain_AccidentCase.FirstOrDefault(x => x.AccidentCaseId == item.AccidentCaseId);
if (getAccidentCase == null)
{
Model.EduTrain_AccidentCase newList = new Model.EduTrain_AccidentCase
{
AccidentCaseId = item.AccidentCaseId,
AccidentCaseCode = item.AccidentCaseCode,
AccidentCaseName = item.AccidentCaseName,
SupAccidentCaseId = item.SupAccidentCaseId,
IsEndLever = item.IsEndLever,
IsBuild = true
};
newLists.Add(newList);
}
}
if (newLists.Count() > 0)
{
db.EduTrain_AccidentCase.InsertAllOnSubmit(newLists);
db.SubmitChanges();
}
responeData.message = "获取成功:事故案例类别" + newLists.Count().ToString() + "条";
}
///获取明细
var getDataItem = hsseC.GetEduTrain_AccidentCaseItemListToSUB();
if (getDataItem.Count() > 0)
{
List<Model.EduTrain_AccidentCaseItem> newItemLists = new List<Model.EduTrain_AccidentCaseItem>();
foreach (var item in getDataItem)
{
var getItem = db.EduTrain_AccidentCaseItem.FirstOrDefault(x => x.AccidentCaseItemId == item.AccidentCaseItemId);
if (getItem == null)
{
Model.EduTrain_AccidentCaseItem newItemList = new Model.EduTrain_AccidentCaseItem
{
AccidentCaseItemId = item.AccidentCaseItemId,
AccidentCaseId = item.AccidentCaseId,
Activities = item.Activities,
AccidentName = item.AccidentName,
AccidentProfiles = item.AccidentProfiles,
AccidentReview = item.AccidentReview,
CompileMan = item.CompileMan,
CompileDate = item.CompileDate,
UnitId = item.UnitId,
IsPass = true
};
newItemLists.Add(newItemList);
}
}
if (newItemLists.Count() > 0)
{
db.EduTrain_AccidentCaseItem.InsertAllOnSubmit(newItemLists);
db.SubmitChanges();
}
responeData.message += ";明细" + newItemLists.Count().ToString() + "条";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("事故案例库信息从集团公司提取!", ex);
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 危险源清单从集团公司提取
/// </summary>
/// <returns></returns>
public static Model.ResponeData getTechnique_HazardList()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
///获取类别
var getData = hsseC.GetTechnique_HazardListTypeListToSUB();
if (getData.Count() > 0)
{
List<Model.Technique_HazardListType> newLists = new List<Model.Technique_HazardListType>();
foreach (var item in getData)
{
var getHType = db.Technique_HazardListType.FirstOrDefault(e => e.HazardListTypeId == item.HazardListTypeId);
if (getHType == null)
{
Model.Technique_HazardListType newList = new Model.Technique_HazardListType
{
HazardListTypeId = item.HazardListTypeId,
HazardListTypeCode = item.HazardListTypeCode,
HazardListTypeName = item.HazardListTypeName,
SupHazardListTypeId = item.SupHazardListTypeId,
IsEndLevel = item.IsEndLevel,
IsBuild = true
};
newLists.Add(newList);
}
}
if (newLists.Count() > 0)
{
db.Technique_HazardListType.InsertAllOnSubmit(newLists);
db.SubmitChanges();
}
responeData.message = "获取成功:类别" + newLists.Count().ToString() + "条";
}
///获取明细
var getDataItem = hsseC.GetTechnique_HazardListListToSUB();
if (getDataItem.Count() > 0)
{
List<Model.Technique_HazardList> newItemLists = new List<Model.Technique_HazardList>();
foreach (var item in getDataItem)
{
var getItem = db.Technique_HazardList.FirstOrDefault(x => x.HazardId == item.HazardId);
if (getItem == null)
{
Model.Technique_HazardList newItemList = new Model.Technique_HazardList
{
HazardId = item.HazardId,
HazardListTypeId = item.HazardListTypeId,
HazardCode = item.HazardCode,
HazardItems = item.HazardItems,
DefectsType = item.DefectsType,
MayLeadAccidents = item.MayLeadAccidents,
HelperMethod = item.HelperMethod,
HazardJudge_L = item.HazardJudge_L,
HazardJudge_E = item.HazardJudge_E,
HazardJudge_C = item.HazardJudge_C,
HazardJudge_D = item.HazardJudge_D,
HazardLevel = item.HazardLevel,
ControlMeasures = item.ControlMeasures,
CompileMan = item.CompileMan,
CompileDate = item.CompileDate,
UnitId = item.UnitId,
IsPass = true
};
newItemLists.Add(newItemList);
}
}
if (newItemLists.Count() > 0)
{
db.Technique_HazardList.InsertAllOnSubmit(newItemLists);
db.SubmitChanges();
}
responeData.message += ";明细" + newItemLists.Count().ToString() + "条";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("危险源清单从集团公司提取!", ex);
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 安全隐患从集团公司提取
/// </summary>
/// <returns></returns>
public static Model.ResponeData getTechnique_RectifyList()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
CNCECHSSEService.HSSEServiceClient hsseC = new CNCECHSSEService.HSSEServiceClient();
///获取类别
var getData = hsseC.GetTechnique_RectifyListToSUB();
if (getData.Count() > 0)
{
List<Model.Technique_Rectify> newLists = new List<Model.Technique_Rectify>();
foreach (var item in getData)
{
var getAccidentCase = db.Technique_Rectify.FirstOrDefault(x => x.RectifyId == item.RectifyId);
if (getAccidentCase == null)
{
Model.Technique_Rectify newList = new Model.Technique_Rectify
{
RectifyId = item.RectifyId,
RectifyCode = item.RectifyCode,
RectifyName = item.RectifyName,
SupRectifyId = item.SupRectifyId,
IsEndLever = item.IsEndLever,
IsBuild = true
};
newLists.Add(newList);
}
}
if (newLists.Count() > 0)
{
db.Technique_Rectify.InsertAllOnSubmit(newLists);
db.SubmitChanges();
}
responeData.message = "获取成功:安全隐患类别" + newLists.Count().ToString() + "条";
}
///获取明细
var getDataItem = hsseC.GetTechnique_RectifyItemListToSUB();
if (getDataItem.Count() > 0)
{
List<Model.Technique_RectifyItem> newItemLists = new List<Model.Technique_RectifyItem>();
foreach (var item in getDataItem)
{
var getItem = db.Technique_RectifyItem.FirstOrDefault(x => x.RectifyItemId == item.RectifyItemId);
if (getItem == null)
{
Model.Technique_RectifyItem newItemList = new Model.Technique_RectifyItem
{
RectifyItemId = item.RectifyItemId,
RectifyId = item.RectifyId,
HazardSourcePoint = item.HazardSourcePoint,
RiskAnalysis = item.RiskAnalysis,
RiskPrevention = item.RiskPrevention,
SimilarRisk = item.SimilarRisk,
CompileMan = item.CompileMan,
CompileDate = item.CompileDate,
UnitId = item.UnitId,
IsPass = true
};
newItemLists.Add(newItemList);
}
}
if (newItemLists.Count() > 0)
{
db.Technique_RectifyItem.InsertAllOnSubmit(newItemLists);
db.SubmitChanges();
}
responeData.message += ";明细" + newItemLists.Count().ToString() + "条";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("安全隐患从集团公司提取!", ex);
}
return responeData;
}
}
#endregion
#endregion
#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
#region
/// <summary>
/// 推送项目到集团
/// </summary>
/// <returns></returns>
public static string PushProject()
{
string code = "0";
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
try
{
//查询所有在建项目
var upReport = (from x in db.Base_Project
where (x.ProjectState == "1" || x.ProjectState == null) && (x.IsDelete == null || x.IsDelete == false)
select new Model.BaseProjectItem
{
ProjectId = x.ProjectId,
MasterSysId = x.MasterSysId,
UnitId = CommonService.GetThisUnitId(),
ProjectCode = x.ProjectCode,
ProjectName = x.ProjectName,
StartDate = x.StartDate,
EndDate = x.EndDate,
ProjectAddress = x.ProjectAddress,
ShortName = x.ShortName,
ProjectType = x.ProjectType,
PostCode = x.PostCode,
Remark = x.Remark,
ProjectState = x.ProjectState,
ContractNo = x.ContractNo,
WorkRange = x.WorkRange,
Duration = x.Duration,
IsUpTotalMonth = x.IsUpTotalMonth,
ProjectMainPerson = x.ProjectMainPerson,
ProjectLiaisonPerson = x.ProjectLiaisonPerson,
IsForeign = x.IsForeign,
FromProjectId = x.FromProjectId,
MapCoordinates = x.MapCoordinates,
ProjectMoney = x.ProjectMoney,
ConstructionMoney = x.ConstructionMoney,
Country = x.Country,
Province = x.Province,
City = x.City,
Telephone = x.Telephone,
EnglishRemark = x.EnglishRemark,
IsFace = x.IsFace,
ProjectState2 = x.ProjectState2,
Progress = x.Progress,
MonitorPW = x.MonitorPW,
MonitorId = x.MonitorId,
ProjectAttribute = x.ProjectAttribute,
SourceUnitId = CommonService.GetThisUnitId(),
}
);
code = PushApiProject(upReport).ToString();
if (code == "1")
{
}
}
catch (Exception ex)
{
ErrLogInfo.WriteLog("【在建项目】上传到服务器", ex);
}
return code;
}
}
/// <summary>
/// 推送项目
/// </summary>
/// <param name="upReport"></param>
/// <returns></returns>
private static int PushApiProject(IQueryable<Model.BaseProjectItem> upReport)
{
string baseurl = "/api/InspectionBrigade/SaveBaseProjectData";
var resultJsonReport = JsonConvert.SerializeObject(upReport);
resultJsonReport = "{\"BaseProjectItems\":" + resultJsonReport.Replace("}{", ",") + "}";
var responeData = BLL.ServerService.PushCNCEC(resultJsonReport, baseurl);
return responeData.code;
}
#endregion
#region
public static int PushInspectionBrigadeUser()
{
string baseurl = "/api/InspectionBrigade/SaveInspectionBrigadeUser";
var CollCropCode = BLL.CommonService.GetIsThisUnit()?.CollCropCode;
var userList = from x in Funs.DB.Sys_User
where x.IsInspectionBrigade == true
select new Model.InspectionBrigadeUserItem()
{
UserId = x.UserId,
UserName = x.UserName,
Sex = x.Sex,
Account = x.Account,
Password = x.Password,
IdentityCard = x.IdentityCard,
Telephone = x.Telephone,
CollCropCode = CollCropCode
};
var resultJsonReport = JsonConvert.SerializeObject(userList.ToList());
resultJsonReport = "{\"InspectionBrigadeUserItems\":" + resultJsonReport.Replace("}{", ",") + "}";
var responeData = BLL.ServerService.PushCNCEC(resultJsonReport, baseurl);
return responeData.code;
}
#endregion
}
}