SGGL_JT/SUBQHSE/WebAPI/Controllers/Customization/7HJ/7HJ_ReportController.cs

2467 lines
151 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

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

using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web.Http;
using Aspose.Words.Lists;
using BLL;
using Model.Customization._7HJ;
using System;
using System.Collections;
using System.Globalization;
using Model;
using System.Web;
namespace WebAPI.Controllers._7HJ
{
/// <summary>
/// 七华建数报表接口
/// </summary>
public class Api_7HJ_ReportController : ApiController
{
#region
/// <summary>
/// 获取企业安全数据统计月报列表
/// </summary>
/// <param name="UnitId"> </param>
/// <returns></returns>
public Model.ResponeData getMonthlyReportList(string UnitId, int? Year, int? Month)
{
{
var responeData = new Model.ResponeData();
try
{
List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
IQueryable<Model.View_Information_MillionsMonthlyReport> query =
Funs.DB.View_Information_MillionsMonthlyReport
.Where(e => e.UnitId == UnitId);
if (Month.HasValue)
{
query = query.Where(e => e.Month == Month);
}
if (Year.HasValue)
{
query = query.Where(e => e.Year == Year);
}
List<Model.View_Information_MillionsMonthlyReport> reports = query.ToList();
if (reports.Count > 0)
{
reports.ForEach(report =>
{
Dictionary<string, object> data = new Dictionary<string, object>();
string upState = string.Empty;
if (report.UpState == BLL.Const.UpState_3)
{
upState = "(已上报)";
}
else
{
upState = "(未上报)";
}
data.Add("Year", report.Year);
data.Add("Month", report.Month);
data.Add("Title", "企业企业安全数据统计月报" + report.MonthStr + report.YearStr + upState);
data.Add("UnitName", "填报企业:" + report.UnitName);
if (report.FillingDate != null)
{
data.Add("FillingDate", "填报日期:" + string.Format("{0:yyyy-MM-dd}", report.FillingDate));
}
else
{
data.Add("FillingDate", "填报日期:");
}
data.Add("DutyPerson", "负责人:" + report.DutyPerson);
if (report.HandleState == BLL.Const.HandleState_1 || report.UpState == BLL.Const.UpState_3)
{
// this.lbHandleMan.Hidden = true;
}
else
{
// this.lbHandleMan.Hidden = false;
data.Add("HandleMan", "下一步办理人:" + report.UserName);
}
data.Add("RecordableIncidentRate",
"百万工时总可记录事件率:" + (report.RecordableIncidentRate ?? 0).ToString());
data.Add("LostTimeRate", "百万工时损失工时率:" + (report.LostTimeRate ?? 0).ToString());
data.Add("LostTimeInjuryRate",
"百万工时损失工时伤害事故率:" + (report.LostTimeInjuryRate ?? 0).ToString());
data.Add("DeathAccidentFrequency",
"百万工时死亡事故频率:" + (report.DeathAccidentFrequency ?? 0).ToString());
data.Add("AccidentMortality", "百万工时事故死亡率:" + (report.AccidentMortality ?? 0).ToString());
// List<Model.Information_MillionsMonthlyReportItem> items = BLL.MillionsMonthlyReportItemService.GetItems(report.MillionsMonthlyReportId);
List<Model.Customization._7HJ.MillionsMonthlyReportItem> items =
(from x in Funs.DB.Information_MillionsMonthlyReportItem
where x.MillionsMonthlyReportId == report.MillionsMonthlyReportId
orderby x.SortIndex
select new Model.Customization._7HJ.MillionsMonthlyReportItem
{
MillionsMonthlyReportItemId = x.MillionsMonthlyReportItemId,
Affiliation = x.Affiliation,
Name = x.Name,
PostPersonNum = x.PostPersonNum ?? 0,
SnapPersonNum = x.SnapPersonNum ?? 0,
ContractorNum = x.ContractorNum ?? 0,
SumPersonNum = x.SumPersonNum ?? 0,
TotalWorkNum = x.TotalWorkNum ?? 0,
SeriousInjuriesNum = x.SeriousInjuriesNum ?? 0,
SeriousInjuriesPersonNum = x.SeriousInjuriesPersonNum ?? 0,
SeriousInjuriesLossHour = x.SeriousInjuriesLossHour ?? 0,
MinorAccidentNum = x.MinorAccidentNum ?? 0,
MinorAccidentPersonNum = x.MinorAccidentPersonNum ?? 0,
MinorAccidentLossHour = x.MinorAccidentLossHour ?? 0,
DeathAccidentNum = x.DeathAccidentNum ?? 0,
DeathAccidentPersonNum = x.DeathAccidentPersonNum ?? 0,
DeathAccidentLossHour = x.DeathAccidentLossHour ?? 0,
RestrictedWorkPersonNum = x.RestrictedWorkPersonNum ?? 0,
RestrictedWorkLossHour = x.RestrictedWorkLossHour ?? 0,
MedicalTreatmentPersonNum = x.MedicalTreatmentPersonNum ?? 0,
MedicalTreatmentLossHour = x.MedicalTreatmentLossHour ?? 0,
FireNum = x.FireNum ?? 0,
EnvironmenNum = x.EnvironmenNum ?? 0,
TrafficNum = x.TrafficNum ?? 0,
EquipmentNum = x.EquipmentNum ?? 0,
QualityNum = x.QualityNum ?? 0,
OtherNum = x.OtherNum ?? 0,
FirstAidDressingsNum = x.FirstAidDressingsNum ?? 0,
AttemptedEventNum = x.AttemptedEventNum ?? 0,
LossDayNum = x.LossDayNum ?? 0,
}).ToList();
//本年度累计行
// Model.Information_MillionsMonthlyReportItem yearTotalItem = new Model.Information_MillionsMonthlyReportItem();
Model.Customization._7HJ.MillionsMonthlyReportItem yearTotalItem =
new Model.Customization._7HJ.MillionsMonthlyReportItem();
//之前月度合计值集合
List<Model.Information_MillionsMonthlyReportItem> yearSumItems =
BLL.MillionsMonthlyReportItemService.GetYearSumItems(report.UnitId, report.Year,
report.Month);
yearTotalItem.MillionsMonthlyReportItemId =
SQLHelper.GetNewID(typeof(Model.Information_MillionsMonthlyReportItem));
yearTotalItem.MillionsMonthlyReportId = report.MillionsMonthlyReportId;
yearTotalItem.SortIndex = (items.Count + 1) * 10;
yearTotalItem.Affiliation = "本年度累计";
yearTotalItem.Name = "本年度累计";
yearTotalItem.PostPersonNum = yearSumItems.Sum(x => x.PostPersonNum ?? 0);
yearTotalItem.SnapPersonNum = yearSumItems.Sum(x => x.SnapPersonNum ?? 0);
yearTotalItem.ContractorNum = yearSumItems.Sum(x => x.ContractorNum ?? 0);
yearTotalItem.SumPersonNum = yearSumItems.Sum(x => x.SumPersonNum ?? 0);
yearTotalItem.TotalWorkNum = yearSumItems.Sum(x => x.TotalWorkNum ?? 0);
yearTotalItem.SeriousInjuriesNum = yearSumItems.Sum(x => x.SeriousInjuriesNum ?? 0);
yearTotalItem.SeriousInjuriesPersonNum =
yearSumItems.Sum(x => x.SeriousInjuriesPersonNum ?? 0);
yearTotalItem.SeriousInjuriesLossHour =
yearSumItems.Sum(x => x.SeriousInjuriesLossHour ?? 0);
yearTotalItem.MinorAccidentNum = yearSumItems.Sum(x => x.MinorAccidentNum ?? 0);
yearTotalItem.MinorAccidentPersonNum = yearSumItems.Sum(x => x.MinorAccidentPersonNum ?? 0);
yearTotalItem.MinorAccidentLossHour = yearSumItems.Sum(x => x.MinorAccidentLossHour ?? 0);
yearTotalItem.DeathAccidentNum = yearSumItems.Sum(x => x.DeathAccidentNum ?? 0);
yearTotalItem.DeathAccidentPersonNum = yearSumItems.Sum(x => x.DeathAccidentPersonNum ?? 0);
yearTotalItem.DeathAccidentLossHour = yearSumItems.Sum(x => x.DeathAccidentLossHour ?? 0);
yearTotalItem.RestrictedWorkPersonNum =
yearSumItems.Sum(x => x.RestrictedWorkPersonNum ?? 0);
yearTotalItem.RestrictedWorkLossHour = yearSumItems.Sum(x => x.RestrictedWorkLossHour ?? 0);
yearTotalItem.MedicalTreatmentPersonNum =
yearSumItems.Sum(x => x.MedicalTreatmentPersonNum ?? 0);
yearTotalItem.MedicalTreatmentLossHour =
yearSumItems.Sum(x => x.MedicalTreatmentLossHour ?? 0);
yearTotalItem.FireNum = yearSumItems.Sum(x => x.FireNum ?? 0);
yearTotalItem.EnvironmenNum = yearSumItems.Sum(x => x.EnvironmenNum ?? 0);
yearTotalItem.TrafficNum = yearSumItems.Sum(x => x.TrafficNum ?? 0);
yearTotalItem.EquipmentNum = yearSumItems.Sum(x => x.EquipmentNum ?? 0);
yearTotalItem.QualityNum = yearSumItems.Sum(x => x.QualityNum ?? 0);
yearTotalItem.OtherNum = yearSumItems.Sum(x => x.OtherNum ?? 0);
yearTotalItem.FirstAidDressingsNum = yearSumItems.Sum(x => x.FirstAidDressingsNum ?? 0);
yearTotalItem.AttemptedEventNum = yearSumItems.Sum(x => x.AttemptedEventNum ?? 0);
yearTotalItem.LossDayNum = yearSumItems.Sum(x => x.LossDayNum ?? 0);
items.Add(yearTotalItem);
data.Add("items", items);
List<Model.Customization._7HJ.MillionsMonthlyReport> report2 =
(from x in Funs.DB.Information_MillionsMonthlyReport
where x.MillionsMonthlyReportId == report.MillionsMonthlyReportId
select new Model.Customization._7HJ.MillionsMonthlyReport
{
MillionsMonthlyReportId = x.MillionsMonthlyReportId,
InputCosts = x.InputCosts,
TrainNum = x.TrainNum ?? 0,
GeneralHazardNum = x.GeneralHazardNum ?? 0,
MajorHazardNum = x.MajorHazardNum ?? 0,
NotProofLargeProjectNum = x.NotProofLargeProjectNum ?? 0,
ProofLargeProjectNum = x.ProofLargeProjectNum ?? 0,
FireLicenseNum = x.FireLicenseNum ?? 0,
LimitLicenseNum = x.LimitLicenseNum ?? 0,
HighLicenseNum = x.HighLicenseNum ?? 0,
HoistingLicenseNum = x.HoistingLicenseNum ?? 0,
BreakGroundLicenseNum = x.BreakGroundLicenseNum ?? 0,
ElectricityLicenseNum = x.ElectricityLicenseNum ?? 0,
RTLicenseNum = x.RTLicenseNum ?? 0,
NightLicenseNum = x.NightLicenseNum ?? 0,
CommissionerNum = x.CommissionerNum ?? 0,
SoleDutyNum = x.SoleDutyNum ?? 0,
}).ToList();
data.Add("items2", report2);
list.Add(data);
});
}
responeData.data = new { list };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
/// <summary>
/// 新增安全数据统计月报
/// </summary>
/// <param name="items"> </param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData SaveMillionsMonthlyReport([FromBody] Model.Customization._7HJ.InformationData items)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
string message = string.Empty;
foreach (var newItem in items.InformationDataItems)
{
if (!string.IsNullOrEmpty(newItem.UnitId) || !string.IsNullOrEmpty(newItem.CollCropCode))
{
string unitId = string.Empty;
string unitName = string.Empty;
var unit = db.Base_Unit.FirstOrDefault(x => x.CollCropCode == newItem.CollCropCode);
if (unit != null)
{
unitId = unit.UnitId;
unitName = unit.UnitName;
}
else
{
var unit2 = db.Base_Unit.FirstOrDefault(x => x.UnitId == newItem.UnitId);
if (unit2 != null)
{
unitId = unit2.UnitId;
unitName = unit2.UnitName;
}
}
if (!string.IsNullOrEmpty(unitId))
{
DateTime? date = Funs.GetNewDateTime(newItem.FillingDate);
if (date != null)
{
Model.Information_MillionsMonthlyReport millionsMonthlyReport =
new Model.Information_MillionsMonthlyReport
{
Year = newItem.Year,
Month = newItem.Month,
UnitId = newItem.UnitId,
FillingDate = date,
DutyPerson = newItem.DutyPerson,
RecordableIncidentRate = Convert.ToDecimal(newItem.RecordableIncidentRate),
LostTimeRate = Convert.ToDecimal(newItem.LostTimeRate),
LostTimeInjuryRate = Convert.ToDecimal(newItem.LostTimeInjuryRate),
DeathAccidentFrequency = Convert.ToDecimal(newItem.DeathAccidentFrequency),
AccidentMortality = Convert.ToDecimal(newItem.AccidentMortality),
InputCosts = Convert.ToDecimal(newItem.InputCosts),
TrainNum = newItem.TrainNum,
GeneralHazardNum = newItem.GeneralHazardNum,
MajorHazardNum = newItem.MajorHazardNum,
NotProofLargeProjectNum = newItem.NotProofLargeProjectNum,
ProofLargeProjectNum = newItem.ProofLargeProjectNum,
FireLicenseNum = newItem.FireLicenseNum,
LimitLicenseNum = newItem.LimitLicenseNum,
HighLicenseNum = newItem.HighLicenseNum,
HoistingLicenseNum = newItem.HoistingLicenseNum,
BreakGroundLicenseNum = newItem.BreakGroundLicenseNum,
ElectricityLicenseNum = newItem.ElectricityLicenseNum,
RTLicenseNum = newItem.RTLicenseNum,
NightLicenseNum = newItem.NightLicenseNum,
CommissionerNum = newItem.CommissionerNum,
SoleDutyNum = newItem.SoleDutyNum,
FillingMan = newItem.FillingMan,
// ReceiveDate = DateTime.Now
};
var millionsMonthlyReportId = newItem.MillionsMonthlyReportId ?? "";
var oldmillionsMonthlyReport =
db.Information_MillionsMonthlyReport.FirstOrDefault(x =>
x.UnitId == millionsMonthlyReport.UnitId &&
x.Year == millionsMonthlyReport.Year &&
x.Month == millionsMonthlyReport.Month);
if (oldmillionsMonthlyReport == null)
{
millionsMonthlyReport.MillionsMonthlyReportId = SQLHelper.GetNewID();
db.Information_MillionsMonthlyReport.InsertOnSubmit(millionsMonthlyReport);
millionsMonthlyReportId = millionsMonthlyReport.MillionsMonthlyReportId;
}
else
{
oldmillionsMonthlyReport.FillingDate = millionsMonthlyReport.FillingDate;
oldmillionsMonthlyReport.DutyPerson = millionsMonthlyReport.DutyPerson;
oldmillionsMonthlyReport.RecordableIncidentRate =
millionsMonthlyReport.RecordableIncidentRate;
oldmillionsMonthlyReport.LostTimeRate = millionsMonthlyReport.LostTimeRate;
oldmillionsMonthlyReport.LostTimeInjuryRate =
millionsMonthlyReport.LostTimeInjuryRate;
oldmillionsMonthlyReport.DeathAccidentFrequency =
millionsMonthlyReport.DeathAccidentFrequency;
oldmillionsMonthlyReport.AccidentMortality =
millionsMonthlyReport.AccidentMortality;
oldmillionsMonthlyReport.InputCosts = millionsMonthlyReport.InputCosts;
oldmillionsMonthlyReport.TrainNum = millionsMonthlyReport.TrainNum;
oldmillionsMonthlyReport.GeneralHazardNum =
millionsMonthlyReport.GeneralHazardNum;
oldmillionsMonthlyReport.MajorHazardNum = millionsMonthlyReport.MajorHazardNum;
oldmillionsMonthlyReport.NotProofLargeProjectNum =
millionsMonthlyReport.NotProofLargeProjectNum;
oldmillionsMonthlyReport.ProofLargeProjectNum =
millionsMonthlyReport.ProofLargeProjectNum;
oldmillionsMonthlyReport.FireLicenseNum = millionsMonthlyReport.FireLicenseNum;
oldmillionsMonthlyReport.LimitLicenseNum =
millionsMonthlyReport.LimitLicenseNum;
oldmillionsMonthlyReport.HighLicenseNum = millionsMonthlyReport.HighLicenseNum;
oldmillionsMonthlyReport.HoistingLicenseNum =
millionsMonthlyReport.HoistingLicenseNum;
oldmillionsMonthlyReport.BreakGroundLicenseNum =
millionsMonthlyReport.BreakGroundLicenseNum;
oldmillionsMonthlyReport.ElectricityLicenseNum =
millionsMonthlyReport.ElectricityLicenseNum;
oldmillionsMonthlyReport.RTLicenseNum = millionsMonthlyReport.RTLicenseNum;
oldmillionsMonthlyReport.NightLicenseNum =
millionsMonthlyReport.NightLicenseNum;
oldmillionsMonthlyReport.CommissionerNum =
millionsMonthlyReport.CommissionerNum;
oldmillionsMonthlyReport.SoleDutyNum = millionsMonthlyReport.SoleDutyNum;
oldmillionsMonthlyReport.FillingMan = millionsMonthlyReport.FillingMan;
// oldmillionsMonthlyReport.ReceiveDate = DateTime.Now;
millionsMonthlyReportId = oldmillionsMonthlyReport.MillionsMonthlyReportId;
var q = from x in db.Information_MillionsMonthlyReportItem
where x.MillionsMonthlyReportId ==
oldmillionsMonthlyReport.MillionsMonthlyReportId
select x;
if (q.Count() > 0)
{
db.Information_MillionsMonthlyReportItem.DeleteAllOnSubmit(q);
db.SubmitChanges();
}
}
var millionsMonthlyReportIdH = newItem.MillionsMonthlyReportId ?? "";
// millionsMonthlyReportHistory.MillionsMonthlyReportId = SQLHelper.GetNewID();
// db.Information_MillionsMonthlyReportHistory.InsertOnSubmit(millionsMonthlyReportHistory);
// millionsMonthlyReportIdH = millionsMonthlyReportHistory.MillionsMonthlyReportId;
//保存子项
List<Model.Information_MillionsMonthlyReportItem> ReportItemList =
new List<Model.Information_MillionsMonthlyReportItem>();
foreach (var item in newItem.MillionsMonthlyReportItem)
{
Model.Information_MillionsMonthlyReportItem ReportItem =
new Model.Information_MillionsMonthlyReportItem();
ReportItem.MillionsMonthlyReportId = millionsMonthlyReportId;
ReportItem.MillionsMonthlyReportItemId = SQLHelper.GetNewID();
ReportItem.Affiliation = item.Affiliation;
ReportItem.Name = item.Name;
ReportItem.PostPersonNum = item.PostPersonNum;
ReportItem.SnapPersonNum = item.SnapPersonNum;
ReportItem.ContractorNum = item.ContractorNum;
ReportItem.SumPersonNum = item.SumPersonNum;
ReportItem.TotalWorkNum = item.TotalWorkNum;
ReportItem.SeriousInjuriesNum = item.SeriousInjuriesNum;
ReportItem.SeriousInjuriesPersonNum = item.SeriousInjuriesPersonNum;
ReportItem.SeriousInjuriesLossHour = item.SeriousInjuriesLossHour;
ReportItem.MinorAccidentNum = item.MinorAccidentNum;
ReportItem.MinorAccidentPersonNum = item.MinorAccidentPersonNum;
ReportItem.MinorAccidentLossHour = item.MinorAccidentLossHour;
ReportItem.DeathAccidentNum = item.OtherAccidentNum;
ReportItem.DeathAccidentPersonNum = item.OtherAccidentPersonNum;
ReportItem.DeathAccidentLossHour = item.OtherAccidentLossHour;
ReportItem.RestrictedWorkPersonNum = item.RestrictedWorkPersonNum;
ReportItem.RestrictedWorkLossHour = item.RestrictedWorkLossHour;
ReportItem.MedicalTreatmentPersonNum = item.MedicalTreatmentPersonNum;
ReportItem.MedicalTreatmentLossHour = item.MedicalTreatmentLossHour;
ReportItem.FireNum = item.FireNum;
ReportItem.EnvironmenNum = item.ExplosionNum;
ReportItem.TrafficNum = item.TrafficNum;
ReportItem.EquipmentNum = item.EquipmentNum;
ReportItem.QualityNum = item.QualityNum;
ReportItem.OtherNum = item.OtherNum;
ReportItem.FirstAidDressingsNum = item.FirstAidDressingsNum;
ReportItem.AttemptedEventNum = item.AttemptedEventNum;
ReportItem.LossDayNum = item.LossDayNum;
ReportItem.SortIndex = item.SortIndex;
ReportItemList.Add(ReportItem);
}
if (ReportItemList.Count > 0)
db.Information_MillionsMonthlyReportItem.InsertAllOnSubmit(ReportItemList);
// if (ReportItemListHistory.Count > 0)
// db.Information_MillionsMonthlyReportHistoryItem.InsertAllOnSubmit(
// ReportItemListHistory);
db.SubmitChanges();
message += "保存成功!";
}
else
{
message += "上报日期不能为空!";
}
}
else
{
message += "单位不存在请确认单位Id和社会统一信用码";
}
}
else
{
message += "单位Id和社会统一信用码不能都为空";
}
}
responeData.data = new { message };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
/// <summary>
/// 修改安全数据统计月报
/// </summary>
/// <param name="items"> </param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData UpdateMillionsMonthlyReport([FromBody] Model.Customization._7HJ.InformationData items)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
string message = string.Empty;
foreach (var newItem in items.InformationDataItems)
{
if (!string.IsNullOrEmpty(newItem.UnitId) || !string.IsNullOrEmpty(newItem.CollCropCode))
{
string unitId = string.Empty;
string unitName = string.Empty;
var unit = db.Base_Unit.FirstOrDefault(x => x.CollCropCode == newItem.CollCropCode);
if (unit != null)
{
unitId = unit.UnitId;
unitName = unit.UnitName;
}
else
{
var unit2 = db.Base_Unit.FirstOrDefault(x => x.UnitId == newItem.UnitId);
if (unit2 != null)
{
unitId = unit2.UnitId;
unitName = unit2.UnitName;
}
}
if (!string.IsNullOrEmpty(unitId))
{
DateTime? date = Funs.GetNewDateTime(newItem.FillingDate);
if (date != null)
{
Model.Information_MillionsMonthlyReport millionsMonthlyReport =
new Model.Information_MillionsMonthlyReport
{
Year = newItem.Year,
Month = newItem.Month,
UnitId = newItem.UnitId,
FillingDate = date,
DutyPerson = newItem.DutyPerson,
RecordableIncidentRate = Convert.ToDecimal(newItem.RecordableIncidentRate),
LostTimeRate = Convert.ToDecimal(newItem.LostTimeRate),
LostTimeInjuryRate = Convert.ToDecimal(newItem.LostTimeInjuryRate),
DeathAccidentFrequency = Convert.ToDecimal(newItem.DeathAccidentFrequency),
AccidentMortality = Convert.ToDecimal(newItem.AccidentMortality),
InputCosts = Convert.ToDecimal(newItem.InputCosts),
TrainNum = newItem.TrainNum,
GeneralHazardNum = newItem.GeneralHazardNum,
MajorHazardNum = newItem.MajorHazardNum,
NotProofLargeProjectNum = newItem.NotProofLargeProjectNum,
ProofLargeProjectNum = newItem.ProofLargeProjectNum,
FireLicenseNum = newItem.FireLicenseNum,
LimitLicenseNum = newItem.LimitLicenseNum,
HighLicenseNum = newItem.HighLicenseNum,
HoistingLicenseNum = newItem.HoistingLicenseNum,
BreakGroundLicenseNum = newItem.BreakGroundLicenseNum,
ElectricityLicenseNum = newItem.ElectricityLicenseNum,
RTLicenseNum = newItem.RTLicenseNum,
NightLicenseNum = newItem.NightLicenseNum,
CommissionerNum = newItem.CommissionerNum,
SoleDutyNum = newItem.SoleDutyNum,
FillingMan = newItem.FillingMan,
// ReceiveDate = DateTime.Now
};
var millionsMonthlyReportId = newItem.MillionsMonthlyReportId ?? "";
var oldmillionsMonthlyReport =
db.Information_MillionsMonthlyReport.FirstOrDefault(x =>
x.UnitId == millionsMonthlyReport.UnitId &&
x.Year == millionsMonthlyReport.Year &&
x.Month == millionsMonthlyReport.Month);
if (oldmillionsMonthlyReport == null)
{
millionsMonthlyReport.MillionsMonthlyReportId = SQLHelper.GetNewID();
db.Information_MillionsMonthlyReport.InsertOnSubmit(millionsMonthlyReport);
millionsMonthlyReportId = millionsMonthlyReport.MillionsMonthlyReportId;
}
else
{
oldmillionsMonthlyReport.FillingDate = millionsMonthlyReport.FillingDate;
oldmillionsMonthlyReport.DutyPerson = millionsMonthlyReport.DutyPerson;
oldmillionsMonthlyReport.RecordableIncidentRate =
millionsMonthlyReport.RecordableIncidentRate;
oldmillionsMonthlyReport.LostTimeRate = millionsMonthlyReport.LostTimeRate;
oldmillionsMonthlyReport.LostTimeInjuryRate =
millionsMonthlyReport.LostTimeInjuryRate;
oldmillionsMonthlyReport.DeathAccidentFrequency =
millionsMonthlyReport.DeathAccidentFrequency;
oldmillionsMonthlyReport.AccidentMortality =
millionsMonthlyReport.AccidentMortality;
oldmillionsMonthlyReport.InputCosts = millionsMonthlyReport.InputCosts;
oldmillionsMonthlyReport.TrainNum = millionsMonthlyReport.TrainNum;
oldmillionsMonthlyReport.GeneralHazardNum =
millionsMonthlyReport.GeneralHazardNum;
oldmillionsMonthlyReport.MajorHazardNum = millionsMonthlyReport.MajorHazardNum;
oldmillionsMonthlyReport.NotProofLargeProjectNum =
millionsMonthlyReport.NotProofLargeProjectNum;
oldmillionsMonthlyReport.ProofLargeProjectNum =
millionsMonthlyReport.ProofLargeProjectNum;
oldmillionsMonthlyReport.FireLicenseNum = millionsMonthlyReport.FireLicenseNum;
oldmillionsMonthlyReport.LimitLicenseNum =
millionsMonthlyReport.LimitLicenseNum;
oldmillionsMonthlyReport.HighLicenseNum = millionsMonthlyReport.HighLicenseNum;
oldmillionsMonthlyReport.HoistingLicenseNum =
millionsMonthlyReport.HoistingLicenseNum;
oldmillionsMonthlyReport.BreakGroundLicenseNum =
millionsMonthlyReport.BreakGroundLicenseNum;
oldmillionsMonthlyReport.ElectricityLicenseNum =
millionsMonthlyReport.ElectricityLicenseNum;
oldmillionsMonthlyReport.RTLicenseNum = millionsMonthlyReport.RTLicenseNum;
oldmillionsMonthlyReport.NightLicenseNum =
millionsMonthlyReport.NightLicenseNum;
oldmillionsMonthlyReport.CommissionerNum =
millionsMonthlyReport.CommissionerNum;
oldmillionsMonthlyReport.SoleDutyNum = millionsMonthlyReport.SoleDutyNum;
oldmillionsMonthlyReport.FillingMan = millionsMonthlyReport.FillingMan;
// oldmillionsMonthlyReport.ReceiveDate = DateTime.Now;
millionsMonthlyReportId = oldmillionsMonthlyReport.MillionsMonthlyReportId;
var q = from x in db.Information_MillionsMonthlyReportItem
where x.MillionsMonthlyReportId ==
oldmillionsMonthlyReport.MillionsMonthlyReportId
select x;
if (q.Count() > 0)
{
db.Information_MillionsMonthlyReportItem.DeleteAllOnSubmit(q);
db.SubmitChanges();
}
}
var millionsMonthlyReportIdH = newItem.MillionsMonthlyReportId ?? "";
// millionsMonthlyReportHistory.MillionsMonthlyReportId = SQLHelper.GetNewID();
// db.Information_MillionsMonthlyReportHistory.InsertOnSubmit(millionsMonthlyReportHistory);
// millionsMonthlyReportIdH = millionsMonthlyReportHistory.MillionsMonthlyReportId;
//保存子项
List<Model.Information_MillionsMonthlyReportItem> ReportItemList =
new List<Model.Information_MillionsMonthlyReportItem>();
foreach (var item in newItem.MillionsMonthlyReportItem)
{
Model.Information_MillionsMonthlyReportItem ReportItem =
new Model.Information_MillionsMonthlyReportItem();
ReportItem.MillionsMonthlyReportId = millionsMonthlyReportId;
ReportItem.MillionsMonthlyReportItemId = SQLHelper.GetNewID();
ReportItem.Affiliation = item.Affiliation;
ReportItem.Name = item.Name;
ReportItem.PostPersonNum = item.PostPersonNum;
ReportItem.SnapPersonNum = item.SnapPersonNum;
ReportItem.ContractorNum = item.ContractorNum;
ReportItem.SumPersonNum = item.SumPersonNum;
ReportItem.TotalWorkNum = item.TotalWorkNum;
ReportItem.SeriousInjuriesNum = item.SeriousInjuriesNum;
ReportItem.SeriousInjuriesPersonNum = item.SeriousInjuriesPersonNum;
ReportItem.SeriousInjuriesLossHour = item.SeriousInjuriesLossHour;
ReportItem.MinorAccidentNum = item.MinorAccidentNum;
ReportItem.MinorAccidentPersonNum = item.MinorAccidentPersonNum;
ReportItem.MinorAccidentLossHour = item.MinorAccidentLossHour;
ReportItem.DeathAccidentNum = item.OtherAccidentNum;
ReportItem.DeathAccidentPersonNum = item.OtherAccidentPersonNum;
ReportItem.DeathAccidentLossHour = item.OtherAccidentLossHour;
ReportItem.RestrictedWorkPersonNum = item.RestrictedWorkPersonNum;
ReportItem.RestrictedWorkLossHour = item.RestrictedWorkLossHour;
ReportItem.MedicalTreatmentPersonNum = item.MedicalTreatmentPersonNum;
ReportItem.MedicalTreatmentLossHour = item.MedicalTreatmentLossHour;
ReportItem.FireNum = item.FireNum;
ReportItem.EnvironmenNum = item.ExplosionNum;
ReportItem.TrafficNum = item.TrafficNum;
ReportItem.EquipmentNum = item.EquipmentNum;
ReportItem.QualityNum = item.QualityNum;
ReportItem.OtherNum = item.OtherNum;
ReportItem.FirstAidDressingsNum = item.FirstAidDressingsNum;
ReportItem.AttemptedEventNum = item.AttemptedEventNum;
ReportItem.LossDayNum = item.LossDayNum;
ReportItem.SortIndex = item.SortIndex;
ReportItemList.Add(ReportItem);
}
if (ReportItemList.Count > 0)
db.Information_MillionsMonthlyReportItem.InsertAllOnSubmit(ReportItemList);
// if (ReportItemListHistory.Count > 0)
// db.Information_MillionsMonthlyReportHistoryItem.InsertAllOnSubmit(
// ReportItemListHistory);
db.SubmitChanges();
message += "保存成功!";
}
else
{
message += "上报日期不能为空!";
}
}
else
{
message += "单位不存在请确认单位Id和社会统一信用码";
}
}
else
{
message += "单位Id和社会统一信用码不能都为空";
}
}
responeData.data = new { message };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 新增职工伤亡事故原因分析报
/// </summary>
/// <param name="items">Information数据</param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData SaveAccidentCauseReport([FromBody] Model.Customization._7HJ.InformationData items)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
string message = string.Empty;
foreach (var newItem in items.InformationDataItems)
{
if (!string.IsNullOrEmpty(newItem.UnitId) || !string.IsNullOrEmpty(newItem.CollCropCode))
{
string unitId = string.Empty;
string unitName = string.Empty;
var unit = db.Base_Unit.FirstOrDefault(x => x.CollCropCode == newItem.CollCropCode);
if (unit != null)
{
unitId = unit.UnitId;
unitName = unit.UnitName;
}
else
{
var unit2 = db.Base_Unit.FirstOrDefault(x => x.UnitId == newItem.UnitId);
if (unit2 != null)
{
unitId = unit2.UnitId;
unitName = unit2.UnitName;
}
}
if (!string.IsNullOrEmpty(unitId))
{
DateTime? date = Funs.GetNewDateTime(newItem.FillingDate);
if (date != null)
{
Model.Information_AccidentCauseReport accidentCauseReport =
new Model.Information_AccidentCauseReport
{
AccidentCauseReportCode = newItem.AccidentCauseReportCode,
Year = newItem.Year,
Month = newItem.Month,
UnitId = newItem.UnitId,
DeathAccident = newItem.DeathAccident,
DeathToll = newItem.DeathToll,
InjuredAccident = newItem.InjuredAccident,
InjuredToll = newItem.InjuredToll,
MinorWoundAccident = newItem.MinorWoundAccident,
MinorWoundToll = newItem.MinorWoundToll,
AverageTotalHours = Convert.ToDecimal(newItem.AverageTotalHours),
AverageManHours = newItem.AverageManHours,
TotalLossMan = newItem.TotalLossMan,
LastMonthLossHoursTotal = newItem.LastMonthLossHoursTotal,
KnockOffTotal = newItem.KnockOffTotal,
DirectLoss = newItem.DirectLoss,
IndirectLosses = newItem.IndirectLosses,
TotalLoss = newItem.TotalLoss,
TotalLossTime = newItem.TotalLossTime,
FillCompanyPersonCharge = newItem.FillCompanyPersonCharge,
TabPeople = newItem.TabPeople,
FillingDate = date,
AuditPerson = newItem.AuditPerson,
// ReceiveDate = DateTime.Now
};
var accidentCauseReportId = newItem.AccidentCauseReportId ?? "";
var oldAccidentCauseReport = db.Information_AccidentCauseReport.FirstOrDefault(x =>
x.UnitId == accidentCauseReport.UnitId && x.Year == accidentCauseReport.Year &&
x.Month == accidentCauseReport.Month);
if (oldAccidentCauseReport == null)
{
accidentCauseReport.AccidentCauseReportId = SQLHelper.GetNewID();
db.Information_AccidentCauseReport.InsertOnSubmit(accidentCauseReport);
accidentCauseReportId = accidentCauseReport.AccidentCauseReportId;
}
else
{
oldAccidentCauseReport.AccidentCauseReportCode =
accidentCauseReport.AccidentCauseReportCode;
oldAccidentCauseReport.DeathAccident = accidentCauseReport.DeathAccident;
oldAccidentCauseReport.DeathToll = accidentCauseReport.DeathToll;
oldAccidentCauseReport.InjuredAccident = accidentCauseReport.InjuredAccident;
oldAccidentCauseReport.InjuredToll = accidentCauseReport.InjuredToll;
oldAccidentCauseReport.MinorWoundAccident =
accidentCauseReport.MinorWoundAccident;
oldAccidentCauseReport.MinorWoundToll = accidentCauseReport.MinorWoundToll;
oldAccidentCauseReport.AverageTotalHours =
accidentCauseReport.AverageTotalHours;
oldAccidentCauseReport.AverageManHours = accidentCauseReport.AverageManHours;
oldAccidentCauseReport.TotalLossMan = accidentCauseReport.TotalLossMan;
oldAccidentCauseReport.LastMonthLossHoursTotal =
accidentCauseReport.LastMonthLossHoursTotal;
oldAccidentCauseReport.KnockOffTotal = accidentCauseReport.KnockOffTotal;
oldAccidentCauseReport.DirectLoss = accidentCauseReport.DirectLoss;
oldAccidentCauseReport.IndirectLosses = accidentCauseReport.IndirectLosses;
oldAccidentCauseReport.TotalLoss = accidentCauseReport.TotalLoss;
oldAccidentCauseReport.TotalLossTime = accidentCauseReport.TotalLossTime;
oldAccidentCauseReport.FillCompanyPersonCharge =
accidentCauseReport.FillCompanyPersonCharge;
oldAccidentCauseReport.TabPeople = accidentCauseReport.TabPeople;
oldAccidentCauseReport.FillingDate = accidentCauseReport.FillingDate;
oldAccidentCauseReport.AuditPerson = accidentCauseReport.AuditPerson;
// oldAccidentCauseReport.ReceiveDate = DateTime.Now;
accidentCauseReportId = oldAccidentCauseReport.AccidentCauseReportId;
var q = from x in db.Information_AccidentCauseReportItem
where x.AccidentCauseReportId ==
oldAccidentCauseReport.AccidentCauseReportId
select x;
if (q.Count() > 0)
{
db.Information_AccidentCauseReportItem.DeleteAllOnSubmit(q);
db.SubmitChanges();
}
}
var accidentCauseReportIdH = newItem.MillionsMonthlyReportId ?? "";
// accidentCauseReportHistory.AccidentCauseReportId = SQLHelper.GetNewID();
// db.Information_AccidentCauseReportHistory.InsertOnSubmit(accidentCauseReportHistory);
// accidentCauseReportIdH = accidentCauseReportHistory.AccidentCauseReportId;
//保存子项
List<Model.Information_AccidentCauseReportItem> ReportItemList =
new List<Model.Information_AccidentCauseReportItem>();
foreach (var item in newItem.AccidentCauseReportItem)
{
Model.Information_AccidentCauseReportItem ReportItem =
new Model.Information_AccidentCauseReportItem();
ReportItem.AccidentCauseReportId = accidentCauseReportId;
ReportItem.AccidentCauseReportItemId = SQLHelper.GetNewID();
ReportItem.AccidentType = item.AccidentType;
ReportItem.TotalDeath = item.TotalDeath;
ReportItem.TotalInjuries = item.TotalInjuries;
ReportItem.TotalMinorInjuries = item.TotalMinorInjuries;
ReportItem.Death1 = item.Death1;
ReportItem.Injuries1 = item.Injuries1;
ReportItem.MinorInjuries1 = item.MinorInjuries1;
ReportItem.Death2 = item.Death2;
ReportItem.Injuries2 = item.Injuries2;
ReportItem.MinorInjuries2 = item.MinorInjuries2;
ReportItem.Death3 = item.Death3;
ReportItem.Injuries3 = item.Injuries3;
ReportItem.MinorInjuries3 = item.MinorInjuries3;
ReportItem.Death4 = item.Death4;
ReportItem.Injuries4 = item.Injuries4;
ReportItem.MinorInjuries4 = item.MinorInjuries4;
ReportItem.Death5 = item.Death5;
ReportItem.Injuries5 = item.Injuries5;
ReportItem.MinorInjuries5 = item.MinorInjuries5;
ReportItem.Death6 = item.Death6;
ReportItem.Injuries6 = item.Injuries6;
ReportItem.MinorInjuries6 = item.MinorInjuries6;
ReportItem.Death7 = item.Death7;
ReportItem.Injuries7 = item.Injuries7;
ReportItem.MinorInjuries7 = item.MinorInjuries7;
ReportItem.Death8 = item.Death8;
ReportItem.Injuries8 = item.Injuries8;
ReportItem.MinorInjuries8 = item.MinorInjuries8;
ReportItem.Death9 = item.Death9;
ReportItem.Injuries9 = item.Injuries9;
ReportItem.MinorInjuries9 = item.MinorInjuries9;
ReportItem.Death10 = item.Death10;
ReportItem.Injuries10 = item.Injuries10;
ReportItem.MinorInjuries10 = item.MinorInjuries10;
ReportItem.Death11 = item.Death11;
ReportItem.Injuries11 = item.Injuries11;
ReportItem.MinorInjuries11 = item.MinorInjuries11;
ReportItemList.Add(ReportItem);
}
if (ReportItemList.Count > 0)
db.Information_AccidentCauseReportItem.InsertAllOnSubmit(ReportItemList);
// if (ReportItemListHistory.Count > 0)
// db.Information_AccidentCauseReportHistoryItem.InsertAllOnSubmit(ReportItemListHistory);
db.SubmitChanges();
message = "保存成功!";
}
else
{
message += "上报日期不能为空!";
}
}
else
{
message += "单位不存在请确认单位Id和社会统一信用码";
}
}
else
{
message += "单位Id和社会统一信用码不能都为空";
}
}
responeData.data = new { message };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
/// <summary>
/// 修改职工伤亡事故原因分析报
/// </summary>
/// <param name="items">Information数据</param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData UpdateAccidentCauseReport([FromBody] Model.Customization._7HJ.InformationData items)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
// responeData.message = APIInformationDataItemService.SaveAccidentCauseReport(newItem);
string message = string.Empty;
foreach (var newItem in items.InformationDataItems)
{
if (!string.IsNullOrEmpty(newItem.UnitId) || !string.IsNullOrEmpty(newItem.CollCropCode))
{
string unitId = string.Empty;
string unitName = string.Empty;
var unit = db.Base_Unit.FirstOrDefault(x => x.CollCropCode == newItem.CollCropCode);
if (unit != null)
{
unitId = unit.UnitId;
unitName = unit.UnitName;
}
else
{
var unit2 = db.Base_Unit.FirstOrDefault(x => x.UnitId == newItem.UnitId);
if (unit2 != null)
{
unitId = unit2.UnitId;
unitName = unit2.UnitName;
}
}
if (!string.IsNullOrEmpty(unitId))
{
DateTime? date = Funs.GetNewDateTime(newItem.FillingDate);
if (date != null)
{
Model.Information_AccidentCauseReport accidentCauseReport =
new Model.Information_AccidentCauseReport
{
AccidentCauseReportCode = newItem.AccidentCauseReportCode,
Year = newItem.Year,
Month = newItem.Month,
UnitId = newItem.UnitId,
DeathAccident = newItem.DeathAccident,
DeathToll = newItem.DeathToll,
InjuredAccident = newItem.InjuredAccident,
InjuredToll = newItem.InjuredToll,
MinorWoundAccident = newItem.MinorWoundAccident,
MinorWoundToll = newItem.MinorWoundToll,
AverageTotalHours = Convert.ToDecimal(newItem.AverageTotalHours),
AverageManHours = newItem.AverageManHours,
TotalLossMan = newItem.TotalLossMan,
LastMonthLossHoursTotal = newItem.LastMonthLossHoursTotal,
KnockOffTotal = newItem.KnockOffTotal,
DirectLoss = newItem.DirectLoss,
IndirectLosses = newItem.IndirectLosses,
TotalLoss = newItem.TotalLoss,
TotalLossTime = newItem.TotalLossTime,
FillCompanyPersonCharge = newItem.FillCompanyPersonCharge,
TabPeople = newItem.TabPeople,
FillingDate = date,
AuditPerson = newItem.AuditPerson,
// ReceiveDate = DateTime.Now
};
var accidentCauseReportId = newItem.AccidentCauseReportId ?? "";
var oldAccidentCauseReport = db.Information_AccidentCauseReport.FirstOrDefault(x =>
x.UnitId == accidentCauseReport.UnitId && x.Year == accidentCauseReport.Year &&
x.Month == accidentCauseReport.Month);
if (oldAccidentCauseReport == null)
{
accidentCauseReport.AccidentCauseReportId = SQLHelper.GetNewID();
db.Information_AccidentCauseReport.InsertOnSubmit(accidentCauseReport);
accidentCauseReportId = accidentCauseReport.AccidentCauseReportId;
}
else
{
oldAccidentCauseReport.AccidentCauseReportCode =
accidentCauseReport.AccidentCauseReportCode;
oldAccidentCauseReport.DeathAccident = accidentCauseReport.DeathAccident;
oldAccidentCauseReport.DeathToll = accidentCauseReport.DeathToll;
oldAccidentCauseReport.InjuredAccident = accidentCauseReport.InjuredAccident;
oldAccidentCauseReport.InjuredToll = accidentCauseReport.InjuredToll;
oldAccidentCauseReport.MinorWoundAccident =
accidentCauseReport.MinorWoundAccident;
oldAccidentCauseReport.MinorWoundToll = accidentCauseReport.MinorWoundToll;
oldAccidentCauseReport.AverageTotalHours =
accidentCauseReport.AverageTotalHours;
oldAccidentCauseReport.AverageManHours = accidentCauseReport.AverageManHours;
oldAccidentCauseReport.TotalLossMan = accidentCauseReport.TotalLossMan;
oldAccidentCauseReport.LastMonthLossHoursTotal =
accidentCauseReport.LastMonthLossHoursTotal;
oldAccidentCauseReport.KnockOffTotal = accidentCauseReport.KnockOffTotal;
oldAccidentCauseReport.DirectLoss = accidentCauseReport.DirectLoss;
oldAccidentCauseReport.IndirectLosses = accidentCauseReport.IndirectLosses;
oldAccidentCauseReport.TotalLoss = accidentCauseReport.TotalLoss;
oldAccidentCauseReport.TotalLossTime = accidentCauseReport.TotalLossTime;
oldAccidentCauseReport.FillCompanyPersonCharge =
accidentCauseReport.FillCompanyPersonCharge;
oldAccidentCauseReport.TabPeople = accidentCauseReport.TabPeople;
oldAccidentCauseReport.FillingDate = accidentCauseReport.FillingDate;
oldAccidentCauseReport.AuditPerson = accidentCauseReport.AuditPerson;
// oldAccidentCauseReport.ReceiveDate = DateTime.Now;
accidentCauseReportId = oldAccidentCauseReport.AccidentCauseReportId;
var q = from x in db.Information_AccidentCauseReportItem
where x.AccidentCauseReportId ==
oldAccidentCauseReport.AccidentCauseReportId
select x;
if (q.Count() > 0)
{
db.Information_AccidentCauseReportItem.DeleteAllOnSubmit(q);
db.SubmitChanges();
}
}
var accidentCauseReportIdH = newItem.MillionsMonthlyReportId ?? "";
// accidentCauseReportHistory.AccidentCauseReportId = SQLHelper.GetNewID();
// db.Information_AccidentCauseReportHistory.InsertOnSubmit(accidentCauseReportHistory);
// accidentCauseReportIdH = accidentCauseReportHistory.AccidentCauseReportId;
//保存子项
List<Model.Information_AccidentCauseReportItem> ReportItemList =
new List<Model.Information_AccidentCauseReportItem>();
foreach (var item in newItem.AccidentCauseReportItem)
{
Model.Information_AccidentCauseReportItem ReportItem =
new Model.Information_AccidentCauseReportItem();
ReportItem.AccidentCauseReportId = accidentCauseReportId;
ReportItem.AccidentCauseReportItemId = SQLHelper.GetNewID();
ReportItem.AccidentType = item.AccidentType;
ReportItem.TotalDeath = item.TotalDeath;
ReportItem.TotalInjuries = item.TotalInjuries;
ReportItem.TotalMinorInjuries = item.TotalMinorInjuries;
ReportItem.Death1 = item.Death1;
ReportItem.Injuries1 = item.Injuries1;
ReportItem.MinorInjuries1 = item.MinorInjuries1;
ReportItem.Death2 = item.Death2;
ReportItem.Injuries2 = item.Injuries2;
ReportItem.MinorInjuries2 = item.MinorInjuries2;
ReportItem.Death3 = item.Death3;
ReportItem.Injuries3 = item.Injuries3;
ReportItem.MinorInjuries3 = item.MinorInjuries3;
ReportItem.Death4 = item.Death4;
ReportItem.Injuries4 = item.Injuries4;
ReportItem.MinorInjuries4 = item.MinorInjuries4;
ReportItem.Death5 = item.Death5;
ReportItem.Injuries5 = item.Injuries5;
ReportItem.MinorInjuries5 = item.MinorInjuries5;
ReportItem.Death6 = item.Death6;
ReportItem.Injuries6 = item.Injuries6;
ReportItem.MinorInjuries6 = item.MinorInjuries6;
ReportItem.Death7 = item.Death7;
ReportItem.Injuries7 = item.Injuries7;
ReportItem.MinorInjuries7 = item.MinorInjuries7;
ReportItem.Death8 = item.Death8;
ReportItem.Injuries8 = item.Injuries8;
ReportItem.MinorInjuries8 = item.MinorInjuries8;
ReportItem.Death9 = item.Death9;
ReportItem.Injuries9 = item.Injuries9;
ReportItem.MinorInjuries9 = item.MinorInjuries9;
ReportItem.Death10 = item.Death10;
ReportItem.Injuries10 = item.Injuries10;
ReportItem.MinorInjuries10 = item.MinorInjuries10;
ReportItem.Death11 = item.Death11;
ReportItem.Injuries11 = item.Injuries11;
ReportItem.MinorInjuries11 = item.MinorInjuries11;
ReportItemList.Add(ReportItem);
}
if (ReportItemList.Count > 0)
db.Information_AccidentCauseReportItem.InsertAllOnSubmit(ReportItemList);
// if (ReportItemListHistory.Count > 0)
// db.Information_AccidentCauseReportHistoryItem.InsertAllOnSubmit(ReportItemListHistory);
db.SubmitChanges();
message += "保存成功!";
}
else
{
message += "上报日期不能为空!";
}
}
else
{
message += "单位不存在请确认单位Id和社会统一信用码";
}
}
else
{
message += "单位Id和社会统一信用码不能都为空";
}
}
responeData.data = new { message };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 新增应急演练开展情况季报
/// </summary>
/// <param name="items">数据项</param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData SaveDrillConductedQuarterlyReport(Model.Customization._7HJ.InformationData items)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
string message = string.Empty;
foreach (var newItem in items.InformationDataItems)
{
if (!string.IsNullOrEmpty(newItem.UnitId) || !string.IsNullOrEmpty(newItem.CollCropCode))
{
string unitId = string.Empty;
string unitName = string.Empty;
var unit = db.Base_Unit.FirstOrDefault(x => x.CollCropCode == newItem.CollCropCode);
if (unit != null)
{
unitId = unit.UnitId;
unitName = unit.UnitName;
}
else
{
var unit2 = db.Base_Unit.FirstOrDefault(x => x.UnitId == newItem.UnitId);
if (unit2 != null)
{
unitId = unit2.UnitId;
unitName = unit2.UnitName;
}
}
if (!string.IsNullOrEmpty(unitId))
{
DateTime? date = Funs.GetNewDateTime(newItem.ReportDate);
if (date != null)
{
Model.Information_DrillConductedQuarterlyReport newDrillConductedQuarterlyReport =
new Model.Information_DrillConductedQuarterlyReport
{
UnitId = newItem.UnitId,
ReportDate = date,
YearId = newItem.YearId,
Quarter = newItem.Quarter,
CompileMan = newItem.CompileMan
};
var drillConductedQuarterlyReportId = newItem.DrillConductedQuarterlyReportId ?? "";
var oldDrillConductedQuarterlyReport =
db.Information_DrillConductedQuarterlyReport.FirstOrDefault
(x => x.UnitId == newItem.UnitId && x.YearId == newItem.YearId &&
x.Quarter == newItem.Quarter);
if (oldDrillConductedQuarterlyReport == null)
{
newDrillConductedQuarterlyReport.DrillConductedQuarterlyReportId =
SQLHelper.GetNewID();
db.Information_DrillConductedQuarterlyReport.InsertOnSubmit(
newDrillConductedQuarterlyReport);
drillConductedQuarterlyReportId = newDrillConductedQuarterlyReport
.DrillConductedQuarterlyReportId;
}
else
{
//先删除子表
var list = db.Information_DrillConductedQuarterlyReportItem.Where(x =>
x.DrillConductedQuarterlyReportId ==
oldDrillConductedQuarterlyReport.DrillConductedQuarterlyReportId);
db.Information_DrillConductedQuarterlyReportItem.DeleteAllOnSubmit(list);
db.SubmitChanges();
//删除主表
db.Information_DrillConductedQuarterlyReport.DeleteOnSubmit(
oldDrillConductedQuarterlyReport);
db.SubmitChanges();
//重新添加主表
newDrillConductedQuarterlyReport.DrillConductedQuarterlyReportId =
SQLHelper.GetNewID();
db.Information_DrillConductedQuarterlyReport.InsertOnSubmit(
newDrillConductedQuarterlyReport);
drillConductedQuarterlyReportId = newDrillConductedQuarterlyReport
.DrillConductedQuarterlyReportId;
db.SubmitChanges();
//oldDrillConductedQuarterlyReport = newDrillConductedQuarterlyReport;
//oldDrillConductedQuarterlyReport.DrillConductedQuarterlyReportId = drillConductedQuarterlyReportId;
}
//保存子项
List<Model.Information_DrillConductedQuarterlyReportItem> ReportItemList =
new List<Model.Information_DrillConductedQuarterlyReportItem>();
foreach (var item in newItem.drillConductedQuarterlyReportItem)
{
Model.Information_DrillConductedQuarterlyReportItem ReportItem =
new Model.Information_DrillConductedQuarterlyReportItem();
ReportItem.DrillConductedQuarterlyReportId = drillConductedQuarterlyReportId;
ReportItem.DrillConductedQuarterlyReportItemId = SQLHelper.GetNewID();
ReportItem.IndustryType = item.IndustryType;
ReportItem.TotalConductCount = item.TotalConductCount;
ReportItem.TotalPeopleCount = item.TotalPeopleCount;
ReportItem.TotalInvestment = item.TotalInvestment;
ReportItem.HQConductCount = item.HQConductCount;
ReportItem.HQPeopleCount = item.HQPeopleCount;
ReportItem.HQInvestment = item.HQInvestment;
ReportItem.BasicConductCount = item.BasicConductCount;
ReportItem.BasicPeopleCount = item.BasicPeopleCount;
ReportItem.BasicInvestment = item.BasicInvestment;
ReportItem.ComprehensivePractice = item.ComprehensivePractice;
ReportItem.CPScene = item.CPScene;
ReportItem.CPDesktop = item.CPDesktop;
ReportItem.SpecialDrill = item.SpecialDrill;
ReportItem.SDScene = item.SDScene;
ReportItem.SDDesktop = item.SDDesktop;
ReportItem.SortIndex = item.SortIndex;
ReportItemList.Add(ReportItem);
}
if (ReportItemList.Count > 0)
db.Information_DrillConductedQuarterlyReportItem.InsertAllOnSubmit(
ReportItemList);
db.SubmitChanges();
message = "保存成功!";
}
else
{
message += "上报日期不能为空!";
}
}
else
{
message += "单位不存在请确认单位Id和社会统一信用码";
}
}
else
{
message += "单位Id和社会统一信用码不能都为空";
}
}
responeData.data = new { message };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
/// <summary>
/// 修改应急演练开展情况季报月报
/// </summary>
/// <param name="items">数据项</param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData UpdateDrillConductedQuarterlyReport(Model.Customization._7HJ.InformationData items)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
string message = string.Empty;
foreach (var newItem in items.InformationDataItems)
{
if (!string.IsNullOrEmpty(newItem.UnitId) || !string.IsNullOrEmpty(newItem.CollCropCode))
{
string unitId = string.Empty;
string unitName = string.Empty;
var unit = db.Base_Unit.FirstOrDefault(x => x.CollCropCode == newItem.CollCropCode);
if (unit != null)
{
unitId = unit.UnitId;
unitName = unit.UnitName;
}
else
{
var unit2 = db.Base_Unit.FirstOrDefault(x => x.UnitId == newItem.UnitId);
if (unit2 != null)
{
unitId = unit2.UnitId;
unitName = unit2.UnitName;
}
}
if (!string.IsNullOrEmpty(unitId))
{
DateTime? date = Funs.GetNewDateTime(newItem.ReportDate);
if (date != null)
{
Model.Information_DrillConductedQuarterlyReport newDrillConductedQuarterlyReport =
new Model.Information_DrillConductedQuarterlyReport
{
UnitId = newItem.UnitId,
ReportDate = date,
YearId = newItem.YearId,
Quarter = newItem.Quarter,
CompileMan = newItem.CompileMan
};
var drillConductedQuarterlyReportId = newItem.DrillConductedQuarterlyReportId ?? "";
var oldDrillConductedQuarterlyReport =
db.Information_DrillConductedQuarterlyReport.FirstOrDefault
(x => x.UnitId == newItem.UnitId && x.YearId == newItem.YearId &&
x.Quarter == newItem.Quarter);
if (oldDrillConductedQuarterlyReport == null)
{
newDrillConductedQuarterlyReport.DrillConductedQuarterlyReportId =
SQLHelper.GetNewID();
db.Information_DrillConductedQuarterlyReport.InsertOnSubmit(
newDrillConductedQuarterlyReport);
drillConductedQuarterlyReportId = newDrillConductedQuarterlyReport
.DrillConductedQuarterlyReportId;
}
else
{
//先删除子表
var list = db.Information_DrillConductedQuarterlyReportItem.Where(x =>
x.DrillConductedQuarterlyReportId ==
oldDrillConductedQuarterlyReport.DrillConductedQuarterlyReportId);
db.Information_DrillConductedQuarterlyReportItem.DeleteAllOnSubmit(list);
db.SubmitChanges();
//删除主表
db.Information_DrillConductedQuarterlyReport.DeleteOnSubmit(
oldDrillConductedQuarterlyReport);
db.SubmitChanges();
//重新添加主表
newDrillConductedQuarterlyReport.DrillConductedQuarterlyReportId =
SQLHelper.GetNewID();
db.Information_DrillConductedQuarterlyReport.InsertOnSubmit(
newDrillConductedQuarterlyReport);
drillConductedQuarterlyReportId = newDrillConductedQuarterlyReport
.DrillConductedQuarterlyReportId;
db.SubmitChanges();
//oldDrillConductedQuarterlyReport = newDrillConductedQuarterlyReport;
//oldDrillConductedQuarterlyReport.DrillConductedQuarterlyReportId = drillConductedQuarterlyReportId;
}
//保存子项
List<Model.Information_DrillConductedQuarterlyReportItem> ReportItemList =
new List<Model.Information_DrillConductedQuarterlyReportItem>();
foreach (var item in newItem.drillConductedQuarterlyReportItem)
{
Model.Information_DrillConductedQuarterlyReportItem ReportItem =
new Model.Information_DrillConductedQuarterlyReportItem();
ReportItem.DrillConductedQuarterlyReportId = drillConductedQuarterlyReportId;
ReportItem.DrillConductedQuarterlyReportItemId = SQLHelper.GetNewID();
ReportItem.IndustryType = item.IndustryType;
ReportItem.TotalConductCount = item.TotalConductCount;
ReportItem.TotalPeopleCount = item.TotalPeopleCount;
ReportItem.TotalInvestment = item.TotalInvestment;
ReportItem.HQConductCount = item.HQConductCount;
ReportItem.HQPeopleCount = item.HQPeopleCount;
ReportItem.HQInvestment = item.HQInvestment;
ReportItem.BasicConductCount = item.BasicConductCount;
ReportItem.BasicPeopleCount = item.BasicPeopleCount;
ReportItem.BasicInvestment = item.BasicInvestment;
ReportItem.ComprehensivePractice = item.ComprehensivePractice;
ReportItem.CPScene = item.CPScene;
ReportItem.CPDesktop = item.CPDesktop;
ReportItem.SpecialDrill = item.SpecialDrill;
ReportItem.SDScene = item.SDScene;
ReportItem.SDDesktop = item.SDDesktop;
ReportItem.SortIndex = item.SortIndex;
ReportItemList.Add(ReportItem);
}
if (ReportItemList.Count > 0)
db.Information_DrillConductedQuarterlyReportItem.InsertAllOnSubmit(
ReportItemList);
db.SubmitChanges();
message = "保存成功!";
}
else
{
message += "上报日期不能为空!";
}
}
else
{
message += "单位不存在请确认单位Id和社会统一信用码";
}
}
else
{
message += "单位Id和社会统一信用码不能都为空";
}
}
responeData.data = new { message };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 新增应急演练开展情况半年报
/// </summary>
/// <param name="items">数据项</param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData SaveDrillPlanHalfYearReport(Model.Customization._7HJ.InformationData items)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
string message = string.Empty;
foreach (var newItem in items.InformationDataItems)
{
if (!string.IsNullOrEmpty(newItem.UnitId) || !string.IsNullOrEmpty(newItem.CollCropCode))
{
string unitId = string.Empty;
string unitName = string.Empty;
var unit = db.Base_Unit.FirstOrDefault(x => x.CollCropCode == newItem.CollCropCode);
if (unit != null)
{
unitId = unit.UnitId;
unitName = unit.UnitName;
}
else
{
var unit2 = db.Base_Unit.FirstOrDefault(x => x.UnitId == newItem.UnitId);
if (unit2 != null)
{
unitId = unit2.UnitId;
unitName = unit2.UnitName;
}
}
if (!string.IsNullOrEmpty(unitId))
{
DateTime? date = Funs.GetNewDateTime(newItem.CompileDate);
if (date != null)
{
Model.Information_DrillPlanHalfYearReport drillPlanHalfYearReport =
new Model.Information_DrillPlanHalfYearReport
{
UnitId = newItem.UnitId,
CompileMan = newItem.CompileMan,
CompileDate = date,
YearId = newItem.YearId,
HalfYearId = newItem.HalfYearId,
Telephone = newItem.Telephone
};
var planHalfYearReportId = newItem.DrillPlanHalfYearReportId ?? "";
var olddrillPlanHalfYearReport = db.Information_DrillPlanHalfYearReport
.FirstOrDefault(x =>
x.UnitId == newItem.UnitId && x.YearId == newItem.YearId &&
x.HalfYearId == newItem.HalfYearId);
if (olddrillPlanHalfYearReport == null)
{
drillPlanHalfYearReport.DrillPlanHalfYearReportId = SQLHelper.GetNewID();
db.Information_DrillPlanHalfYearReport.InsertOnSubmit(drillPlanHalfYearReport);
planHalfYearReportId = drillPlanHalfYearReport.DrillPlanHalfYearReportId;
}
else
{
//查到后需要删除重新添加
//olddrillPlanHalfYearReport = drillPlanHalfYearReport;
//olddrillPlanHalfYearReport.DrillPlanHalfYearReportId = planHalfYearReportId;
var oldList = db.Information_DrillPlanHalfYearReportItem.Where(x =>
x.DrillPlanHalfYearReportId ==
olddrillPlanHalfYearReport.DrillPlanHalfYearReportId);
db.Information_DrillPlanHalfYearReportItem.DeleteAllOnSubmit(oldList);
db.SubmitChanges();
db.Information_DrillPlanHalfYearReport.DeleteOnSubmit(
olddrillPlanHalfYearReport);
db.SubmitChanges();
drillPlanHalfYearReport.DrillPlanHalfYearReportId = SQLHelper.GetNewID();
db.Information_DrillPlanHalfYearReport.InsertOnSubmit(drillPlanHalfYearReport);
planHalfYearReportId = drillPlanHalfYearReport.DrillPlanHalfYearReportId;
}
//保存子项
List<Model.Information_DrillPlanHalfYearReportItem> ReportItemList =
new List<Model.Information_DrillPlanHalfYearReportItem>();
foreach (var item in newItem.drillPlanHalfYearReportItem)
{
Model.Information_DrillPlanHalfYearReportItem ReportItem =
new Model.Information_DrillPlanHalfYearReportItem();
ReportItem.DrillPlanHalfYearReportId = planHalfYearReportId;
ReportItem.DrillPlanHalfYearReportItemId = SQLHelper.GetNewID();
ReportItem.DrillPlanName = item.DrillPlanName;
ReportItem.DrillPlanDate = item.DrillPlanDate;
ReportItem.AccidentScene = item.AccidentScene;
ReportItem.ExerciseWay = item.ExerciseWay;
ReportItem.OrganizationUnit = item.OrganizationUnit;
ReportItem.SortIndex = item.SortIndex;
ReportItemList.Add(ReportItem);
}
if (ReportItemList.Count > 0)
db.Information_DrillPlanHalfYearReportItem.InsertAllOnSubmit(ReportItemList);
db.SubmitChanges();
message = "保存成功!";
}
else
{
message += "日期不能为空!";
}
}
else
{
message += "单位不存在请确认单位Id和社会统一信用码";
}
}
else
{
message += "单位Id和社会统一信用码不能都为空";
}
}
responeData.data = new { message };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
/// <summary>
/// 修改应急演练开展情况半年报
/// </summary>
/// <param name="items">数据项</param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData UpdateDrillPlanHalfYearReport(Model.Customization._7HJ.InformationData items)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
string message = string.Empty;
foreach (var newItem in items.InformationDataItems)
{
if (!string.IsNullOrEmpty(newItem.UnitId) || !string.IsNullOrEmpty(newItem.CollCropCode))
{
string unitId = string.Empty;
string unitName = string.Empty;
var unit = db.Base_Unit.FirstOrDefault(x => x.CollCropCode == newItem.CollCropCode);
if (unit != null)
{
unitId = unit.UnitId;
unitName = unit.UnitName;
}
else
{
var unit2 = db.Base_Unit.FirstOrDefault(x => x.UnitId == newItem.UnitId);
if (unit2 != null)
{
unitId = unit2.UnitId;
unitName = unit2.UnitName;
}
}
if (!string.IsNullOrEmpty(unitId))
{
DateTime? date = Funs.GetNewDateTime(newItem.CompileDate);
if (date != null)
{
Model.Information_DrillPlanHalfYearReport drillPlanHalfYearReport =
new Model.Information_DrillPlanHalfYearReport
{
UnitId = newItem.UnitId,
CompileMan = newItem.CompileMan,
CompileDate = date,
YearId = newItem.YearId,
HalfYearId = newItem.HalfYearId,
Telephone = newItem.Telephone
};
var planHalfYearReportId = newItem.DrillPlanHalfYearReportId ?? "";
var olddrillPlanHalfYearReport = db.Information_DrillPlanHalfYearReport
.FirstOrDefault(x =>
x.UnitId == newItem.UnitId && x.YearId == newItem.YearId &&
x.HalfYearId == newItem.HalfYearId);
if (olddrillPlanHalfYearReport == null)
{
drillPlanHalfYearReport.DrillPlanHalfYearReportId = SQLHelper.GetNewID();
db.Information_DrillPlanHalfYearReport.InsertOnSubmit(drillPlanHalfYearReport);
planHalfYearReportId = drillPlanHalfYearReport.DrillPlanHalfYearReportId;
}
else
{
//查到后需要删除重新添加
//olddrillPlanHalfYearReport = drillPlanHalfYearReport;
//olddrillPlanHalfYearReport.DrillPlanHalfYearReportId = planHalfYearReportId;
var oldList = db.Information_DrillPlanHalfYearReportItem.Where(x =>
x.DrillPlanHalfYearReportId ==
olddrillPlanHalfYearReport.DrillPlanHalfYearReportId);
db.Information_DrillPlanHalfYearReportItem.DeleteAllOnSubmit(oldList);
db.SubmitChanges();
db.Information_DrillPlanHalfYearReport.DeleteOnSubmit(
olddrillPlanHalfYearReport);
db.SubmitChanges();
drillPlanHalfYearReport.DrillPlanHalfYearReportId = SQLHelper.GetNewID();
db.Information_DrillPlanHalfYearReport.InsertOnSubmit(drillPlanHalfYearReport);
planHalfYearReportId = drillPlanHalfYearReport.DrillPlanHalfYearReportId;
}
//保存子项
List<Model.Information_DrillPlanHalfYearReportItem> ReportItemList =
new List<Model.Information_DrillPlanHalfYearReportItem>();
foreach (var item in newItem.drillPlanHalfYearReportItem)
{
Model.Information_DrillPlanHalfYearReportItem ReportItem =
new Model.Information_DrillPlanHalfYearReportItem();
ReportItem.DrillPlanHalfYearReportId = planHalfYearReportId;
ReportItem.DrillPlanHalfYearReportItemId = SQLHelper.GetNewID();
ReportItem.DrillPlanName = item.DrillPlanName;
ReportItem.DrillPlanDate = item.DrillPlanDate;
ReportItem.AccidentScene = item.AccidentScene;
ReportItem.ExerciseWay = item.ExerciseWay;
ReportItem.OrganizationUnit = item.OrganizationUnit;
ReportItem.SortIndex = item.SortIndex;
ReportItemList.Add(ReportItem);
}
if (ReportItemList.Count > 0)
db.Information_DrillPlanHalfYearReportItem.InsertAllOnSubmit(ReportItemList);
db.SubmitChanges();
message = "保存成功!";
}
else
{
message += "日期不能为空!";
}
}
else
{
message += "单位不存在请确认单位Id和社会统一信用码";
}
}
else
{
message += "单位Id和社会统一信用码不能都为空";
}
}
responeData.data = new { message };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 新增季度工程项目质量信息表
/// </summary>
/// <param name="items">数据项</param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData SaveQuarterlyProjectQuality(Model.Customization._7HJ.InformationData items)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
string message = string.Empty;
foreach (var newItem in items.InformationDataItems)
{
if (!string.IsNullOrEmpty(newItem.UnitId) || !string.IsNullOrEmpty(newItem.CollCropCode))
{
string unitId = string.Empty;
string unitName = string.Empty;
var unit = db.Base_Unit.FirstOrDefault(x => x.CollCropCode == newItem.CollCropCode);
if (unit != null)
{
unitId = unit.UnitId;
unitName = unit.UnitName;
}
else
{
var unit2 = db.Base_Unit.FirstOrDefault(x => x.UnitId == newItem.UnitId);
if (unit2 != null)
{
unitId = unit2.UnitId;
unitName = unit2.UnitName;
}
}
if (!string.IsNullOrEmpty(unitId))
{
DateTime? date = Funs.GetNewDateTime(newItem.CompileDate);
if (date != null)
{
Model.Information_QuarterlyProjectQuality report =
new Model.Information_QuarterlyProjectQuality
{
UnitId = newItem.UnitId,
Year = newItem.Year,
Quarter = newItem.Quarter,
QualityManagePersonNum = newItem.QualityManagePersonNum,
AdvancedTitlePersonNum = newItem.AdvancedTitlePersonNum,
IntermediateTitlePersonNum = newItem.IntermediateTitlePersonNum,
BeImplementedProjectNum = newItem.BeImplementedProjectNum,
StartImplementedProjectNum = newItem.StartImplementedProjectNum,
AccumulativeStartImplemented = newItem.AccumulativeStartImplemented,
CompleteProjectNum = newItem.CompleteProjectNum,
YearCompleteProjectNum = newItem.YearCompleteProjectNum,
QuarterTotal = newItem.QuarterTotal,
QuarterFirstPassNum = newItem.QuarterFirstPassNum,
QuarterFirstPassRate = newItem.QuarterFirstPassRate,
YearTotal = newItem.YearTotal,
YearFirstPassNum = newItem.YearFirstPassNum,
YearFirstPassRate = newItem.YearFirstPassRate,
QuaterCheckSuperviseNum = newItem.QuaterCheckSuperviseNum,
QuaterCorrectiveNoticeNum = newItem.QuaterCorrectiveNoticeNum,
QuaterQualityProblemNum = newItem.QuaterQualityProblemNum,
QuaterClosedQualityProblemNum = newItem.QuaterClosedQualityProblemNum,
YearCheckSuperviseNum = newItem.YearCheckSuperviseNum,
YearCorrectiveNoticeNum = newItem.YearCorrectiveNoticeNum,
YearQualityProblemNum = newItem.YearQualityProblemNum,
YearClosedQualityProblemNum = newItem.YearClosedQualityProblemNum,
QuaterQualityAccidentNum = newItem.QuaterQualityAccidentNum,
QuaterDirectEconomicLoss = newItem.QuaterDirectEconomicLoss,
YearQualityAccidentNum = newItem.YearQualityAccidentNum,
YearDirectEconomicLoss = newItem.YearDirectEconomicLoss,
ResponsiblePerson = newItem.ResponsiblePerson,
CompileMan = newItem.CompileMan,
CompileDate = Funs.GetNewDateTime(newItem.CompileDate),
Tel = newItem.Tel
};
var quarterlyProjectQualityId = newItem.QuarterlyProjectQualityId ?? "";
var oldQualityWorkSummaryReport =
db.Information_QuarterlyProjectQuality.FirstOrDefault(
x =>
x.UnitId == newItem.UnitId && x.Year == newItem.Year &&
x.Quarter == newItem.Quarter);
if (oldQualityWorkSummaryReport == null)
{
report.QuarterlyProjectQualityId = SQLHelper.GetNewID();
db.Information_QuarterlyProjectQuality.InsertOnSubmit(report);
quarterlyProjectQualityId = report.QuarterlyProjectQualityId;
}
else
{
//oldQualityWorkSummaryReport = report;
//oldQualityWorkSummaryReport.QuarterlyProjectQualityId = quarterlyProjectQualityId;
db.Information_QuarterlyProjectQuality.DeleteOnSubmit(
oldQualityWorkSummaryReport);
db.SubmitChanges();
report.QuarterlyProjectQualityId = SQLHelper.GetNewID();
db.Information_QuarterlyProjectQuality.InsertOnSubmit(report);
quarterlyProjectQualityId = report.QuarterlyProjectQualityId;
}
db.SubmitChanges();
message = "保存成功!";
}
else
{
message += "上报日期不能为空!";
}
}
else
{
message += "单位不存在请确认单位Id和社会统一信用码";
}
}
else
{
message += "单位Id和社会统一信用码不能都为空";
}
}
responeData.data = new { message };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
/// <summary>
/// 修改季度工程项目质量信息表
/// </summary>
/// <param name="items">数据项</param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData UpdateQuarterlyProjectQuality(Model.Customization._7HJ.InformationData items)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
string message = string.Empty;
foreach (var newItem in items.InformationDataItems)
{
if (!string.IsNullOrEmpty(newItem.UnitId) || !string.IsNullOrEmpty(newItem.CollCropCode))
{
string unitId = string.Empty;
string unitName = string.Empty;
var unit = db.Base_Unit.FirstOrDefault(x => x.CollCropCode == newItem.CollCropCode);
if (unit != null)
{
unitId = unit.UnitId;
unitName = unit.UnitName;
}
else
{
var unit2 = db.Base_Unit.FirstOrDefault(x => x.UnitId == newItem.UnitId);
if (unit2 != null)
{
unitId = unit2.UnitId;
unitName = unit2.UnitName;
}
}
if (!string.IsNullOrEmpty(unitId))
{
DateTime? date = Funs.GetNewDateTime(newItem.CompileDate);
if (date != null)
{
Model.Information_QuarterlyProjectQuality report =
new Model.Information_QuarterlyProjectQuality
{
UnitId = newItem.UnitId,
Year = newItem.Year,
Quarter = newItem.Quarter,
QualityManagePersonNum = newItem.QualityManagePersonNum,
AdvancedTitlePersonNum = newItem.AdvancedTitlePersonNum,
IntermediateTitlePersonNum = newItem.IntermediateTitlePersonNum,
BeImplementedProjectNum = newItem.BeImplementedProjectNum,
StartImplementedProjectNum = newItem.StartImplementedProjectNum,
AccumulativeStartImplemented = newItem.AccumulativeStartImplemented,
CompleteProjectNum = newItem.CompleteProjectNum,
YearCompleteProjectNum = newItem.YearCompleteProjectNum,
QuarterTotal = newItem.QuarterTotal,
QuarterFirstPassNum = newItem.QuarterFirstPassNum,
QuarterFirstPassRate = newItem.QuarterFirstPassRate,
YearTotal = newItem.YearTotal,
YearFirstPassNum = newItem.YearFirstPassNum,
YearFirstPassRate = newItem.YearFirstPassRate,
QuaterCheckSuperviseNum = newItem.QuaterCheckSuperviseNum,
QuaterCorrectiveNoticeNum = newItem.QuaterCorrectiveNoticeNum,
QuaterQualityProblemNum = newItem.QuaterQualityProblemNum,
QuaterClosedQualityProblemNum = newItem.QuaterClosedQualityProblemNum,
YearCheckSuperviseNum = newItem.YearCheckSuperviseNum,
YearCorrectiveNoticeNum = newItem.YearCorrectiveNoticeNum,
YearQualityProblemNum = newItem.YearQualityProblemNum,
YearClosedQualityProblemNum = newItem.YearClosedQualityProblemNum,
QuaterQualityAccidentNum = newItem.QuaterQualityAccidentNum,
QuaterDirectEconomicLoss = newItem.QuaterDirectEconomicLoss,
YearQualityAccidentNum = newItem.YearQualityAccidentNum,
YearDirectEconomicLoss = newItem.YearDirectEconomicLoss,
ResponsiblePerson = newItem.ResponsiblePerson,
CompileMan = newItem.CompileMan,
CompileDate = Funs.GetNewDateTime(newItem.CompileDate),
Tel = newItem.Tel
};
var quarterlyProjectQualityId = newItem.QuarterlyProjectQualityId ?? "";
var oldQualityWorkSummaryReport =
db.Information_QuarterlyProjectQuality.FirstOrDefault(
x =>
x.UnitId == newItem.UnitId && x.Year == newItem.Year &&
x.Quarter == newItem.Quarter);
if (oldQualityWorkSummaryReport == null)
{
report.QuarterlyProjectQualityId = SQLHelper.GetNewID();
db.Information_QuarterlyProjectQuality.InsertOnSubmit(report);
quarterlyProjectQualityId = report.QuarterlyProjectQualityId;
}
else
{
//oldQualityWorkSummaryReport = report;
//oldQualityWorkSummaryReport.QuarterlyProjectQualityId = quarterlyProjectQualityId;
db.Information_QuarterlyProjectQuality.DeleteOnSubmit(
oldQualityWorkSummaryReport);
db.SubmitChanges();
report.QuarterlyProjectQualityId = SQLHelper.GetNewID();
db.Information_QuarterlyProjectQuality.InsertOnSubmit(report);
quarterlyProjectQualityId = report.QuarterlyProjectQualityId;
}
db.SubmitChanges();
message = "保存成功!";
}
else
{
message += "上报日期不能为空!";
}
}
else
{
message += "单位不存在请确认单位Id和社会统一信用码";
}
}
else
{
message += "单位Id和社会统一信用码不能都为空";
}
}
responeData.data = new { message };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 新增生态环保总结工作报告
/// </summary>
/// <param name="items">数据项</param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData SaveEPSummaryReport(Model.Customization._7HJ.InformationData items)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
string message = string.Empty;
foreach (var newItem in items.InformationDataItems)
{
if (!string.IsNullOrEmpty(newItem.UnitId) || !string.IsNullOrEmpty(newItem.CollCropCode))
{
string unitId = string.Empty;
string unitName = string.Empty;
var unit = db.Base_Unit.FirstOrDefault(x => x.CollCropCode == newItem.CollCropCode);
if (unit != null)
{
unitId = unit.UnitId;
unitName = unit.UnitName;
}
else
{
var unit2 = db.Base_Unit.FirstOrDefault(x => x.UnitId == newItem.UnitId);
if (unit2 != null)
{
unitId = unit2.UnitId;
unitName = unit2.UnitName;
}
}
if (!string.IsNullOrEmpty(unitId))
{
DateTime? date = Funs.GetNewDateTime(newItem.ReportDate);
if (date != null)
{
Model.Information_EPSummaryReport report = new Model.Information_EPSummaryReport
{
UnitId = newItem.UnitId,
YearId = newItem.YearId,
Quarter = newItem.Quarter,
ResponsiblePerson = newItem.ResponsiblePerson,
ResponsiblePersonTel = newItem.ResponsiblePersonTel,
ContactPerson = newItem.ContactPerson,
ContactPersonTel = newItem.ContactPersonTel,
ReportDate = Funs.GetNewDateTime(newItem.ReportDate),
Description1 = newItem.Description1,
Description2 = newItem.Description2,
Description3 = newItem.Description3,
Description4 = newItem.Description4,
Description5 = newItem.Description5,
Description6 = newItem.Description6,
Description7 = newItem.Description7,
Description8 = newItem.Description8,
Description9 = newItem.Description9
};
var ePSummaryReportId = newItem.EPSummaryReportId ?? "";
var oldEPSummaryReport = db.Information_EPSummaryReport.FirstOrDefault(x =>
x.UnitId == newItem.UnitId
&& x.YearId == newItem.YearId && x.Quarter == newItem.Quarter);
if (oldEPSummaryReport == null)
{
report.EPSummaryReportId = SQLHelper.GetNewID();
db.Information_EPSummaryReport.InsertOnSubmit(report);
ePSummaryReportId = report.EPSummaryReportId;
}
else
{
//oldEPSummaryReport = report;
//oldEPSummaryReport.EPSummaryReportId = ePSummaryReportId;
db.Information_EPSummaryReport.DeleteOnSubmit(oldEPSummaryReport);
db.SubmitChanges();
report.EPSummaryReportId = SQLHelper.GetNewID();
db.Information_EPSummaryReport.InsertOnSubmit(report);
ePSummaryReportId = report.EPSummaryReportId;
}
db.SubmitChanges();
message = "保存成功!";
}
else
{
message += "上报日期不能为空!";
}
}
else
{
message += "单位不存在请确认单位Id和社会统一信用码";
}
}
else
{
message += "单位Id和社会统一信用码不能都为空";
}
}
responeData.data = new { message };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
/// <summary>
/// 修改生态环保总结工作报告
/// </summary>
/// <param name="items">数据项</param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData UpdateEPSummaryReport(Model.Customization._7HJ.InformationData items)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
string message = string.Empty;
foreach (var newItem in items.InformationDataItems)
{
if (!string.IsNullOrEmpty(newItem.UnitId) || !string.IsNullOrEmpty(newItem.CollCropCode))
{
string unitId = string.Empty;
string unitName = string.Empty;
var unit = db.Base_Unit.FirstOrDefault(x => x.CollCropCode == newItem.CollCropCode);
if (unit != null)
{
unitId = unit.UnitId;
unitName = unit.UnitName;
}
else
{
var unit2 = db.Base_Unit.FirstOrDefault(x => x.UnitId == newItem.UnitId);
if (unit2 != null)
{
unitId = unit2.UnitId;
unitName = unit2.UnitName;
}
}
if (!string.IsNullOrEmpty(unitId))
{
DateTime? date = Funs.GetNewDateTime(newItem.ReportDate);
if (date != null)
{
Model.Information_EPSummaryReport report = new Model.Information_EPSummaryReport
{
UnitId = newItem.UnitId,
YearId = newItem.YearId,
Quarter = newItem.Quarter,
ResponsiblePerson = newItem.ResponsiblePerson,
ResponsiblePersonTel = newItem.ResponsiblePersonTel,
ContactPerson = newItem.ContactPerson,
ContactPersonTel = newItem.ContactPersonTel,
ReportDate = Funs.GetNewDateTime(newItem.ReportDate),
Description1 = newItem.Description1,
Description2 = newItem.Description2,
Description3 = newItem.Description3,
Description4 = newItem.Description4,
Description5 = newItem.Description5,
Description6 = newItem.Description6,
Description7 = newItem.Description7,
Description8 = newItem.Description8,
Description9 = newItem.Description9
};
var ePSummaryReportId = newItem.EPSummaryReportId ?? "";
var oldEPSummaryReport = db.Information_EPSummaryReport.FirstOrDefault(x =>
x.UnitId == newItem.UnitId
&& x.YearId == newItem.YearId && x.Quarter == newItem.Quarter);
if (oldEPSummaryReport == null)
{
report.EPSummaryReportId = SQLHelper.GetNewID();
db.Information_EPSummaryReport.InsertOnSubmit(report);
ePSummaryReportId = report.EPSummaryReportId;
}
else
{
//oldEPSummaryReport = report;
//oldEPSummaryReport.EPSummaryReportId = ePSummaryReportId;
db.Information_EPSummaryReport.DeleteOnSubmit(oldEPSummaryReport);
db.SubmitChanges();
report.EPSummaryReportId = SQLHelper.GetNewID();
db.Information_EPSummaryReport.InsertOnSubmit(report);
ePSummaryReportId = report.EPSummaryReportId;
}
db.SubmitChanges();
message = "保存成功!";
}
else
{
message += "上报日期不能为空!";
}
}
else
{
message += "单位不存在请确认单位Id和社会统一信用码";
}
}
else
{
message += "单位Id和社会统一信用码不能都为空";
}
}
responeData.data = new { message };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
#endregion
#region
/// <summary>
/// 新增建筑行业能源节约与生态环境保护汇总表
/// </summary>
/// <param name="items">数据项</param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData SaveArchitectureReport(Model.Customization._7HJ.InformationData items)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
string message = string.Empty;
foreach (var newItem in items.InformationDataItems)
{
if (!string.IsNullOrEmpty(newItem.UnitId) || !string.IsNullOrEmpty(newItem.CollCropCode))
{
string unitId = string.Empty;
string unitName = string.Empty;
var unit = db.Base_Unit.FirstOrDefault(x => x.CollCropCode == newItem.CollCropCode);
if (unit != null)
{
unitId = unit.UnitId;
unitName = unit.UnitName;
}
else
{
var unit2 = db.Base_Unit.FirstOrDefault(x => x.UnitId == newItem.UnitId);
if (unit2 != null)
{
unitId = unit2.UnitId;
unitName = unit2.UnitName;
}
}
if (!string.IsNullOrEmpty(unitId))
{
DateTime? date = Funs.GetNewDateTime(newItem.FillingDate);
if (date != null)
{
Model.Environmental_ArchitectureReport chemicalReport =
new Model.Environmental_ArchitectureReport
{
Year = newItem.Year,
Quarters = newItem.Quarters,
UnitId = newItem.UnitId,
FillingDate = date,
DutyPerson = newItem.DutyPerson,
FillingMan = newItem.FillingMan
};
var chemicalReportId = newItem.ArchitectureReportId ?? "";
var oldArchitectureReport = db.Environmental_ArchitectureReport.FirstOrDefault(x =>
x.UnitId == chemicalReport.UnitId && x.Year == chemicalReport.Year &&
x.Quarters == chemicalReport.Quarters);
if (oldArchitectureReport == null)
{
chemicalReport.ArchitectureReportId = SQLHelper.GetNewID();
db.Environmental_ArchitectureReport.InsertOnSubmit(chemicalReport);
chemicalReportId = chemicalReport.ArchitectureReportId;
}
else
{
var architectureReportItems = db.Environmental_ArchitectureReportItem.Where(x =>
x.ArchitectureReportId == oldArchitectureReport.ArchitectureReportId);
db.Environmental_ArchitectureReportItem.DeleteAllOnSubmit(
architectureReportItems);
db.SubmitChanges();
db.Environmental_ArchitectureReport.DeleteOnSubmit(oldArchitectureReport);
db.SubmitChanges();
chemicalReport.ArchitectureReportId = SQLHelper.GetNewID();
db.Environmental_ArchitectureReport.InsertOnSubmit(chemicalReport);
chemicalReportId = chemicalReport.ArchitectureReportId;
db.SubmitChanges();
}
//var architectureReportItems = db.Environmental_ArchitectureReportItem.Where(x => x.ArchitectureReportId == chemicalReportId);
//if (architectureReportItems.Count() > 0)
//{
// db.Environmental_ArchitectureReportItem.DeleteAllOnSubmit(architectureReportItems);
// db.SubmitChanges();
//}
//保存子项
List<Model.Environmental_ArchitectureReportItem> ReportItemList =
new List<Model.Environmental_ArchitectureReportItem>();
foreach (var item in newItem.ArchitectureReportItem)
{
Model.Environmental_ArchitectureReportItem ReportItem =
new Model.Environmental_ArchitectureReportItem();
ReportItem.ArchitectureReportId = chemicalReportId;
ReportItem.ArchitectureReportItemId = SQLHelper.GetNewID();
ReportItem.SortIndex = item.SortIndex;
ReportItem.BaseNumber = item.BaseNumber;
ReportItem.LastYearValue = item.LastYearValue;
ReportItem.ThisYearValue = item.ThisYearValue;
ReportItem.Rate = item.Rate;
ReportItemList.Add(ReportItem);
}
if (ReportItemList.Count > 0)
db.Environmental_ArchitectureReportItem.InsertAllOnSubmit(ReportItemList);
db.SubmitChanges();
message = "保存成功!";
}
else
{
message += "上报日期不能为空!";
}
}
else
{
message += "单位不存在请确认单位Id和社会统一信用码";
}
}
else
{
message += "单位Id和社会统一信用码不能都为空";
}
}
responeData.data = new { message };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
/// <summary>
/// 修改建筑行业能源节约与生态环境保护汇总表
/// </summary>
/// <param name="items">数据项</param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData UpdateArchitectureReport(Model.Customization._7HJ.InformationData items)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
var responeData = new Model.ResponeData();
try
{
string message = string.Empty;
foreach (var newItem in items.InformationDataItems)
{
if (!string.IsNullOrEmpty(newItem.UnitId) || !string.IsNullOrEmpty(newItem.CollCropCode))
{
string unitId = string.Empty;
string unitName = string.Empty;
var unit = db.Base_Unit.FirstOrDefault(x => x.CollCropCode == newItem.CollCropCode);
if (unit != null)
{
unitId = unit.UnitId;
unitName = unit.UnitName;
}
else
{
var unit2 = db.Base_Unit.FirstOrDefault(x => x.UnitId == newItem.UnitId);
if (unit2 != null)
{
unitId = unit2.UnitId;
unitName = unit2.UnitName;
}
}
if (!string.IsNullOrEmpty(unitId))
{
DateTime? date = Funs.GetNewDateTime(newItem.FillingDate);
if (date != null)
{
Model.Environmental_ArchitectureReport chemicalReport =
new Model.Environmental_ArchitectureReport
{
Year = newItem.Year,
Quarters = newItem.Quarters,
UnitId = newItem.UnitId,
FillingDate = date,
DutyPerson = newItem.DutyPerson,
FillingMan = newItem.FillingMan
};
var chemicalReportId = newItem.ArchitectureReportId ?? "";
var oldArchitectureReport = db.Environmental_ArchitectureReport.FirstOrDefault(x =>
x.UnitId == chemicalReport.UnitId && x.Year == chemicalReport.Year &&
x.Quarters == chemicalReport.Quarters);
if (oldArchitectureReport == null)
{
chemicalReport.ArchitectureReportId = SQLHelper.GetNewID();
db.Environmental_ArchitectureReport.InsertOnSubmit(chemicalReport);
chemicalReportId = chemicalReport.ArchitectureReportId;
}
else
{
var architectureReportItems = db.Environmental_ArchitectureReportItem.Where(x =>
x.ArchitectureReportId == oldArchitectureReport.ArchitectureReportId);
db.Environmental_ArchitectureReportItem.DeleteAllOnSubmit(
architectureReportItems);
db.SubmitChanges();
db.Environmental_ArchitectureReport.DeleteOnSubmit(oldArchitectureReport);
db.SubmitChanges();
chemicalReport.ArchitectureReportId = SQLHelper.GetNewID();
db.Environmental_ArchitectureReport.InsertOnSubmit(chemicalReport);
chemicalReportId = chemicalReport.ArchitectureReportId;
db.SubmitChanges();
}
//var architectureReportItems = db.Environmental_ArchitectureReportItem.Where(x => x.ArchitectureReportId == chemicalReportId);
//if (architectureReportItems.Count() > 0)
//{
// db.Environmental_ArchitectureReportItem.DeleteAllOnSubmit(architectureReportItems);
// db.SubmitChanges();
//}
//保存子项
List<Model.Environmental_ArchitectureReportItem> ReportItemList =
new List<Model.Environmental_ArchitectureReportItem>();
foreach (var item in newItem.ArchitectureReportItem)
{
Model.Environmental_ArchitectureReportItem ReportItem =
new Model.Environmental_ArchitectureReportItem();
ReportItem.ArchitectureReportId = chemicalReportId;
ReportItem.ArchitectureReportItemId = SQLHelper.GetNewID();
ReportItem.SortIndex = item.SortIndex;
ReportItem.BaseNumber = item.BaseNumber;
ReportItem.LastYearValue = item.LastYearValue;
ReportItem.ThisYearValue = item.ThisYearValue;
ReportItem.Rate = item.Rate;
ReportItemList.Add(ReportItem);
}
if (ReportItemList.Count > 0)
db.Environmental_ArchitectureReportItem.InsertAllOnSubmit(ReportItemList);
db.SubmitChanges();
message = "保存成功!";
}
else
{
message += "上报日期不能为空!";
}
}
else
{
message += "单位不存在请确认单位Id和社会统一信用码";
}
}
else
{
message += "单位Id和社会统一信用码不能都为空";
}
}
responeData.data = new { message };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
#endregion
}
}